class Integer
Attributes
Public Instance Methods
Source
# File lib/origen/core_ext/integer.rb, line 35 def cycles if block_given? times do yield Origen.app.tester.cycle end else Origen.app.tester.cycle(repeat: self) end end
Implements 10.cycles
Also aliased as: cycle
Source
# File lib/origen/core_ext/integer.rb, line 47 def ones_comp(num_bits) self ^ ((1 << num_bits) - 1) end
Also aliased as: ones_complement, ones_compliment
Source
# File lib/origen/core_ext/integer.rb, line 56 def to_bit_mask (1 << self) - 1 end
Returns a bit mask for the given number of bits:
4.to_bit_mask # => 0x1111
Also aliased as: bit_mask
Source
# File lib/origen/core_ext/integer.rb, line 61 def to_bool if self == 1 true elsif self == 0 false end end
Source
# File lib/origen/core_ext/integer.rb, line 69 def to_spreadsheet_column index_hash = Hash.new { |hash, key| hash[key] = hash[key - 1].next }.merge(0 => 'A') index_hash[self] end
Source
# File lib/origen/core_ext/integer.rb, line 79 def twos_complement(width = nil) _width = width || Integer.width if self > 2**(_width - 1) - 1 fail(RangeError, "Integer #{self} cannot fit into #{_width} bits with 2s complement encoding") elsif self < -1 * (2**(_width - 1)) fail(RangeError, "Integer #{self} cannot fit into #{_width} bits with 2s complement encoding") end self < 0 ? ((-1 * self) ^ (2**_width - 1)) + 1 : self end
Also aliased as: twos_comp, twos_compliment