Class: Integer

Inherits:
Object
  • Object
show all
Defined in:
lib/HDLRuby/hruby_high.rb,
lib/HDLRuby/hruby_tools.rb,
lib/HDLRuby/hruby_verilog.rb
more...

Overview

For allocating numbers at structure declaration. (temporary)

Instance Method Summary collapse

Instance Method Details

#pow2?Boolean

Tells if the value is a power of 2.

Returns:

  • (Boolean)
[View source]

44
45
46
# File 'lib/HDLRuby/hruby_tools.rb', line 44

def pow2?
    return self > 0 && (self & (self - 1) == 0)
end

#to_exprObject

Converts to a new high-level expression.

[View source]

4269
4270
4271
# File 'lib/HDLRuby/hruby_high.rb', line 4269

def to_expr
    return Value.new(Integer,self)
end

#to_verilogObject

[View source]

42
43
44
# File 'lib/HDLRuby/hruby_verilog.rb', line 42

def to_verilog
    to_s
end

#widthObject

Gets the bit width NOTE: returns infinity if the number is negative.

[View source]

39
40
41
# File 'lib/HDLRuby/hruby_tools.rb', line 39

def width
    return self >= 0 ? Math.log2(self+1).ceil : 1.0/0.0
end