Dual Port RAM System - Dual-port RAM that supports simultaneous read and write operations - Simulink (original) (raw)

Dual-port RAM that supports simultaneous read and write operations

Libraries:
HDL Coder / HDL RAMs

Description

The Dual Port RAM System block models a dual-port RAM that supports simultaneous read and write operations through output ports for read and write data. To configure this block, open the block and set the Type of RAM parameter to dual port. By using this block, you can:

Note

During a write, new data appears at the output of the write portwr_dout of the Dual Port RAM System block. If a read operation occurs simultaneously at the same address as a write operation, old data appears at the read output port rd_dout.

Limitations

Ports

Input

expand all

Data to write, specified as a scalar or a vector. You can write the data into the RAM memory location when the write enable signal at portwe is true. This value can be an integer, or of type double,single or half. The value can also be a fi object and can be real or complex.

Bus Support:

You can use non-virtual bus and arrays of buses for HDL code generation.

Data Types: single | double | half | int8 | int16 | uint8 | uint16 | Boolean | fixed point

Address to write, specified as a scalar or a vector. Use this address to write to RAM when the signal at port we istrue. This value can be either afixed-point (fi) or an unsignedinteger and must be between 2 and 31 bits long.

Data Types: uint8 | uint16 | fixed point

Write enable, specified as a scalar or a vector. When the signal at port we is true, the block writes the data into the specified memory location. When the signal at port we is false, the block reads the value from the memory location specified byrd_addr port when the signal at portwe is false.

Note

To use column-write method, the data type must be aninteger or afixed-point.

Data Types: uint8 | uint16 | uint32 | uint64 | Boolean | fixed point

Address to read, specified as a scalar or a vector. Use this address to read the data from the RAM. This value can be either afixed-point (fi) or an unsignedinteger and must be between 2 and 31 bits long.

Data Types: uint8 | uint16 | fixed point

Output

expand all

Read output data, returned as a scalar or vector. The block reads the old data from the memory location specified by therd_addr port.

Write output data, returned as a scalar or vector. The block reads the new or old data from the memory location specified by thewr_addr port.

Parameters

expand all

Main

Type of RAM, specified as either:

The code generator dynamically configures the input and output ports of the block based on the RAM type that you specify.

Programmatic Use

**Block Parameter:**RAMType
Type: character vector, string
Values: Dual port | Simple dual port Single port True dual port Simple tri port
Default: Dual port

Enable this option to allow the hardware to execute a read instruction immediately, without waiting one cycle.

Programmatic Use

**Block Parameter:**AsyncRead
Type: character vector, string
Values: 'on' | 'off'
Default: 'off'

Select the behavior for write output as New data orOld data:

Dependencies

To enable this parameter, clear the Use asynchronous read feature in target hardware parameter.

Programmatic Use

**Block Parameter:**WriteOutputValue
Type: character vector, string
Values: New data | Old data
Default: New data

Specify the initial simulation output of the RAM by using one of these options:

Programmatic Use

**Block Parameter:**RAMInitialValue
Type: integer, floating point
Values: 0.0 | Scalar Vector
Default: 0.0

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Advanced

Since R2024b

Dependencies

To enable this parameter, clear the Use asynchronous read feature in target hardware parameter.

Programmatic Use

**Block Parameter:**ModelRAMDelay
Type: character vector, string
Values: 'on' | 'off'
Default: 'on'

Since R2025a

Dependencies

To enable this parameter, clear the Model RAM with one cycle of delay parameter or enable the Use asynchronous read feature in target hardware parameter.

Programmatic Use

**Block Parameter:**VectorAccess
Type: character vector, string
Values: 'serial' | 'parallel'
Default: 'serial'

More About

expand all

You can use the column-write method to view the RAM as a collection of equally sized columns. During a write cycle, you can write into each of these columns separately. The data type and value of the write enable input, along with the data type of write data input, determine the size of each column and the columns in which the block writes in the addressed memory location.

In this context:

The table summarizes the relationship among the data types of the write data input, the data types of write enable input, the number of columns, and the width of each column.

DT DW DTWE NC WC in Bits
uint16 16 ufix4 4 4
uint32 32 ufix4 4 8
uint64 64 ufix4 4 16
uint32 32 uint8 8 4
uint64 64 uint8 8 8
int32 32 uint16 16 2

For example, if DT is uint16 and_WE_ is ufix4, then DW is equal to 16, NC is equal to 4, and WC is equal to 4 bits. If the input to din is 980, its binary representation is 0000001111010100. The column-wise representation of din is c4 = 0000, c3 =0011, c2 = 1101, and c1 =0100, where c1 is the first column.

The table summarizes the results of using the column-write method for different input combinations.

Value of we Binary Representation ofwe Columns Selected for Writing in RAM Data at Memory Location dout
Before Performing Write Operation After Performing Write Operation
3 0011 c2, c1 c4 = 0000c3 =0000 c2 =0000c1 =0000 c4 = 0000c3 =0000c2 =1101c1 =0100 212
4 0100 c3 c4 = 0000c3 =0000c2 =0000c1 =0000 c4 = 0000c3 =0011 c2 = 0000c1 =0000 768
6 0110 c3, c2 c4 = 0000c3 =0000c2 =0000c1 =0000 c4 = 0000c3 =0011c2 =1101c1 =0000 976
9 1001 c4, c1 c4 = 0000c3 =0000c2 =0000c1 =0000 c4 = 0000c3 =0000c2 =0000c1 =0100 4
9 1001 c4, c1 c4 = 1111c3 =1111c2 =1111c1 =1111 c4 = 0000c3 =1111c2 =1111c1 =0100 4084

Limitations

Extended Capabilities

expand all

HDL Architecture

The block has a MATLABSystem architecture which indicates that the block implementation uses the hdl.RAM System object™.

HDL Block Properties

General
ConstrainedOutputPipeline Number of registers to place at the outputs by moving existing delays within your design. Distributed pipelining does not redistribute these registers. The default is0. For more details, see ConstrainedOutputPipeline.
InputPipeline Number of input pipeline stages to insert in the generated code. Distributed pipelining and constrained output pipelining can move these registers. The default is0. For more details, see InputPipeline.
OutputPipeline Number of output pipeline stages to insert in the generated code. Distributed pipelining and constrained output pipelining can move these registers. The default is0. For more details, see OutputPipeline.
RAMDirective Specify whether to map RAM blocks in your design to the RAM blocks on the target FPGA. For UltraRAM mapping,Initial output of RAM must be set to 0. For more details, see RAMDirective.

Complex Data Support

This block supports code generation for complex signals.

Restrictions

The block does not support:

Version History

Introduced in R2017b

expand all

You can use Dual Port RAM System block inside a data rate feedback loop and use clock-rate pipelining optimization. This model design is helpful for applications that require programmable or tunable lookup tables without having to regenerate bitstreams.

Use the new parameter Model RAM with one cycle of delay to model delay in your simulation. Model RAM with one cycle of delay is enabled by default and is disabled when Use asynchronous read feature in target hardware is enabled.

These parameters are renamed:

Previous Name Current Name
Specify the type of RAM Type of RAM
Enable asynchronous reads Use asynchronous read feature in target hardware
Specify the output data for a write operation Behavior for write output
Specify the RAM initial value Initial output of RAM

In this block, you can use the column-write method to selectively modify specific parts of the memory without altering the remaining parts at a specified memory address.

In this block, you can initialize RAM banks with unique initial values.

The block now supports HDL code generation for input data specified as an array of buses.

The block now supports HDL code generation with input data of typeHalf orBoolean.

See Also

Objects

Blocks

Topics