Class: Integer

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

Overview

class Fixnum def to_verilog to_s end end

Instance Method Summary collapse

Instance Method Details

#pow2?Boolean

Tells if the value is a power of 2.

Returns:

  • (Boolean)


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

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

#to_exprObject

Converts to a new high-level expression.



3901
3902
3903
# File 'lib/HDLRuby/hruby_high.rb', line 3901

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

#to_verilogObject



34
35
36
# File 'lib/HDLRuby/hruby_verilog.rb', line 34

def to_verilog
    to_s
end

#widthObject

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



33
34
35
# File 'lib/HDLRuby/hruby_tools.rb', line 33

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