Sha256: 82c04f898e0ff21011c10bd43e1f7b86efc9566285a8407e95c5e2d028762567

Contents?: true

Size: 785 Bytes

Versions: 111

Compression:

Stored size: 785 Bytes

Contents

class Bignum
  # Extend Fixnum to enable 10.cycles
  def cycles
    if block_given?
      times do
        yield
        Origen.app.tester.cycle
      end
    else
      Origen.app.tester.cycle(repeat: self)
    end
  end
  alias_method :cycle, :cycles

  alias_method :old_bit_select, :[]
  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

  def ones_comp(num_bits)
    self ^ ((1 << num_bits) - 1)
  end
  alias_method :ones_complement, :ones_comp
  alias_method :ones_compliment, :ones_comp
end

Version data entries

111 entries across 111 versions & 1 rubygems

Version Path
origen-0.7.42 lib/origen/core_ext/bignum.rb
origen-0.7.41 lib/origen/core_ext/bignum.rb
origen-0.7.40 lib/origen/core_ext/bignum.rb
origen-0.7.39 lib/origen/core_ext/bignum.rb
origen-0.7.38 lib/origen/core_ext/bignum.rb
origen-0.7.37 lib/origen/core_ext/bignum.rb
origen-0.7.36 lib/origen/core_ext/bignum.rb
origen-0.7.35 lib/origen/core_ext/bignum.rb
origen-0.7.34 lib/origen/core_ext/bignum.rb
origen-0.7.33 lib/origen/core_ext/bignum.rb
origen-0.7.32 lib/origen/core_ext/bignum.rb
origen-0.7.31 lib/origen/core_ext/bignum.rb
origen-0.7.30 lib/origen/core_ext/bignum.rb
origen-0.7.29 lib/origen/core_ext/bignum.rb
origen-0.7.28 lib/origen/core_ext/bignum.rb
origen-0.7.27 lib/origen/core_ext/bignum.rb
origen-0.7.26 lib/origen/core_ext/bignum.rb
origen-0.7.25 lib/origen/core_ext/bignum.rb
origen-0.7.24 lib/origen/core_ext/bignum.rb
origen-0.7.23 lib/origen/core_ext/bignum.rb