Origen Memory Image (0.7.0)


This plugin provides a common API for easily reading memory image files in any format so that their contained data can then be used in Origen:

# Read in an s-record
srec = OrigenMemoryImage.new("srecs/test_atd.abs.S19")

# Write it to the DUT, or otherwise work with it, however you like
srec.to_a.each do |addr, data|
  $dut.write_memory data, address: addr

How To Import

To use in an application:

Add the following to your application’s Gemfile:

gem 'origen_memory_image', '0.7.0'
To use in a plugin:

Add the following to your plugin’s gemspec:

spec.add_runtime_dependency 'origen_memory_image', '~> 0', '>= 0.7.0'

and require the gem in your code:

require 'origen_memory_image'

How To Use

Create a memory map object that points to a specific source file, note that you do not need to supply the format. Also note that the format is detected by looking at the file content and the naming and extension of the file has no relevance (so it can be called anything).

The path to the file can be absolute or relative to Origen.root:

my_srec = OrigenMemoryImage.new("source_files/test_atd.abs.S19")
my_hex  = OrigenMemoryImage.new("source_files/math.hex")

Memory images can also be created directly from a string:

str = <<-END
0D 15 0F 13 0E 14 10 12
00 00 04 17 04 03 05 06

my_hex = OrigenMemoryImage.new(str, source: String)

Every memory image object then supports a common API.

The start_address method returns the start (execution start) address:

my_srec.start_address   # => 0x3000_F000

The to_a method returns the file content as an array of address/data pairs, this method supports options to set the data width, flip the data endianness, and crop the data between starting and ending address:

my_srec.to_a                                      # => [[0x3000_F000, 0x11223344], [0x3000_F004, 0x55667788], [0x3000_F008, 0x99AABBCC], ...]

my_srec.to_a(flip_endianness: true)               # => [[0x3000_F000, 0x44332211], [0x3000_F004, 0x88776655], [0x3000_F008, 0x99AABBCC], ...]

my_srec.to_a(data_width_in_bytes: 2)              # => [[0x3000_F000, 0x1122], [0x3000_F002, 0x3344], [0x3000_F004, 0x5566], ...]

my_srec.to_a(crop: [0x3000_F004])                 # => [[0x3000_F004, 0x55667788], [0x3000_F008, 0x99AABBCC], ...]

my_srec.to_a(crop: [0x3000_F000, 0x3000_F004])    # => [[0x3000_F000, 0x11223344], [0x3000_F004, 0x55667788]]

Such an array can be iterated on like this to separate the address and data:

my_srec.to_a.each do |address, data|
  # Process as required

Currently Supported Formats


Any valid S-record:


Hex Files

The data lines can be grouped into any size:

1E E0 02 1C 22 40 1B E0 02 1C 22 43 18 E0 02 1C 
5A 78 0A 43 03 E0 03 4B F7 21 5A 78 0A 40 00 20 
22 E0 84 42 22 D3 1F E0 84 42 1F D9 1C E0 84 42 
002B20D1 03E0012A 01D1002B 1BD00223 
2340022A 02D1002B 15D103E0 032A01D1 

Binary Files

A binary file:


How To Setup a Development Environment

Clone the repository from Github.

Follow the instructions here if you want to make a 3rd party app workspace use your development copy of the OrigenMemoryImage plugin: Setting up a Plugin Development Environment

This plugin also contains a test suite, makes sure this passes before committing any changes!

origen specs