Embedded Design Handbook

ID 683689
Date 8/28/2023
Public
Document Table of Contents

3.7.5.1.3. Add Memory Master Components

Memory masters access the SDRAM controller by writing the test pattern to the memory and reading the pattern back for validation. The RAM test controller accepts commands from the processor and controls the memory masters. Each command contains a start address, test length in bytes, and memory block size in bytes. The RAM test controller segments the commands into smaller block transfers and issues the commands to the read and write masters independently via streaming connections.

When the pattern reader or writer components complete a block transfer, they signal to the RAM test controller that they are ready for another command. The RAM test controller issues the block-sized commands independently, which minimizes the number of idle cycles between memory transfers. The RAM test controller also ensures that the pattern reader never overtakes the pattern writer with respect to the memory locations it is testing, otherwise data corruption occurs.

The SDRAM controller is parameterized to use a local maximum burst length of 2. The pattern reader and writer components are also configured to match this burst length to maximize the memory bandwidth.

Add a Pattern Writer Component

The pattern writer component accepts memory transfer commands from the RAM test controller with the command streaming interface. The st_data streaming interface accepts data provided by the design’s pattern generator. The mm_data memory-mapped interface writes the pattern data to the SDRAM controller.
  1. In the IP Catalog, double-click Pattern Writer from the Memory Test Microcores group.
  2. In the parameter editor, turn on Burst Enable.
  3. Ensure that the Maximum Burst Count is 2.
  4. Ensure that Enable Burst Re-alignment is turned on.
  5. To accept the other default parameters, click Finish.
  6. Rename the instance to pattern_writer.
  7. Set the pattern_writer clock to clk_0.
  8. Connect the pattern_writer st_data interface to the pattern_generator_subsystem st_data_out interface.
  9. Export the pattern_writer mm_data interface with the name write_master.

Add a Pattern Reader Component

The pattern reader component accepts memory transfer commands from the RAM test controller with the command streaming interface. The mm_data interface reads the pattern data from the SDRAM controller. The st_data interface sends the data read from memory to the design’s pattern checker.
  1. In the IP Catalog, double-click Pattern Reader from the Memory Test Microcores group.
  2. n the parameter editor, turn on Burst Enable.
  3. Ensure the Maximum Burst Count is 2.
  4. Ensure that Enable Burst Re-alignment is turned on.
  5. To accept the other default parameters, click Finish.
  6. Rename the instance to pattern_reader.
  7. Set the pattern_reader clock to clk_0.
  8. Connect the pattern_reader st_data interface to the pattern_checker_subsystem st_data_in interface.
  9. Export the pattern_reader mm_data interface with the name read_master.

Add a RAM Test Controller

The RAM test controller contains two streaming command interfaces; write_command and read_command, that send commands to the pattern reader and pattern writer components. These streaming interfaces issue commands effectively because Avalon-ST interfaces offer low latency and a simple handshaking protocol, as well as because the processor accesses a slave port, csr, to write commands to the controller.
  1. In the IP Catalog, double-click RAM Test Controller from the Memory Test Microcores group.
  2. In the parameter editor, click Finish to accept the default parameters.
  3. Rename the instance to ram_test_controller.
  4. Set the ram_test_controller clock to clk_0.
  5. Connect the ram_test_controller write_command interface to the pattern_writer_command interface.
  6. Connect the ram_test_controller read_command interface to the pattern_reader_command interface.
  7. Connect the ram_test_controller csr interface to the mm_bridge m0 interface.

Do not use the Generation tab at this point in the tutorial to generate HDL code for these subsystems. You must generate files for the entire top-level system, which includes all the subsystems. The batch script provided for you to program the device requires that only one system is generated in the project directory. The top-level design includes a Nios® II subsystem, and the Nios® II software build tools require the SOPC Information File (.sopcinfo) to be generated for the top-level design. If there are multiple .sopcinfo files, the batch script to program the device fails with an error from the software build tools.