Class: HDLRuby::Low::TimeWait

Inherits:
Statement
  • Object
show all
Defined in:
lib/HDLRuby/hruby_db.rb,
lib/HDLRuby/hruby_low.rb,
lib/HDLRuby/hruby_low2c.rb,
lib/HDLRuby/hruby_low2hdr.rb,
lib/HDLRuby/hruby_low2vhd.rb,
lib/HDLRuby/hruby_verilog.rb,
lib/HDLRuby/hruby_low2high.rb,
lib/HDLRuby/hruby_low_mutable.rb,
lib/HDLRuby/hruby_low_skeleton.rb,
lib/HDLRuby/hruby_low_fix_types.rb,
lib/HDLRuby/hruby_low_bool2select.rb,
lib/HDLRuby/hruby_low_without_select.rb,
lib/HDLRuby/hruby_low_without_subsignals.rb,
lib/HDLRuby/hruby_low_casts_without_expression.rb

Overview

Extends the TimeWait class with functionality for extracting expressions from cast.

Direct Known Subclasses

High::TimeWait

Constant Summary

Constants included from Low2Symbol

Low2Symbol::Low2SymbolPrefix, Low2Symbol::Low2SymbolTable, Low2Symbol::Symbol2LowTable

Instance Attribute Summary collapse

Attributes included from Hparent

#parent

Instance Method Summary collapse

Methods inherited from Statement

#add_blocks_code, #add_make_block, #behavior, #block, #blocks2seq!, #break_types!, #delete_related!, #delete_unless!, #each_statement, #extract_declares!, #mix?, #par_in_seq2seq!, #parent_system, #replace_expressions!, #replace_names!, #scope, #to_ch, #to_seq!, #to_upper_space!, #top_block, #top_scope, #use_name?, #with_boolean!

Methods included from Low2Symbol

#to_sym

Methods included from Hparent

#hierarchy, #no_parent!, #scope

Constructor Details

#initialize(delay) ⇒ TimeWait

Creates a new statement waiting +delay+.



4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
# File 'lib/HDLRuby/hruby_low.rb', line 4122

def initialize(delay)
    # Check and set the delay.
    unless delay.is_a?(Delay)
        raise AnyError, "Invalid class for a delay: #{delay.class}."
    end
    super()
    @delay = delay
    # And set its parent.
    delay.parent = self
end

Instance Attribute Details

#delayObject (readonly)

The delay to wait.



4119
4120
4121
# File 'lib/HDLRuby/hruby_low.rb', line 4119

def delay
  @delay
end

Instance Method Details

#boolean_in_assign2select!Object

Converts booleans in assignments to select operators.



152
153
154
155
# File 'lib/HDLRuby/hruby_low_bool2select.rb', line 152

def boolean_in_assign2select!
    # Nothing to do.
    return self
end

#casts_without_expression!Object

Extracts the expressions from the casts.



137
138
139
140
# File 'lib/HDLRuby/hruby_low_casts_without_expression.rb', line 137

def casts_without_expression!
    # Nothing to do.
    return self
end

#cloneObject

Clones the TimeWait (deeply)



4158
4159
4160
# File 'lib/HDLRuby/hruby_low.rb', line 4158

def clone
    return TimeWait.new(@delay.clone)
end

#each_block(&ruby_block) ⇒ Object

Iterates over the sub blocks.



4179
4180
4181
4182
4183
4184
# File 'lib/HDLRuby/hruby_low.rb', line 4179

def each_block(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_block) unless ruby_block
    # A ruby block?
    # Nothing to do.
end

#each_block_deep(&ruby_block) ⇒ Object

Iterates over all the blocks contained in the current block.



4187
4188
4189
4190
4191
4192
# File 'lib/HDLRuby/hruby_low.rb', line 4187

def each_block_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_block_deep) unless ruby_block
    # A ruby block?
    # Nothing to do.
end

#each_deep(&ruby_block) ⇒ Object

Iterates over each object deeply.

Returns an enumerator if no ruby block is given.



4143
4144
4145
4146
4147
4148
4149
4150
# File 'lib/HDLRuby/hruby_low.rb', line 4143

def each_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_deep) unless ruby_block
    # A ruby block? First apply it to current.
    ruby_block.call(self)
    # Then apply on the delay.
    self.delay.each_deep(&ruby_block)
end

#each_node(&ruby_block) ⇒ Object

Iterates over the expression children if any.



4163
4164
4165
4166
4167
4168
# File 'lib/HDLRuby/hruby_low.rb', line 4163

def each_node(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_node) unless ruby_block
    # A ruby block?
    # Nothing to do.
end

#each_node_deep(&ruby_block) ⇒ Object

Iterates over the nodes deeply if any.



4171
4172
4173
4174
4175
4176
# File 'lib/HDLRuby/hruby_low.rb', line 4171

def each_node_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_node_deep) unless ruby_block
    # A ruby block? First apply it to current.
    ruby_block.call(self)
end

#each_statement_deep(&ruby_block) ⇒ Object

Iterates over all the statements contained in the current block.



4195
4196
4197
4198
4199
4200
4201
# File 'lib/HDLRuby/hruby_low.rb', line 4195

def each_statement_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_statement_deep) unless ruby_block
    # A ruby block?
    # Apply it on self.
    ruby_block.call(self)
end

#eql?(obj) ⇒ Boolean

Comparison for hash: structural comparison.

Returns:

  • (Boolean)


4134
4135
4136
4137
4138
# File 'lib/HDLRuby/hruby_low.rb', line 4134

def eql?(obj)
    return false unless obj.is_a?(TimeWait)
    return false unless @delay.eql?(obj.delay)
    return true
end

#explicit_types!Object

Explicit the types conversions in the time wait.



176
177
178
179
# File 'lib/HDLRuby/hruby_low_fix_types.rb', line 176

def explicit_types!
    # Nothing to do.
    return self
end

#extract_selects!Object

Extract the Select expressions.



105
106
107
108
# File 'lib/HDLRuby/hruby_low_without_select.rb', line 105

def extract_selects!
    # Nothing to extract.
    return []
end

#hashObject

Hash function.



4153
4154
4155
# File 'lib/HDLRuby/hruby_low.rb', line 4153

def hash
    return [@delay].hash
end

#map_nodes!(&ruby_block) ⇒ Object

Maps on the children (including the condition).



1049
1050
1051
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 1049

def map_nodes!(&ruby_block)
    # Nothing to do.
end

#set_delay!(delay) ⇒ Object

Sets the delay.



1038
1039
1040
1041
1042
1043
1044
1045
1046
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 1038

def set_delay!(delay)
    # Check and set the delay.
    unless delay.is_a?(Delay)
        raise AnyError, "Invalid class for a delay: #{delay.class}."
    end
    @delay = delay
    # And set its parent.
    delay.parent = self
end

#signal2subs!Object

Decompose the hierarchical signals in the statements.



97
98
99
100
# File 'lib/HDLRuby/hruby_low_without_subsignals.rb', line 97

def signal2subs!
    # Nothing to do.
    return self
end

#to_c(res, level = 0) ⇒ Object

Generates the C text of the equivalent HDLRuby code. +level+ is the hierachical level of the object. def to_c(level = 0)



1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
# File 'lib/HDLRuby/hruby_low2c.rb', line 1880

def to_c(res,level = 0)
    # The resulting string.
    # res = " " * level*3
    res << " " * level*3
    # Generate the wait.
    # res << "hw_wait(#{self.delay.to_c(level+1)}," +
    #     "#{Low2C.behavior_access(self)});\n"
    res << "hw_wait("
    self.delay.to_c(res,level+1)
    res << "," << Low2C.behavior_access(self) << ");\n"
    # Return the resulting string.
    return res
end

#to_hdr(level = 0) ⇒ Object

Generates the text of the equivalent hdr text. +level+ is the hierachical level of the object.



439
440
441
442
443
444
445
446
# File 'lib/HDLRuby/hruby_low2hdr.rb', line 439

def to_hdr(level = 0)
    # The resulting string.
    res = " " * (level*3)
    # Generate the wait.
    res << "wait " << self.delay.to_hdr(level) << "\n" 
    # Return the resulting string.
    return res
end

#to_highObject

Creates a new high wait statement.



319
320
321
# File 'lib/HDLRuby/hruby_low2high.rb', line 319

def to_high
    return HDLRuby::High::TimeWait.new(self.delay.to_high)
end

#to_verilog(spc = 3) ⇒ Object



1823
1824
1825
# File 'lib/HDLRuby/hruby_verilog.rb', line 1823

def to_verilog(spc = 3)
    return (" " * spc) + self.delay.to_verilog + "\n"
end

#to_vhdl(vars, level = 0) ⇒ Object

Generates the text of the equivalent HDLRuby::High code. +vars+ is the list of the variables and +level+ is the hierachical level of the object.



1047
1048
1049
1050
1051
1052
1053
1054
# File 'lib/HDLRuby/hruby_low2vhd.rb', line 1047

def to_vhdl(vars,level = 0)
    # The resulting string.
    res = " " * (level*3)
    # Generate the wait.
    res << "wait for " << self.delay.to_vhdl(level) << ";\n" 
    # Return the resulting string.
    return res
end