Main Content

Simple Dual Port RAM System

R2026b

Simple dual-port RAM that supports simultaneous read and write operations

  • Simple Dual Port RAM System block

Libraries:
HDL Coder / HDL RAMs

Description

The Simple Dual Port RAM System block models a simple dual-port RAM that supports simultaneous read and write operations. The block provides one output port for read data. To configure this block, open the block dialog box and set the Type of RAM block parameter to Simple dual port. The block accepts real or complex data.

Use this block to:

Note

During a write operation, if a read operation occurs simultaneously at the same address, old data appears at the read output port.

Limitations

  • When you build the FPGA bitstream, global reset logic does not reset RAM contents. To reset RAM contents, implement reset logic.

  • RAM address inputs must be unsigned and must be between 2 and 31 bits long.

  • The write enable input does not support signed data types with non-zero fraction lengths.

  • The word length of the write data input must be a multiple of the word length of the write enable input.

  • HDL code generation is not supported when Simple Dual Port RAM System blocks are in Resettable subsystems.

  • You can generate HDL code for Simple Dual Port RAM System blocks that are in resettable subsystems.

  • If the RAMArchitecture model configuration parameter is set to WithoutClockEnable, you cannot generate HDL code for Simple Dual Port RAM System blocks in enabled or triggered subsystems.

Ports

Input

expand all

Data to write, specified as a scalar or a vector. The block writes the value at port din to the memory location specified by wr_addr when the write enable signal at port we is true.

Bus Support:

Supports non-virtual buses and arrays of buses.

The block does not support:

  • Nested bus at the data port.

  • Non-zero values at the Initial output of RAM when you use a non-virtual bus input to the data port.

Data Types: single | double | half | int8 | int16 | uint8 | uint16 | Boolean | fixed point
Complex Number Support: Yes

Address to write, specified as an unsigned scalar or vector. The block uses this address to write to RAM when the signal at port we is true. The address must be unsigned and must be between 2 and 31 bits long.

Data Types: uint8 | uint16 | fixed point

Write enable control, specified as a scalar or a vector. When the signal at port we is true, the block writes the value at port din to the memory location specified by wr_addr. When the signal at port we is false, the block reads the value from the memory location specified by rd_addr port.

Note

To use the column-write method, specify the data type of we as an integer or fixed-point type.

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

Address to read, specified as an unsigned scalar or vector. The block uses this address to read from the RAM. The address must be unsigned and must be between 2 and 31 bits long.

Dependencies

To enable this port, set the Type of RAM parameter to Simple dual port or Dual port.

Data Types: uint8 | uint16 | fixed point

Output

expand all

Read output data, returned as a scalar or a vector. The block outputs the data stored at the memory location specified by the rd_addr input port. If a read and write occur simultaneously to the same address, the block outputs the old data.

Data Types: single | double | half | int8 | int16 | uint8 | uint16 | Boolean | fixed point
Complex Number Support: Yes

Parameters

expand all

Main

Specify the RAM configuration. HDL Coder™ configures the input and output ports based on the RAM type you select.

  • Single port — Create a single-port RAM with write data, address, and write enable data as inputs and read data as the output.

  • Simple dual port — Create a simple dual-port RAM with write data, write address, write enable, and read address as inputs, and data from the read address as the output.

  • Dual port — Create a dual-port RAM with write data, write address, write enable, and read address as inputs, and data from the read address and write address as the outputs.

  • True dual port — Create a true dual-port RAM with write data a and b, write and read addresses for a and b, and write enable a and b as inputs and data from write addresses a and b as the outputs.

  • Simple tri port — Create a simple tri port RAM with write data, write address, write enable, and read addresses a and b as inputs and data from read addresses a and b as the outputs.

Programmatic Use

Block Parameter: RAMType
Type: character vector, string
Values: Single port | Simple dual port | Dual port | True dual port | Simple tri port
Default: Simple 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'

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

  • A scalar value.

  • A vector with a one-to-one mapping between the initial value and the RAM words.

  • An n-by-m matrix with a one-to-one mapping between the initial values and the RAM words in the RAM banks, where n represents the number of RAM banks and m represents the number of address locations in the RAM block, or vice-versa.

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

  • When you select this parameter, the RAM delays the input data by one cycle before the output can read it. Use this option to ensure the block is cycle-accurate with the generated HDL code.

  • When you clear this parameter, the RAM reads and outputs the input data immediately, but adds one cycle of latency during HDL code generation. Use this option to leverage clock-rate pipelining when you specify an oversampling value or work with multirate models.

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

  • When you set this parameter to serial, the code generator infers parallel banks of RAM from vector inputs to RAM System block.

  • When you set this parameter to parallel:

    • The code generator does not scale up RAM consumption with the size of the vector input when you generate HDL Code. Instead, it applies each operation of the input signals one at a time, starting with the first index. Enabling serial access allows you to leverage multicycle RAM access at a faster clock rate while modeling with a vector input at the data rate.

    • If the RAM System block exists in a clock-rate pipelining region, the serialization uses a clock-rate implementation instead of local multirate implementation.

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

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2017b

expand all