Class: HDLRuby::Low::TimeWait
- Defined in:
- lib/HDLRuby/hruby_db.rb,
lib/HDLRuby/hruby_low.rb,
lib/HDLRuby/hruby_low2c.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
Overview
Extends the TimeWait class with functionality for converting booleans in assignments to select operators.
Direct Known Subclasses
Constant Summary
Constants included from Low2Symbol
Low2Symbol::Low2SymbolPrefix, Low2Symbol::Low2SymbolTable, Low2Symbol::Symbol2LowTable
Instance Attribute Summary collapse
-
#delay ⇒ Object
readonly
The delay to wait.
Attributes included from Hparent
Instance Method Summary collapse
-
#boolean_in_assign2select! ⇒ Object
Converts booleans in assignments to select operators.
-
#clone ⇒ Object
Clones the TimeWait (deeply).
-
#each_block(&ruby_block) ⇒ Object
Iterates over the sub blocks.
-
#each_block_deep(&ruby_block) ⇒ Object
Iterates over all the blocks contained in the current block.
-
#each_node(&ruby_block) ⇒ Object
Iterates over the expression children if any.
-
#each_node_deep(&ruby_block) ⇒ Object
Iterates over the nodes deeply if any.
-
#each_statement_deep(&ruby_block) ⇒ Object
Iterates over all the statements contained in the current block.
-
#eql?(obj) ⇒ Boolean
Comparison for hash: structural comparison.
-
#explicit_types! ⇒ Object
Explicit the types conversions in the time wait.
-
#extract_selects! ⇒ Object
Extract the Select expressions.
-
#hash ⇒ Object
Hash function.
-
#initialize(delay) ⇒ TimeWait
constructor
Creates a new statement waiting
delay. -
#map_nodes!(&ruby_block) ⇒ Object
Maps on the children (including the condition).
-
#set_delay!(delay) ⇒ Object
Sets the delay.
-
#to_c(level = 0) ⇒ Object
Generates the C text of the equivalent HDLRuby::High code.
-
#to_high(level = 0) ⇒ Object
Generates the text of the equivalent HDLRuby::High code.
- #to_verilog(mode = nil) ⇒ Object
-
#to_vhdl(vars, level = 0) ⇒ Object
Generates the text of the equivalent HDLRuby::High code.
Methods inherited from Statement
#add_blocks_code, #block, #blocks2seq!, #break_types!, #delete_unless!, #extract_declares!, #mix?, #replace_expressions!, #replace_names!, #to_upper_space!, #top_block, #top_scope, #with_boolean!
Methods included from Low2Symbol
Methods included from Hparent
Constructor Details
#initialize(delay) ⇒ TimeWait
Creates a new statement waiting delay.
3227 3228 3229 3230 3231 3232 3233 3234 3235 |
# File 'lib/HDLRuby/hruby_low.rb', line 3227 def initialize(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 |
Instance Attribute Details
#delay ⇒ Object (readonly)
The delay to wait.
3224 3225 3226 |
# File 'lib/HDLRuby/hruby_low.rb', line 3224 def delay @delay end |
Instance Method Details
#boolean_in_assign2select! ⇒ Object
Converts booleans in assignments to select operators.
126 127 128 129 |
# File 'lib/HDLRuby/hruby_low_bool2select.rb', line 126 def boolean_in_assign2select! # Nothing to do. return self end |
#clone ⇒ Object
Clones the TimeWait (deeply)
3250 3251 3252 |
# File 'lib/HDLRuby/hruby_low.rb', line 3250 def clone return TimeWait.new(@delay.clone) end |
#each_block(&ruby_block) ⇒ Object
Iterates over the sub blocks.
3271 3272 3273 3274 3275 3276 |
# File 'lib/HDLRuby/hruby_low.rb', line 3271 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.
3279 3280 3281 3282 3283 3284 |
# File 'lib/HDLRuby/hruby_low.rb', line 3279 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_node(&ruby_block) ⇒ Object
Iterates over the expression children if any.
3255 3256 3257 3258 3259 3260 |
# File 'lib/HDLRuby/hruby_low.rb', line 3255 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.
3263 3264 3265 3266 3267 3268 |
# File 'lib/HDLRuby/hruby_low.rb', line 3263 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.
3287 3288 3289 3290 3291 3292 3293 |
# File 'lib/HDLRuby/hruby_low.rb', line 3287 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.
3238 3239 3240 3241 3242 |
# File 'lib/HDLRuby/hruby_low.rb', line 3238 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.
143 144 145 146 |
# File 'lib/HDLRuby/hruby_low_fix_types.rb', line 143 def explicit_types! # Nothing to do. return self end |
#extract_selects! ⇒ Object
Extract the Select expressions.
104 105 106 107 |
# File 'lib/HDLRuby/hruby_low_without_select.rb', line 104 def extract_selects! # Nothing to extract. return [] end |
#hash ⇒ Object
Hash function.
3245 3246 3247 |
# File 'lib/HDLRuby/hruby_low.rb', line 3245 def hash return [@delay].hash end |
#map_nodes!(&ruby_block) ⇒ Object
Maps on the children (including the condition).
901 902 903 |
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 901 def map_nodes!(&ruby_block) # Nothing to do. end |
#set_delay!(delay) ⇒ Object
Sets the delay.
890 891 892 893 894 895 896 897 898 |
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 890 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 |
#to_c(level = 0) ⇒ Object
Generates the C text of the equivalent HDLRuby::High code.
level is the hierachical level of the object.
1232 1233 1234 1235 1236 1237 1238 1239 1240 |
# File 'lib/HDLRuby/hruby_low2c.rb', line 1232 def to_c(level = 0) # The resulting string. res = " " * level*3 # Generate the wait. res << "hw_wait(#{self.delay.to_c(level+1)}," + "#{Low2C.behavior_access(self)});\n" # Return the resulting string. return res end |
#to_high(level = 0) ⇒ Object
Generates the text of the equivalent HDLRuby::High code.
level is the hierachical level of the object.
439 440 441 442 443 444 445 446 |
# File 'lib/HDLRuby/hruby_low2high.rb', line 439 def to_high(level = 0) # The resulting string. res = " " * (level*3) # Generate the wait. res << "wait " << self.delay.to_high(level) << "\n" # Return the resulting string. return res end |
#to_verilog(mode = nil) ⇒ Object
1589 1590 1591 |
# File 'lib/HDLRuby/hruby_verilog.rb', line 1589 def to_verilog(mode=nil) return self.delay.to_verilog 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.
981 982 983 984 985 986 987 988 |
# File 'lib/HDLRuby/hruby_low2vhd.rb', line 981 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 |