Class: Origen::Registers::Msb0Delegator

Inherits:
Delegator
  • Object
show all
Defined in:
lib/origen/registers/msb0_delegator.rb

Overview

Thin wrapper around register objects to modify bit number interpretation

This is provided as a convenience to make user code more readable

Instance Method Summary collapse

Constructor Details

#initialize(reg_object, bits) ⇒ Msb0Delegator

Returns a new instance of Msb0Delegator.



9
10
11
12
# File 'lib/origen/registers/msb0_delegator.rb', line 9

def initialize(reg_object, bits)
  @reg_object = reg_object
  @bits = bits
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/origen/registers/msb0_delegator.rb', line 31

def method_missing(method, *args, &block)
  if args.last.is_a?(Hash)
    args.last[:with_bit_order] = :msb0
  else
    args << { with_bit_order: :msb0 }
  end
  @reg_object.method_missing(method, *args, &block)
end

Instance Method Details

#__getobj__Object



14
15
16
# File 'lib/origen/registers/msb0_delegator.rb', line 14

def __getobj__
  @reg_object
end

#__object__Object



18
19
20
# File 'lib/origen/registers/msb0_delegator.rb', line 18

def __object__
  @reg_object
end

#__setobj__(obj) ⇒ Object



22
23
24
# File 'lib/origen/registers/msb0_delegator.rb', line 22

def __setobj__(obj)
  @reg_object = obj
end

#bit(*args) ⇒ Object Also known as: bits, []



40
41
42
# File 'lib/origen/registers/msb0_delegator.rb', line 40

def bit(*args)
  @reg_object.bit(args, with_bit_order: :msb0)
end

#inspect(options = {}) ⇒ Object



26
27
28
29
# File 'lib/origen/registers/msb0_delegator.rb', line 26

def inspect(options = {})
  options[:with_bit_order] = :msb0
  @reg_object.inspect(options)
end