Class Integer
In: lib/ruby-vpi/integer.rb
Parent: Object

NOTE: Because integers are immediate values in Ruby, these methods cannot modify the value of the integer upon which they are invoked. Instead, they return the new value as their result.

Methods

extend_sign   length   limit   log2   mask   max   pack   split   to_limit   to_mask   to_max   unpack  

Public Instance methods

Performs sign extension on this integer, which has the given width (number of bits), so that the result will have the given extended width (number of bits).

Returns the minimum number of bits necessary to represent this integer.

Returns the lowest upper-bound of this integer. This integer cannot reach the limit without occupying more bits in its binary representation.

Returns the ceiling of the logarithm (base 2) of this positive integer.

Returns a bit-mask capable of masking this integer.

max()

Alias for mask

Transforms this infinite-length Ruby integer into a fixed-length integer (represented in two‘s complement form) that has the given width (number of bits).

Splits this integer into an array of smaller integers, each of which have the given positive, non-zero width (number of bits). These smaller integers are ordered from left to right, in the same way that humans write unsigned binary numbers; for example:

 >> 6.split 1
 => [1, 1, 0]
 >> 6.split(1).map {|i| i.to_s 2}
 => ["1", "1", "0"]
 >> 6.split 2
 => [1, 2]
 >> 6.split(2).map {|i| i.to_s 2}
 => ["1", "10"]

Returns the lowest upper-bound of an integer with this number of bits.

Returns a bit-mask capable of masking an integer with this number of bits.

to_max()

Alias for to_mask

Transforms this fixed-length integer (represented in two‘s complement form) that has the given width (number of bits) into an infinite-length Ruby integer.

[Validate]