class Origen::Registers::Container

A container can be used to easily interface register operations to an IPS-style interface where the container will take care of data alignment and byte enable calculations. A container looks and behaves like a register and drivers should be able to accept a container in place of a regular register.

Here are some examples:

include Origen::Registers

#       Name  Address  Size  Bits
add_reg :r0,   4,       8,    data => {:bits => 8}
add_reg :r1,   5,       8,    data => {:bits => 8}
add_reg :r2,   6,       8,    data => {:bits => 8}
add_reg :r3,   7,       8,    data => {:bits => 8}

reg(:r0).write(0xB0)
reg(:r1).write(0xB1)
reg(:r2).write(0xB2)
reg(:r3).write(0xB3)

big    = Container.new
little = Container.new(:endian => :little)

big.add(reg(:r0)).data              # => 0x0000_00B0
little.add(reg(:r0)).data           # => 0xB000_0000
big.byte_enable                     # => 0b0001
little.byte_enable                  # => 0b1000

big.empty
big.data                            # => 0x0000_0000
big.address                         # => nil
big.add(reg(:r2))
big.address                         # => 4 (longword aligned)
big.add(reg(:r3)).add(reg(:r1)
big.add.data                        # => 0xB3B2_B100
big.byte_enable                     # => 0b1110

# Treat it like it's a register in drivers:
big.shift_out_left do |bit|
  pin(:tdi).drive!(bit.data)
end

# The address can be overridden
big.empty
big.add(reg(:r2), :address => 10)
big.address                         # => 8 (longword aligned)

# Containers can accomodate other containers
big.empty
lower_word = Container.new
lower_word.add(:r0).add(:r1)
big.add(:r3)
lower_word.data                     # => 0x0000_B1B0
big.data                            # => 0xB300_0000
big.add(lower_word)
big.data                            # => 0xB300_B1B0
lower_word.data                     # => 0x0000_B1B0

# Contained registers are the same register objects
reg(:r0).write(0x55)
big.data                            # => 0xB300_B155
lower_word.data                     # => 0x0000_B155