Class: Bignum

Inherits:
Object show all
Defined in:
lib/origen/core_ext/bignum.rb

Instance Method Summary collapse

Instance Method Details

#[](*args) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/origen/core_ext/bignum.rb', line 16

def [](*args)
  if args.length == 1 && !args.first.is_a?(Range)
    old_bit_select(args.first)
  else
    if args.first.is_a?(Range)
      msb = args.first.first
      lsb = args.first.last
    else
      msb = args.first
      lsb = args.last
    end
    (self >> lsb) & 0.ones_comp(msb - lsb + 1)
  end
end

#cyclesObject Also known as: cycle

Extend Fixnum to enable 10.cycles



3
4
5
6
7
8
9
10
11
12
# File 'lib/origen/core_ext/bignum.rb', line 3

def cycles
  if block_given?
    times do
      yield
      Origen.app.tester.cycle
    end
  else
    Origen.app.tester.cycle(repeat: self)
  end
end

#old_bit_selectObject



15
# File 'lib/origen/core_ext/bignum.rb', line 15

alias_method :old_bit_select, :[]

#ones_comp(num_bits) ⇒ Object Also known as: ones_complement, ones_compliment



31
32
33
# File 'lib/origen/core_ext/bignum.rb', line 31

def ones_comp(num_bits)
  self ^ ((1 << num_bits) - 1)
end