Class: OrigenStandardSubblocks::RAM

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

Overview

Note:

This currently assumes 32-bit addresses.

Note:

This currently assumes Big-Endian address space (e.g., the RAM grows upwards).

Simple subblock for modeling RAM.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RAM

Note:

The length option is a required option.

Create a new OrigenStandardSubblocks::RAM object.

Parameters:

  • options (Hash) (defaults to: {})

    Initializaton options.

Options Hash (options):

  • :length (Fixnum)

    The length of the RAM, in bytes.

Raises:

  • (Origen::Error)

    When length is not given as an option.



13
14
15
16
17
18
19
# File 'lib/origen_standard_subblocks/RAM/ram.rb', line 13

def initialize(options = {})
  @length = options[:length]

  if @length.nil?
    Origen.app.fail(message: 'RAM subblock requires a :length option to be given!')
  end
end

Instance Method Details

#end_addrFixnum Also known as: end_address, end, last_addr, last_address, last

Note:

This assume 32-bit addresses

Returns the end address: i.e., the last usable address (not the length).

Returns:

  • (Fixnum)

    Indicating the last usable address.



50
51
52
# File 'lib/origen_standard_subblocks/RAM/ram.rb', line 50

def end_addr
  start_addr + length - 4
end

#lengthFixnum Also known as: size

Returns the length of the RAM

Returns:

  • (Fixnum)

    Indicating the length of the RAM.



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

def length
  @length
end

#start_addrFixnum Also known as: start_address, start, first_addr, first_address, first

Returns the start address (frst usable address) in the RAM.

Returns:

  • (Fixnum)

    Indicating the start address of the RAM.



23
24
25
# File 'lib/origen_standard_subblocks/RAM/ram.rb', line 23

def start_addr
  base_address
end