Products & Services Solutions Academia Support User Community Company

RAM Blocks

Overview of RAM Blocks

The RAM blocks let you:

The RAM blocks are grouped together in the hdldemolib library, as shown in the following figure. The library provides three type of RAM blocks:

To open the library, type the following command at the MATLAB prompt:

hdldemolib

Then, drag the desired RAM block from the hdldemolib library to your model, and set the block parameters and connect signals following the guidelines in the following sections.

RAM Block Demo

The RAM-Based FIR Filter demo (hdlcoderfirram.mdl) provides an example of VHDL code generation for a Dual Port RAM block. Run this demo to acquaint yourself with the generated code.

The HDL device under test (DUT) in the model is the FIR_RAM subsystem. The FIR_RAM subsystem contains a Dual Port RAM block. The entity and architecture definitions generated for this block are written to DualPortRAM_Inst0.vhd .

The code generated for the top-level DUT, FIR_RAM.vhd, contains the component instantiation for the Dual Port RAM block.

Dual Port RAM Block

Dual Port RAM Block Ports and Parameters

The following figure shows the Dual Port RAM block.

The block has the following input and output ports:

Read-During-Write Behavior

During a write, new data appears at the output of the write port (wr_dout) of the Dual Port RAM block. If a read operation is performed at the same address at the read port, old data is read at the output (rd_dout).

Simple Dual Port RAM Block

Simple Dual Port RAM Block Ports and Parameters

The following figure shows the Simple Dual Port RAM block.

This block is similar to the Dual Port RAM. It differs from Dual Port RAM in its read-during-write behavior, and it does not have the data output at the write port (wr_dout).

The block has the following input and output ports:

Read-During-Write Behavior

During a write operation, if a read operation is performed at the same address at the read port, old data is read at the output.

Single Port RAM Block

Single Port RAM Block Ports and Parameters

The following figure shows the Single Port RAM block.

The block has the following input and output ports:

Read-During-Write Behavior

The Output data during write drop-down menu provides options that control how the RAM handles output/read data. These options are:

Code Generation with RAM Blocks

The following general considerations apply to code generation for any of the RAM blocks:

RAM Block Implementations

The following table shows HDL implementation names and implementation parameters for each type of RAM block..

RAM BlockImplementationImplementation
Parameter
Dual Port RAMhdldefaults.
RamBlockDualHDLInstantiation
RAMStyle
Simple Dual Port RAMhdldefaults.
RamBlockSimpDualHDLInstantiation
RAMStyle
Single Port RAMhdldefaults.
RamBlockSingleHDLInstantiation
RAMStyle

The RAMStyle implementation parameter lets you enable or suppress generation of clock enable logic. RAMStyle supports the following parameter values:

In many cases, you can use the default and leave RAMStyle unspecified. However, some synthesis tools do not support RAM inference with a clock enable. You may want to specify RAMStyle as 'generic' if your synthesis tool does not support RAM structures with a clock enable, and cannot map generated HDL code to FPGA RAM resources. To learn how to use generic style RAM for your design, see the Getting Started with RAM and ROM demo in Simulink demo. To open the demo, type the following command at the MATLAB prompt:

hdlcoderramrom

Limitations for RAM Blocks

The following limitations apply to the use of RAM blocks in HDL code generation:

Generic RAM and ROM Demos

Generic RAM Template Supports RAM Without a Clock Enable Signal

The RAM blocks in the hdldemolib library implement RAM structures using HDL templates that include a clock enable signal.

However, some synthesis tools do not support RAM inference with a clock enable. As an alternative, the coder provides a generic style of HDL templates that do not use a clock enable signal for the RAM structures. The generic RAM template implements clock enable with logic in a wrapper around the RAM.

You may want to use the generic RAM style if your synthesis tool does not support RAM structures with a clock enable, and cannot map generated HDL code to FPGA RAM resources. To learn how to use generic style RAM for your design, see the Getting Started with RAM and ROM demo in Simulink demo. To open the demo, type the following command at the MATLAB prompt:

hdlcoderramrom

Generating ROM with Lookup Table and Unit Delay Blocks

Simulink HDL Coder does not provide a ROM block, but you can easily build one using basic Simulink blocks. The new Getting Started with RAM and ROM in Simulink demo includes an example in which a ROM is built using a Lookup Table block and a Unit Delay block. To open the demo, type the following command at the MATLAB prompt:

hdlcoderramrom
  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS