Class: Integer
- Inherits:
-
Object
- Object
- Integer
- Defined in:
- lib/HDLRuby/hruby_high.rb,
lib/HDLRuby/hruby_tools.rb,
lib/HDLRuby/hruby_verilog.rb
Overview
For allocating numbers at structure declaration. (temporary)
Instance Method Summary collapse
-
#pow2? ⇒ Boolean
Tells if the value is a power of 2.
-
#to_expr ⇒ Object
Converts to a new high-level expression.
- #to_verilog ⇒ Object
-
#width ⇒ Object
Gets the bit width NOTE: returns infinity if the number is negative.
Instance Method Details
#pow2? ⇒ Boolean
Tells if the value is a power of 2.
45 46 47 |
# File 'lib/HDLRuby/hruby_tools.rb', line 45 def pow2? return self > 0 && (self & (self - 1) == 0) end |
#to_expr ⇒ Object
Converts to a new high-level expression.
4441 4442 4443 |
# File 'lib/HDLRuby/hruby_high.rb', line 4441 def to_expr return Value.new(Integer,self) end |
#to_verilog ⇒ Object
42 43 44 |
# File 'lib/HDLRuby/hruby_verilog.rb', line 42 def to_verilog to_s end |
#width ⇒ Object
Gets the bit width NOTE: returns infinity if the number is negative.
40 41 42 |
# File 'lib/HDLRuby/hruby_tools.rb', line 40 def width return self >= 0 ? Math.log2(self+1).ceil : 1.0/0.0 end |