Class: OrigenStandardSubblocks::RAMController

Inherits:
Object
  • Object
show all
Includes:
Origen::Controller
Defined in:
lib/origen_standard_subblocks/RAM/ram_controller.rb

Instance Method Summary collapse

Instance Method Details

#[](index) ⇒ Origen:Registers::Reg

TODO:

Add support for negative index notation & ranges.

TODO:

Add support for bounds checking.

Shortcut for mem, where the base address is added to the index.

Examples:

Get a Origen::Registers::Reg object for the first usable memory location (indexes start at 0)

r = dut.ram[0]
r.class #=> Origen::Registers::Reg
r.address.to_hex #=> '0x100'

Get a Origen::Registers::Reg object for the second usable memory location (indexes start at 0)

# Assume base address is 0x100 and the length is 0x10
r = dut.ram[1]
r.class #=> Origen::Registers::Reg
r.address.to_hex #=> '0x104'

Parameters:

  • index (Fixnum)

    Offset index in the RAM. Note that standard index notation is used. I.e., an index of 0 corresponds to the first usable address and an index of 1 corresponds to the second usable address.

Returns:

  • (Origen:Registers::Reg)


21
22
23
# File 'lib/origen_standard_subblocks/RAM/ram_controller.rb', line 21

def [](index)
  dut.mem(start_addr + (4 * index))
end

#[]=(index, data) ⇒ Origen::Registers::BitCollection

TODO:

Add support for negative index notation & ranges.

TODO:

Add support for bounds checking.

Shortcut for mem.write!, where the base address is added to the index.

Parameters:

  • index (Fixnum)

    Offset index in the RAM. Note that standard index notation is used. I.e., an index of 0 corresponds to the first usable address and an index of 1 corresponds to the second usable address.

  • data (Fixnum)

    Data to write to the RAM location indicated by the index. Or: RAM[index] <= data

Returns:

  • (Origen::Registers::BitCollection)


34
35
36
# File 'lib/origen_standard_subblocks/RAM/ram_controller.rb', line 34

def []=(index, data)
  self[index].write!(data)
end