class Integer

Extends the Integer class for computing for conversion to expression.

Extends the Integer class for computing the bit width.

Public Instance Methods

pow2?() click to toggle source

Tells if the value is a power of 2.

# File lib/HDLRuby/hruby_tools.rb, line 37
def pow2?
    return self > 0 && (self & (self - 1) == 0)
end
to_expr() click to toggle source

Converts to a new high-level expression.

# File lib/HDLRuby/hruby_high.rb, line 4259
def to_expr
    return Value.new(Integer,self)
end
to_verilog() click to toggle source
# File lib/HDLRuby/hruby_verilog.rb, line 42
def to_verilog
    to_s
end
width() click to toggle source

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

# File lib/HDLRuby/hruby_tools.rb, line 32
def width
    return self >= 0 ? Math.log2(self+1).ceil : 1.0/0.0
end