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.
3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 |
# File 'lib/HDLRuby/hruby_low.rb', line 3248 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.
3242 3243 3244 |
# File 'lib/HDLRuby/hruby_low.rb', line 3242 def unit @unit end |
#value ⇒ Object (readonly)
The time value.
3245 3246 3247 |
# File 'lib/HDLRuby/hruby_low.rb', line 3245 def value @value end |
Instance Method Details
#clone ⇒ Object
Clones the Delay (deeply)
3273 3274 3275 |
# File 'lib/HDLRuby/hruby_low.rb', line 3273 def clone return Delay.new(@value,@unit) end |
#eql?(obj) ⇒ Boolean
Comparison for hash: structural comparison.
3260 3261 3262 3263 3264 3265 |
# File 'lib/HDLRuby/hruby_low.rb', line 3260 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.
3268 3269 3270 |
# File 'lib/HDLRuby/hruby_low.rb', line 3268 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.
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 |
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 936 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.
925 926 927 928 |
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 925 def set_unit!(unit) # Check and set the unit. @unit = unit.to_sym end |
#set_value!(value) ⇒ Object
Sets the value.
915 916 917 918 919 920 921 922 |
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 915 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.
1226 1227 1228 1229 |
# File 'lib/HDLRuby/hruby_low2c.rb', line 1226 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
1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 |
# File 'lib/HDLRuby/hruby_verilog.rb', line 1670 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.
998 999 1000 |
# File 'lib/HDLRuby/hruby_low2vhd.rb', line 998 def to_vhdl(level = 0) return self.value.to_vhdl(level) + " #{self.unit}" end |