Internal Memory (RAM and ROM) User Guide
Internal Memory (RAM and ROM) User Guide
Feedback Subscribe
2013 Altera Corporation. All rights reserved. ALTERA, ARRIA, CYCLONE, HARDCOPY, MAX, MEGACORE, NIOS, QUARTUS and STRATIX words and logos
are trademarks of Altera Corporation and registered in the U.S. Patent and Trademark Office and in other countries. All other words and logos identified as
trademarks or service marks are the property of their respective holders as described at www.altera.com/common/legal.html. Altera warrants performance of its
semiconductor products to current specifications in accordance with Altera's standard warranty, but reserves the right to make changes to any products and
services at any time without notice. Altera assumes no responsibility or liability arising out of the application or use of any information, product, or service
described herein except as expressly agreed to in writing by Altera. Altera customers are advised to obtain the latest version of device specifications before relying
on any published information and before placing orders for products or services.
May 2013
Altera Corporation
ISO
9001:2008
Registered
This user guide describes the megafunctions that implement the following memory
modes:
RAM:1-PortSingle-port RAM
RAM:2-PortDual-port RAM
ROM:1-PortSingle-port ROM
ROM:2-PortDual-port ROM
Features
The internal memory blocks provide the following features:
May 2013
Byte Enable
Asynchronous Clear
Read Enable
Read-During-Write
Altera Corporation
12
Device Support
Altera internal memory blocks are available for Arria, Cyclone, HardCopy, MAX,
and Stratix device series. However, ROM memory blocks are not available for MAX
device series.
2. Parameter Settings
This section describes the parameter settings for the memory modes that you can
configure through the parameter editors. You can find the parameter editors under
the Memory Compiler category when you launch the MegaWizard Plug-In Manager.
1
Altera recommends that you use the parameter editor to configure and build your
RAM and ROM memory blocks to ensure that the combination of your selected
options are valid.
Table 21 lists the parameter settings for the RAM:1-Port.
Legal Values
Default
value
Description
256
Auto
Single clock
What clocking method would you like to
use?
or
Dual Clock: use
separate input and
output clocks
May 2013
Altera Corporation
22
Description
On/Off
On
On/Off
Off
On/Off
Off
On/Off
Off
Option
Legal Values
q output port
More Options
Create an
addressstall_a
input port.
On/Off
Off
On/Off
Off
MLAB: 5 or 10
Other memory block
types: 8 or 9
M10K and M20K: 8,
9, or 10
On/Off
MLAB: 5
Other
memory
block types:
8
Off
More Options
q port
On/Off
Off
23
Legal Values
On/Off
Default
value
Off
Description
Specifies whether to create a read
enable signal.
For more information, refer to Read
Enable on page 315.
New data
On/Off
On
or
Yes, use this file for
the memory content
data
No, leave it
blank
May 2013
Altera Corporation
On/Off
Off
None
24
Legal Values
Default
values
Description
With one
read port
and one
write port
As a number of bits
As a
number of
words
256
On/Off
Off
or
With two read /write
ports
As a number of words
or
or
Use Stratix M512
emulation logic cell
style
Auto
Use
default
logic cell
style
25
Legal Values
Default
values
Auto
Description
Specifies the maximum block
depth in words. This option is
enabled only when you set the
memory block type to Auto.
For more information refer to
Maximum Block Depth
Configuration on page 39.
Single clock
Single clock
Single
clock
May 2013
Altera Corporation
26
Legal Values
Default
values
Off
Description
Off
Off
Off
27
Legal Values
Default
values
Description
On/Off
On
On
More Options
May 2013
Altera Corporation
data port
wraddress port
wren port
raddress port
q_b port
data_a port
data_b port
wraddress_a
port
wraddress_b
port
wren_a port
wren_b port
q_a port
q_b port
On/Off
28
Legal Values
On/Off
Default
values
Off
Description
Specifies whether to turn on the
option to create one clock enable
signal for each clock signal.
For more information, refer to
Clocking Modes and Clock
Enable on page 310.
More Options
Use clock
enable for port A
input registers
Use clock
enable for port B
input registers
Use clock
enable for port A
output registers
Use clock
enable for port B
output register
On/Off
Off
29
Legal Values
Default
values
Description
More Options
Create an
wr_addressstall
input port.
Create an
rd_addressstall
input port.
On/Off
Off
Create an
addressstall_a
input port.
Create an
addressstall_b
input port.
On/Off
Off
On/Off
Off
More Options
rdaddress port
q_b port
May 2013
Altera Corporation
q_a port
q_b port
210
Legal Values
Default
values
Description
I do not
care
I do not care
On/Off
Off
211
Legal Values
Default
values
Description
Parameter Settings: Output 2 (This tab is only available when you select two read/ write ports)
What should the q_a output be when reading
from a memory location being written to?
New data
On/Off
On
or
Yes, use this file for the
memory content data
No, leave
it blank
May 2013
Altera Corporation
212
Legal Values
Default
values
Description
256
Auto
Single clock
or
What clocking method would you like to use?
On/Off
On/Off
On
Off
213
Default
values
Description
On/Off
Off
On/Off
Off
Option
More Options
Create an
addressstall_a
input port.
On/Off
Off
On/Off
Off
address port
On/Off
Off
q port
On/Off
Off
More Options
On/Off
Off
May 2013
Altera Corporation
214
Legal Values
Default
values
On/Off
Off
None
Description
Specifies whether to allow
In-System Memory Content
Editor to capture and update
content independently of the
system clock
Specifies the ROM ID.
Legal Values
Default
values
Description
or
As a number
of words
256
As a number of bits
On/Off
Off
Auto
Auto
215
Legal Values
Default
values
Description
Single clock
or
or
Off
On/Off
On
q_a port
On/Off
On
q_b port
On/Off
On
On/Off
Off
More Options
May 2013
Altera Corporation
216
Default
values
Description
On/Off
Off
On/Off
Off
Option
More Options
Create an
addressstall_a input
port.
Create an
addressstall_b
input port.
On/Off
Off
On/Off
Off
q_a port
On/Off
Off
q_b port
On/Off
Off
More Options
PORT_A
The initial content file should conform to which
ports dimensions?
or
PORT_B
PORT_A
3. Functional Description
This section describes the features and functionality of the internal memory blocks
and the ports of the ALTSYNCRAM and ALTDPRAM megafunctions.
Single-port RAM
In a single-port RAM, the read and write operations share the same address at port A,
and the data is read from output port A.
Figure 31 shows a block diagram of a typical single-port RAM.
Figure 31. Single-port RAM
data[]
address[]
wren
byteena[]
addressstall
inclock
q[]
outclock
clockena
rden
aclr
May 2013
Altera Corporation
32
data[]
wraddress[]
rdaddress[]
rden
wren
byteena[]
wr_addressstall
wrclock
wrclocken
q[]
rd_addressstall
rdclock
rdclocken
ecc_status[]
aclr
data_a[]
address_a[]
wren_a
byteena_a[]
addressstall_a
clock_a
rden_a
data_b[]
address_b[]
wren_b
byteena_b[]
addressstall_b
clock_b
rden_b
aclr_a
aclr_b
q_a[]
q_b[]
33
Single-port ROM
In single-port ROM, only one address port is available for read operation.
Figure 34 shows the block diagram of a single-port ROM.
Figure 34. Single-port ROM
address[]
addressstall_a
inclock
inclocken
outclock
outclocken
q[]
outaclr
Dual-port ROM
The dual-port ROM has almost similar functional ports as single-port ROM. The
difference is dual-port ROM has an additional address port for read operation.
Figure 34 shows the block diagram of a dual-port ROM.
Figure 35. Dual-port ROM
address_a[]
outclock
address_b[]
outclocken
addressstall_a
addressstall_b
q_a[]
inclock
q_b[]
aclr_b
inclocken
aclr_a
May 2013
Altera Corporation
34
Select the type of memory blocks available based on your target device. Refer to
Table 31 on page 35. To select the appropriate memory block type for your
device, obtain more information about the features of your selected internal
memory block in your target device, such as the maximum performance,
supported configurations (depth width), byte enable, power-up condition, and
the write and read operation triggering.
Use logic cells. As compared to internal memory resources, using logic cells to
create memory reduces the design performance and utilizes more area. This
implementation is normally used when you have used up all the internal memory
resources. When logic cells are used, the parameter editor provides you with the
following two types of logic cell implementations:
Default logic cell stylethe write operation triggers (internally) on the rising
edge of the write clock and have continuous read. This implementation uses
less logic cells and is faster, but it is not fully compatible with the Stratix M512
emulation style.
Select the Auto option, which allows the software to automatically select the
appropriate internal memory resource. When you set the memory block type to
Auto, the compiler favors larger block types that can support the memory capacity
you require in a single internal memory block. This setting gives the best
performance and requires no logic elements (LEs) for glue logic. When you create
the memory with specific internal memory blocks, such as M9K, the compiler is
still able to emulate wider and deeper memories than the block type supported
natively. The compiler spans multiple internal memory blocks (only of the same
type) with glue logic added in the LEs as needed.
1
35
Table 31 lists the options available for you to implement your memory blocks in
various device families.
Table 31. Internal Memory Blocks in Altera Devices
Memory Block Types
M512 (1)
(512 bits)
M4K
(4 Kbits)
M-RAM (2)
(512 Kbits)
M9K
(9 Kbits)
M144K
(144 Kbits)
M10K
(10 Kbits)
M20K
(20 Kbits)
Logic
Cell
(LC)
Arria GX
Arria II GX
Arria II GZ
Arria V
Cyclone, Cyclone II
Device Family
Cyclone V
HardCopy II
HardCopy III,
HardCopy IV
Stratix V
To identify the type of memory block that the software selects to create your memory,
refer to the fitter report after compilation.
f For more information about internal memory blocks and the specifications, refer to
the memory related chapters in your target device handbook.
May 2013
Altera Corporation
36
Write Operation
(1)
Read Operation
M10K
M20K
M144K
M9K
M-RAM
(2)
M4K
M512
It is important that you understand the write operation triggering to avoid potential
write contentions that can result in unknown data storage at that location.
37
Figure 36 and Figure 37 show the valid write operation that triggers at the rising
and falling clock edge, respectively.
Figure 36. Valid Write Operation that Triggers at Rising
Clock Edges
clock_a
clock_a
address_a
01
address_a
01
wren_a
wren_a
data_a
data_a
06
05
twc
06
05
Valid Write
twc
clock_b
clock_b
address_b
address_b
01
01
wren_b
wren_b
data_b
02
03
04
05
data_b
02
03
04
05
Figure 36 assumes that twc is the maximum write cycle time interval. Write operation
of data 03 through port B does not meet the criteria and causes write contention with
the write operation at port A, which result in unknown data at address 01. The write
operation at the next rising edge is valid because it meets the criteria and data 04
replaces the unknown data.
Figure 37 assumes that twc is the maximum write cycle time interval. Write operation
of data 04 through port B does not meet the criteria and therefore causes write
contention with the write operation at port A that result in unknown data at address
01. The next data (05) is latched at the next rising clock edge that meets the criteria and
is written into the memory block at the falling clock edge.
1
Data and addresses are latched at the rising edge of the write clock regardless of the
different write operation triggering.
May 2013
Altera Corporation
38
If your port width configuration (either the depth or the width) is more than the
amount an internal memory block can support, additional memory blocks (of the
same type) are used. For example, if you configure your M9K as 512 36, which
exceeds the supported port width of 512 18, two M9Ks are used to implement your
RAM.
In addition to the supported configuration provided, you can set the memory depth
to a non-power of two, but the actual memory depth allocated can vary. The variation
depends on the type of resource implemented.
If the memory is implemented in dedicated memory blocks, setting a non-power of
two for the memory depth reflects the actual memory depth. If the memory is
implemented in logic cells (and not using Stratix M512 emulation logic cell style that
can be set through the parameter editor), setting a non-power of two for the memory
depth does not reflect the actual memory depth. In this case, you write to or read from
up to 2 address_width memory locations even though the memory depth you set is less
than 2 address_width . For example, if you set the memory depth to 3, and the RAM is
implemented using logic cells, your actual memory depth is 4.
When you implement your memory using dedicated memory blocks, you can check
the actual memory depth by referring to the fitter report.
MLABs do not have native support for mixed-width operation, thus the
option to select MLABs is disabled in the parameter editor. However, the
Quartus II software can implement mixed-width memories in MLABs by
using more than one MLAB. Therefore, if you select AUTO for your
memory block type, it is possible to implement mixed-width port memory
using multiple MLABs.
f For more information about width ratio that supports mixed-width port,
refer to your relevant device handbook.
Memory depth of 1 word is not supported in simple dual-port and true dual-port
RAMs with mixed-width port. The parameter editor prompts an error message when
the memory depth is less than 2 words. For example, if the width for port A is 4 bits
and the width for port B is 8 bits, the smallest depth supported by the RAM is 4
words. This configuration results in memory size of 16 bits (4 4) and can be
represented by memory depth of 2 words for port B. If you set the memory depth to 2
words that results in memory size of 8 bits (2 4), it can only be represented by
memory depth of 1 word for port B, and therefore the width of the port is not
supported.
39
ALUT Usage
M9Ks
8K 1 (default setting)
51.49
36
4K 2
20.28 (39%)
38
36
2K 4
10.80 (21%)
44
36
1K 9
6.08 (12%)
125
32
512 18
4.51 (9%)
212
32
256 36
6.36 (12%)
467
32
When the RAM is sliced shallower, the dynamic power usage decreases. However, for
a RAM block with a depth of 256, the power used by the extra LEs starts to outweigh
the power gain achieved by shallower slices.
You can also use this option to reduce the total number of memory blocks used (but at
the expense of LEs). From Table 33, the 8K 36 RAM uses 36 M9K RAM blocks with
a default slicing of 8K 1. By setting the maximum block depth to 1K, the 8K 36
RAM can fit into 32 M9K blocks.
The maximum block depth must be in a power of two, and the valid values vary
among different dedicated memory blocks.
May 2013
Altera Corporation
310
Table 34 lists the valid range of maximum block depth for various internal memory
blocks.
Table 34. Valid Range of Maximum Block Depth for Various internal Memory Blocks
internal Memory Blocks
Valid Range
M10K
2568K
M20K
51216K
M144K
2K16K
M9K
2568K
MLAB
3264
(1)
(2)
M512
32512
M4K
1284K
M-RAM
4K64K
The parameter editor prompts an error message if you enter an invalid value for the
maximum block depth. Altera recommends that you set the value to Auto if you are
not sure of the appropriate maximum block depth to set or the setting is not important
for your design. This setting enables the compiler to select the maximum block depth
with the appropriate port width configuration for the type of internal memory block
of your memory.
True Dual-port
RAM
Single-port
ROM
Dual-port
ROM
Read/Write
Input/Output
Independent
Single clock
Asynchronous clock mode is only supported in MAX series of devices, and not
supported in Stratix and newer devices. However, Stratix III and newer devices
support asynchronous read memory for simple dual-port RAM mode if you choose
MLAB memory block with unregistered rdaddress port.
The clock enable signals are not supported for write address, byte enable, and data
input registers on Arria V, Cyclone V, and Stratix V MLAB blocks.
311
May 2013
You can create independent clock enable for different input and output registers to
control the shut down of a particular register for power saving purposes. From the
parameter editor, click More Options (beside the clock enable option) to set the
available independent clock enable that you prefer.
Altera Corporation
312
a0
a1
a2
a3
a4
a5
a6
rden
addressstall
latched address
(inside memory)
an
q (synch) doutn-1
q (asynch)
a1
a0
dout0
doutn
dout4
dout1
dout0
doutn
a5
a4
dout4
dout1
dout5
a0
a1
a2
a3
a4
a5
a6
00
01
02
03
04
05
06
data
wren
addressstall
latched address
(inside memory)
contents at a0
contents at a1
a1
a0
XX
01
02
XX
contents at a3
XX
contents at a5
a4
a5
00
XX
contents at a2
contents at a4
an
03
04
XX
XX
05
313
Byte Enable
All internal memory blocks that are implemented as RAMs support byte enables that
mask the input data so that only specific bytes, nibbles, or bits of data are written. The
unwritten bytes or bits retain the previously written value.
The least significant bit (LSB) of the byte-enable port corresponds to the least
significant byte of the data bus. For example, if you use a RAM block in x18 mode and
the byte-enable port is 01, data [8..0] is enabled and data [17..9] is disabled.
Similarly, if the byte-enable port is 11, both data bytes are enabled.
You can specifically define and set the size of a byte for the byte-enable port. The valid
values are 5, 8, 9, and 10, depending on the type of internal memory blocks. The
values of 5 and 10 are only supported by MLAB.
To create a byte-enable port, the width of the data input port must be a multiple of the
size of a byte for the byte-enable port. For example, if you use an MLAB memory
block, the byte enable is only supported if your data bits are multiples of 5, 8, 9 or 10,
that is 10, 15, 16, 18, 20, 24, 25, 27, 30, and so on. If the width of the data input port is
10, you can only define the size of a byte as 5. In this case, you get a 2-bit byte-enable
port, each bit controls 5 bits of data input written. If the width of the data input port is
20, then you can define the size of a byte as either 5 or 10. If you define 5 bits of input
data as a byte, you get a 4-bit byte-enable port, each bit controls 5 bits of data input
written. If you define 10 bits of input data as a byte, you get a 2-bit byte-enable port,
each bit controls 10 bits of data input written.
Figure 310 shows the results of the byte enable on the data that is written into the
memory, and the data that is read from the memory.
Figure 310. Byte Enable Functional Waveform
inclock
wren
address
data
byteena
contents at a0
contents at a1
a0
an
a1
a2
a0
a1
ABCD
XXXX
10
XX
a2
XXXX
01
11
FFFF
XX
ABFF
FFFF
FFCD
FFFF
contents at a2
ABCD
doutn
ABXX
XXCD
ABCD
ABFF
FFCD
ABCD
doutn
ABFF
FFCD
ABCD
ABFF
FFCD
ABCD
When a byte-enable bit is deasserted during a write cycle, the corresponding masked
byte of the q output can appear as a Don't Care value or the current data at that
location. This selection is only available if you set the read-during-write output
behavior to New Data.
f For more information about the masked byte and the q output, refer to Read-DuringWrite on page 316.
May 2013
Altera Corporation
314
Asynchronous Clear
The internal memory blocks in the Arria II GX, Arria II GZ, Cyclone III, HardCopy III,
HardCopy IV, Stratix III, Stratix IV, Stratix V, and newer device families support the
asynchronous clear feature used on the output latches and output registers. Therefore,
if your RAM does not use output registers, clear the RAM outputs using the output
latch asynchronous clear. The asynchronous clear feature allows you to clear the
outputs even if the q output port is not registered. However, this feature is not
supported in MLAB memory blocks.
The outputs stay cleared until the next clock. However, in Arria V, Cyclone V, and
Stratix V devices, the outputs stay cleared until the next read.
1
You cannot use the asynchronous clear port to clear the contents of the internal
memory. Use the asynchronous clear port to clear the contents of the input and output
register stages only.
Table 36 lists the asynchronous clear effects on the input ports for various devices in
various memory settings.
Table 36. Asynchronous Clear Effects on the Input Ports for Various Devices in Various Memory Settings
Memory Mode
(1)
Single dual-port
RAM and True
dual-port RAM
Single-port ROM
Dual-port ROM
During a read operation, clearing the input read address asynchronously corrupts the
memory contents. The same effect applies to a write operation if the write address is
cleared.
315
Beginning from Arria V, Cyclone V, and Stratix V devices onwards, an output clock
signal is needed to successfully recover the output latch from an asynchronous clear
signal. This implies that in a single clock mode true dual-port RAM, setting clock
enabled on the registered output may affect the recovery of the unregistered output
because they share the same output clock signal. To avoid this, provide an output
clock signal (with clock enabled) to the output latch to deassert an asynchronous clear
signal from the output latch.
Read Enable
Support for the read enable feature depends on the target device, memory block type,
and the memory mode you select. Table 37 lists the memory configurations for
various device families that support the read enable feature.
Table 37. Read-Enable Support in Various Device Families
Memory
Modes
M9K, M144K,
M10K, M20K
MLAB
M512, M4K
M-RAM
Single-port
RAM
Tri-port RAM
Single-port
ROM
Dual-port
ROM
If you create the read-enable port and perform a write operation (with the read enable
port deasserted), the data output port retains the previous values that are held during
the most recent active read enable. If you activate the read enable during a write
operation, or if you do not create a read-enable signal, the output port shows the new
data being written, the old data at that address, or a Don't Care value when readduring-write occurs at the same address location.
f For more information about the read-during-write output behavior, refer to the
Read-During-Write on page 316.
May 2013
Altera Corporation
316
Read-During-Write
The read-during-write (RDW) occurs when a read and a write target the same
memory location at the same time. The RDW operates in the following two ways:
Same-port
Mixed-port
Same-Port RDW
The same-port RDW occurs when the input and output of the same port access the
same address location with the same clock.
The same-port RDW has the following output choices:
New DataNew data is available on the rising edge of the same clock cycle on
which it was written.
Old DataThe RAM outputs reflect the old data at that address before the write
operation proceeds.
1
Old Data is not supported for M10K and M20K memory blocks in
single-port RAM and true dual-port RAM.
Don't CareThe RAM outputs don't care values for the RDW operation.
Mixed-Port RDW
The mixed-port RDW occurs when one port reads and another port writes to the same
address location with the same clock.
The mixed-port RDW has the following output choices:
Old DataThe RAM outputs reflect the old data at that address before the write
operation proceeds.
1
Don't CareThe RAM outputs don't care or unknown values for RDW
operation without analyzing the timing path.
1
For LUTRAM, this option functions differently whereby when you enable
this option, the RAM outputs dont care or unknown values for RDW
operation but analyzes the timing path to prevent metastability. Therefore,
if you want the RAM to output dont care values without analyzing the
timing path, you have to turn on the Do not analyze the timing between
write and read operation. Metastability issues are prevented by never
writing and reading at the same address at the same time option.
317
Single-port RAM
(1)
(2)
Mixed-port RDW
(3)
M-RAM
Old Data
Dont Care
No parameter editor
(5)
Dont Care
MLAB
Dont Care
M9K
Dont Care
New Data (6)
M144K
Old Data
Old Data
NA
Dont Care
Old Data
New Data
Dont Care
(6)
Old Data
Old Data
New Data (6)
M20K
Dont Care
No parameter editor (5)
Dont Care
Dont Care
M10K
LCs
(4)
NA
Old Data
M4K
Mixed-port RDW
Old Data
Dont Care
Dont Care
NA
May 2013
The RDW old data mode is not supported when the Error Correction Code (ECC) is
engaged.
If you are not concerned about the output when RDW occurs and would like to
improve performance, you can select Don't Care. Selecting Don't Care increases the
flexibility in the type of memory block being used, provided you do not assign block
type when you instantiate the memory block.
Altera Corporation
318
Power-Up Conditions
M512
Outputs cleared
M4K
Outputs cleared
M-RAM
MLAB
M9K
Outputs cleared
M144K
Outputs cleared
M10K
Outputs cleared
M20K
Outputs cleared
The outputs of M512, M4K, M9K, M144K, M10K, and M20K blocks always power-up
to zero, regardless of whether the output registers are used or bypassed. Even if a
memory initialization file is used to pre-load the contents of the memory block, the
output is still cleared.
MLAB and M-RAM blocks power-up to zero only if output registers are used. If
output registers are not used, MLAB blocks power-up to read the memory contents
while M-RAM blocks power-up to an unknown state.
1
When the memory block type is set to Auto in the parameter editor, the compiler is
free to choose any memory block type, in which the power-up value depends on the
chosen memory block type. To identify the type of memory block the software selects
to implement your memory, refer to the fitter report after compilation.
All memory blocks (excluding M-RAM) support memory initialization via the
Memory Initialization File (.mif) or Hexadecimal (Intel-format) file (.hex). You can
include the files using the parameter editor when you configure and build your RAM.
For RAM, besides using the .mif file or the .hex file, you can initialize the memory to
zero or X. To initialize the memory to zero, select No, leave it blank. To initialize the
content to X, turn on Initialize memory content data to XX..X on power-up in
simulation. Turning on this option does not change the power-up behavior of the
RAM but initializes the content to X. For example, if your target memory block is
M4K, the output is cleared during power-up (based on Table 39 on page 318). The
content that is initialized to X is shown only when you perform the read operation.
The Quartus II software searches for the altsyncram init_file in the project directory,
the project db directory, user libraries, and the current source file location.
319
The Mixed-port RDW for old data mode is not supported when the ECC feature is
engaged. The result for RDW is Don't Care.
The M144K ECC status is communicated via a three-bit status flag eccstatus[2..0].
while the M20K ECC status is communicated with a two-bit ECC status flag
eccstatus[1..0] where eccstatus[1] corresponds to the signal e (error) and
eccstatus[0] corresponds to the signal ue (uncorrectable error).
Table 310 lists the truth table for the ECC status flags.
Table 310. Truth Table for ECC Status Flags
M144K
M20K
eccstatus[1..0]
Status
eccstatus[2..0]
eccstatus[1]
e
eccstatus[0]
ue
No error
000
011
101
001
Illegal
010
100
11X
May 2013
Altera Corporation
320
Type
Required
Description
Data input to port A of the memory.
The data_a port is required if the operation_mode is set to any
of the following values:
data_a
address_a
Input
Input
Optional
Yes
SINGLE_PORT
DUAL_PORT
BIDIR_DUAL_PORT
wren_a
Input
Optional
SINGLE_PORT
DUAL_PORT
BIDIR_DUAL_PORT
Input
Optional
byteena_a
Input
Optional
For more information about byte enable feature and the criterion
that you must follow to use the feature correctly, refer to Byte
Enable on page 313.
addressstall_a
Input
Optional
321
Type
Required
Description
Data output from port A of the memory.
The q_a port is required if the operation_mode parameter is set
to any of the following values:
Output
q_a
Yes
SINGLE_PORT
BIDIR_DUAL_PORT
ROM
The width of q_a port must be equal to the width of data_a port.
Data input to port B of the memory.
Input
data_b
Optional
address_b
Input
Optional
DUAL_PORT
BIDIR_DUAL_PORT
wren_b
Yes
Input
rden_b
Optional
byteena_b
Input
Optional
For more information about byte enable feature and the criterion
that you must follow to use the feature correctly, refer to Byte
Enable on page 313.
addressstall_b
Input
Optional
Output
q_b
Yes
DUAL_PORT
BIDIR_DUAL_PORT
The width of q_b port must be equal to the width of data_b port.
May 2013
Altera Corporation
322
Type
Required
Description
The following table describes which of your memory clock must
be connected to the clock0 port, and port synchronization in
different clocking modes:
Clocking
Mode
clock0
Input
Descriptions
Single clock
Read/Write
Input Output
Independent
clock
Yes
323
Type
Required
Description
The following table describes which of your memory clock must
be connected to the clock1 port, and port synchronization in
different clocking modes:
Clocking
Mode
Input
clock1
Descriptions
Single clock
Read/Write
Input Output
Independent
clock
Optional
clocken0
Input
Optional
clocken1
Input
Optional
clocken2
Input
Optional
clocken3
Input
Optional
May 2013
Altera Corporation
324
Type
Required
Description
Asynchronously clear the registered input and output ports. The
aclr0 port affects the registered ports that are clocked by
clock0 clock. while the aclr1 port affects the registered ports
that are clocked by clock1 clock.
aclr0
Input
aclr1
Optional
Output
eccstatus
Optional
Table 312 lists the input and output ports for the ALTDPRAM megafunction.
Table 312. ALTDPRAM Megafunction Input and Output Ports Description
Port Name
Type
Required
Description
Data input to the memory.
data
Input
Yes
wraddress
Input
Yes
wren
Input
Yes
The data port is required and the width must be equal to the
width of the q port.
Write address input to the memory.
The wraddress port is required and must be equal to the width
of the raddress port.
Write enable input for wraddress port.
The wren port is required.
Read address input to the memory.
raddress
Input
Yes
325
Type
Required
Description
Read enable input for rdaddress port.
Input
rden
Optional
Input
byteena
Optional
Byte enable input to mask the data port so that only specific
bytes, nibbles, or bits of data are written. The byteena port is
not supported when use_eab parameter is set to OFF. It is
supported in Arria II GX, Stratix III, Cyclone III, and newer
devices with the ram_block_type parameter set to MLAB.
For more information about byte enable feature and the criterion
that you must follow to use the feature correctly, refer to Byte
Enable on page 313.
wraddressstall
Input
Optional
rdaddressstall
Input
Optional
Output
May 2013
Altera Corporation
Yes
326
Type
Required
Description
The following table describes which of your memory clock must
be connected to the inclock port, and port synchronization in
different clocking modes:
Clocking
Mode
inclock
Input
Yes
Descriptions
Single clock
Read/Write
Input/Output
outclock
inclocken
Input
Input
Single clock
Read/Write
Input/Output
Yes
Optional
Descriptions
327
Type
Required
Description
Input
Optional
Input
aclr
Optional
May 2013
Altera Corporation
328
4. Design Example
This section describes the design example provided with this user guide. You can
download design examples from the following locations:
ecc_encoder.v
ecc_decoder.v
true_dp_ram.v
top_dpram.v
true_dp_ram.vt
true_dp.do
May 2013
Altera Corporation
42
This design example describes how ECC features can be implemented with the RAM
for cases in which the ECC is not supported internally by the RAM. However, the
design examples might not represent the optimized design or implementation.
Option
Currently selected device family:
Value
Stratix III
How do you want to configure this module? Configure this module as an ECC encoder
3
8 bits
Not selected
Not selected
43
Option
Currently selected device family:
Value
Stratix III
How do you want to configure this module? Configure this module as an ECC decoder
3
13 bits
Not selected
Not selected
2a
Parameter Settings
(General)
Parameter Settings
(Widths/Blk Type)
May 2013
Altera Corporation
Option
Value
Megafunction
Stratix IV
Verilog HDL
true_dp_ram
Turned off
Stratix III
As a number of words
16
Not selected
13
M9K
Auto
44
Option
Value
Single clock
Not selected
Not selected
Not selected
Not selected
Parameter Settings
New Data
(Output 2)
Old Data
Parameter Settings
(Clks/Rd, Byte En)
Parameter Settings
(Regs/Clkens.Aclrs)
Parameter Settings
(Output 1)
Parameter Settings
(Mem Init)
EDA
Summary
Generate netlist
Turned off
Turned on
Turned off
Turned on
Turned off
Turned off
45
7. Select the true_dp.do file and click Open. The true_dp.do file is a script file that
automates all the necessary settings, compiles and simulates the design files, and
displays the simulation waveform.
8. Verify the result shown in the Waveform Viewer window.
You can rearrange signals, remove signals, add signals, and change the radix by
modifying the script in true_dp.do accordingly.
Simulation Results
The top-level block contains the input and output ports shown in Table 44.
Table 44. Top-level Input and Output Ports Representations
Ports Name
Ports Type
Descriptions
clock
Input
corrupt_dataa_bit0
Input
Input
Input
Output
Output
address_a
data_a
wren_a
rden_a
address_b
data_b
wren_b
rden_b
rdata1
err_corrected1
err_detected1
err_fatal1
rdata2
err_corrected2
err_detected2
err_fatal2
Notes to Table 44:
(1) For input ports, only data signal goes through the encoder; others bypass the encoder and go directly to the RAM
block. Because the encoder uses one pipeline, signals that bypass the encoder require additional pipelines before
going to the RAM. This has been implemented in the top level.
(2) The encoder and decoder each use one pipeline while the RAM uses two pipelines, making the total pipeline equal
to four. Therefore, read data is only shown at output ports four clock cycles after the read enable is initiated.
May 2013
Altera Corporation
46
Figure 42 shows the timing diagram of when the same-port read-during-write occurs
for each port A and port B of the RAM.
Figure 42. Same-Port Read-During-Write
47
At 2500 ps, same-port read-during-write occurs for each port A and port B. Because
the true dual-port RAM configured to port A is reading the new data and port B is
reading the old data when the same-port read-during-write occurs, the rdata1 port
shows the new data aa and the rdata2 port shows the old data 00 after four clock
cycles at 17500 ps. When the data is read again from the same address at the next
rising clock edge at 7500 ps, the rdata2 port shows the recent data bb at 22500 ps.
Figure 43 shows the timing diagram of when the mixed-port read-during-write
occurs.
Figure 43. Mixed-Port Read-During-Write
May 2013
Altera Corporation
48
Figure 44 shows the timing diagram of when the write contention occurs.
Figure 44. Write Contention
At 22500 ps, the write contention occurs when data dd and ee are written to address 0
simultaneously. Besides that, the same-port read-during-write also occurs for port A
and port B. The setting for port A and port B for same-port read-during-write takes
effect when the rdata1 port shows the new data dd and the rdata2 port shows the old
data aa after four clock cycles at 37500 ps. When the data is read again from the same
address at the next rising clock edge at 27500 ps, rdata1 and rdata2 ports show
unknown values at 42500 ps. Apart from that, the unknown data input to the decoder
also results in an unknown ECC status.
49
Figure 45 shows the timing diagram of the effect when an error is injected to twist
the LSB of the encoded data at port A by asserting corrupt_dataa_bit0.
Figure 45. Error Injection Asserting corrupt_dataa_bit0
At 32500 ps, same-port read-during-write occurs at port A while mixed-port readduring-write occurs at port B. The corrupt_dataa_bit0 is also asserted to corrupt the
LSB of encoded data at port A; therefore, the storing data has the LSB corrupted, in
which the intended data ff is corrupted, becomes fe, and stored at address 0. After
four clock cycles at 47500 ps, the rdata1 port shows the new data ff that has been
corrected by the decoder, and the ECC status signals, err_corrected1 and
err_detected1, are asserted. For rdata2 port, old data (which is unknown) is shown
and the ECC-status signal remains unknown.
1
The decoders correct the single-bit error of the data shown at rdata1 and rdata2 ports
only. The actual data stored at address 0 in the RAM remains corrupted, until new
data is written.
At 37500 ps, the same condition happens to port A and port B. The difference is port B
reads the corrupted old data fe from address 0. After four clock cycles at 52500 ps, the
rdata2 port shows the old data ff that has been corrected by the decoder and the ECC
status signals, err_corrected2 and err_detected2, are asserted to show the data has
been corrected.
May 2013
Altera Corporation
410
November 2012
January 2012
November 2011
Version
4.2
4.1
4.0
3.0
Changes
Updated Table 34 on page 310 to fix a typographical error.
Added a note to the Asynchronous Clear on page 314 to state that internal contents
cannot be cleared with the asynchronous clear signal.
Updated note in Clocking Modes and Clock Enable on page 310 to include Stratix V
devices.
Added a note to the Asynchronous Clear on page 314 to clarify that clear deassertion
on output latch is dependent on output clock.
March 2011
2.0
November 2009
1.0
Initial release