class HDLRuby::Low::Delay
Describes a delay: not synthesizable.
Describes a delay: not synthesizable.
Extends the Delay
class with generation of C text.
Extends the Delay
class with generation of hdr text.
Add the conversion to high.
Extends the Delay
class with conversion to symbol.
Extends the Delay
class with generation of HDLRuby::High
text.
Describes a delay: not synthesizable.
Attributes
The time unit.
The time value.
Public Class Methods
Creates a new delay of value
unit
of time.
# File lib/HDLRuby/hruby_low.rb, line 3615 def initialize(value,unit) # Check and set the value. unless value.is_a?(Numeric) raise AnyError, "Invalid class for a delay value: #{value.class}." end @value = value # Check and set the unit. @unit = unit.to_sym end
Public Instance Methods
Clones the Delay
(deeply)
# File lib/HDLRuby/hruby_low.rb, line 3655 def clone return Delay.new(@value,@unit) end
Iterates over each object deeply.
Returns an enumerator if no ruby block is given.
# File lib/HDLRuby/hruby_low.rb, line 3632 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 value. self.value.each_deep(&ruby_block) end
Comparison for hash: structural comparison.
# File lib/HDLRuby/hruby_low.rb, line 3642 def eql?(obj) return false unless obj.is_a?(Delay) return false unless @unit.eql?(obj.unit) return false unless @value.eql?(obj.value) return true end
Hash
function.
# File lib/HDLRuby/hruby_low.rb, line 3650 def hash return [@unit,@value].hash end
Replaces sub expressions using node2rep
table indicating the node to replace and the corresponding replacement. Returns the actually replaced nodes and their corresponding replacement.
NOTE: the replacement is duplicated.
# File lib/HDLRuby/hruby_low_mutable.rb, line 994 def replace_expressions!(node2rep) # First recurse on the children. res = self.value.replace_expressions! # Is there a replacement to do on the value? rep = node2rep[self.value] if rep then # Yes, do it. rep = rep.clone node = self.value # node.set_parent!(nil) self.set_value!(rep) # And register the replacement. res[node] = rep end return res end
Sets the unit.
# File lib/HDLRuby/hruby_low_mutable.rb, line 983 def set_unit!(unit) # Check and set the unit. @unit = unit.to_sym end
Sets the value.
# File lib/HDLRuby/hruby_low_mutable.rb, line 973 def set_value!(value) # Check and set the value. unless value.is_a?(Numeric) raise AnyError, "Invalid class for a delay value: #{value.class}." end @value = value end
Generates the C text of the equivalent HDLRuby
code. level
is the hierachical level of the object.
# File lib/HDLRuby/hruby_low2c.rb, line 1321 def to_c(level = 0) return "make_delay(#{self.value.to_s}," + "#{Low2C.unit_name(self.unit)})" end
Generates the text of the equivalent hdr text. level
is the hierachical level of the object.
# File lib/HDLRuby/hruby_low2hdr.rb, line 428 def to_hdr(level = 0) return self.value.to_hdr(level) + ".#{self.unit}" end
Creates a new high delay.
# File lib/HDLRuby/hruby_low2high.rb, line 300 def to_high return HDLRuby::High::Delay.new(self.value,self.unit) end
# File lib/HDLRuby/hruby_verilog.rb, line 1725 def to_verilog time = self.value.to_s if(self.unit.to_s == "ps") then return "##{time};" elsif(self.unit.to_s == "ns") return "##{time}000;" elsif(self.unit.to_s == "us") return "##{time}000000;" elsif(self.unit.to_s == "ms") return "##{time}000000000;" elsif(self.unit.to_s == "s") return "##{time}000000000000;" end end
Generates the text of the equivalent HDLRuby::High
code. level
is the hierachical level of the object.
# File lib/HDLRuby/hruby_low2vhd.rb, line 1022 def to_vhdl(level = 0) return self.value.to_vhdl(level) + " #{self.unit}" end