Class: HDLRuby::Low::Delay
- Inherits:
-
Base::Delay
- Object
- Base::Delay
- HDLRuby::Low::Delay
- Includes:
- Hparent, Low2Symbol
- Defined in:
- lib/HDLRuby/hruby_db.rb,
lib/HDLRuby/hruby_low.rb,
lib/HDLRuby/hruby_low2c.rb,
lib/HDLRuby/hruby_low2sym.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
Overview
Describes a delay: not synthesizable.
Direct Known Subclasses
Constant Summary
Constants included from Low2Symbol
Low2Symbol::Low2SymbolPrefix, Low2Symbol::Low2SymbolTable, Low2Symbol::Symbol2LowTable
Instance Attribute Summary collapse
-
#unit ⇒ Object
readonly
The time unit.
-
#value ⇒ Object
readonly
The time value.
Attributes included from Hparent
Instance Method Summary collapse
-
#clone ⇒ Object
Clones the Delay (deeply).
-
#eql?(obj) ⇒ Boolean
Comparison for hash: structural comparison.
-
#hash ⇒ Object
Hash function.
-
#initialize(value, unit) ⇒ Delay
constructor
Creates a new delay of +value+ +unit+ of time.
-
#replace_expressions!(node2rep) ⇒ Object
Replaces sub expressions using +node2rep+ table indicating the node to replace and the corresponding replacement.
-
#set_unit!(unit) ⇒ Object
Sets the unit.
-
#set_value!(value) ⇒ Object
Sets the value.
-
#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 ⇒ Object
-
#to_vhdl(level = 0) ⇒ Object
Generates the text of the equivalent HDLRuby::High code.
Methods included from Low2Symbol
Methods included from Hparent
Constructor Details
#initialize(value, unit) ⇒ Delay
Creates a new delay of +value+ +unit+ of time.
3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 |
# File 'lib/HDLRuby/hruby_low.rb', line 3203 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 |
Instance Attribute Details
#unit ⇒ Object (readonly)
The time unit.
3197 3198 3199 |
# File 'lib/HDLRuby/hruby_low.rb', line 3197 def unit @unit end |
#value ⇒ Object (readonly)
The time value.
3200 3201 3202 |
# File 'lib/HDLRuby/hruby_low.rb', line 3200 def value @value end |
Instance Method Details
#clone ⇒ Object
Clones the Delay (deeply)
3228 3229 3230 |
# File 'lib/HDLRuby/hruby_low.rb', line 3228 def clone return Delay.new(@value,@unit) end |
#eql?(obj) ⇒ Boolean
Comparison for hash: structural comparison.
3215 3216 3217 3218 3219 3220 |
# File 'lib/HDLRuby/hruby_low.rb', line 3215 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 ⇒ Object
Hash function.
3223 3224 3225 |
# File 'lib/HDLRuby/hruby_low.rb', line 3223 def hash return [@unit,@value].hash end |
#replace_expressions!(node2rep) ⇒ Object
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.
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 |
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 865 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 |
#set_unit!(unit) ⇒ Object
Sets the unit.
854 855 856 857 |
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 854 def set_unit!(unit) # Check and set the unit. @unit = unit.to_sym end |
#set_value!(value) ⇒ Object
Sets the value.
844 845 846 847 848 849 850 851 |
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 844 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 |
#to_c(level = 0) ⇒ Object
Generates the C text of the equivalent HDLRuby::High code. +level+ is the hierachical level of the object.
1223 1224 1225 1226 |
# File 'lib/HDLRuby/hruby_low2c.rb', line 1223 def to_c(level = 0) return "make_delay(#{self.value.to_s}," + "#{Low2C.unit_name(self.unit)})" end |
#to_high(level = 0) ⇒ Object
Generates the text of the equivalent HDLRuby::High code. +level+ is the hierachical level of the object.
428 429 430 |
# File 'lib/HDLRuby/hruby_low2high.rb', line 428 def to_high(level = 0) return self.value.to_high(level) + ".#{self.unit}" end |
#to_verilog ⇒ Object
1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 |
# File 'lib/HDLRuby/hruby_verilog.rb', line 1662 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 |
#to_vhdl(level = 0) ⇒ Object
Generates the text of the equivalent HDLRuby::High code. +level+ is the hierachical level of the object.
983 984 985 |
# File 'lib/HDLRuby/hruby_low2vhd.rb', line 983 def to_vhdl(level = 0) return self.value.to_vhdl(level) + " #{self.unit}" end |