You are on page 1of 4

2018 2nd IEEE Advanced Information Management,Communicates,Electronic and Automation Control Conference(IMCEC 2018)

Design and Implementation of DDR4 SDRAM


Controller Based on FPGA
Jia Zheng, Kai Yan, Yue Zhang, Zengping Chen
School of Electronic Science and Engineering, National University of Defense Technology
Changsha, China
jia_zheng77@163.com

Abstract—The DDR4 SDRAM is the latest Double-Data-Rate


Fourth Generation Synchronous Dynamic Random Access II. DDR4 WORKING PRINCIPLE
Memory with the advantages of large capacity, high speed, low After the system is powered on or reseted, DDR4 SDRAM
power consumption and good stability. In order to solve the data needs to be initialized according to the given initialization flow.
cache problem of the ultra-high-speed sampling and processing DDR4 SDRAM provides 8 mode registers for users to use
system, this paper designs DDR4 SDRAM read-write controller more easily [2]. The user configures a specific value of the
module based on UltraScale DDR4_v2.2 IP core. This paper MRS command during the initialization process. These mode
mainly introduces the characteristics and working principle of registers are mainly used for initialization such as burst type,
DDR4, introduces the DDR4 read-write controller module in burst length, ODT resistance, ZQ calibration, CAS latency,
detail, and packages it as the FIFO interface and finally tests and
TDQS enable, DBI enable, CA parity and Write Leveling
gives the test results. System tests results verify that the module
meets the requirements of large-capacity data cache, and has the
enable [4]. When the initialization operation is completed, the
advantages of good stability and high portability. system enters the IDLE state, waiting for the read-write
controller access. The main operating commands is as follows:
Keywords—DDR4 SDRAM, UltraScale, DDR4_v2.2 IP core,
read-write controller A. Precharge Command (PRE)
The PRECHARGE command is used to close the row that
I. INTRODUCTION has been opened with the Bank. After the PRECHARGE
DDR4 SDRAM is the latest generation of Double-Data- command, it is necessary to wait a certain amount of time
Rate Synchronous Dynamic Random Access Memory. before the next row is activated. Once a bank has executed a
Compared to the previous generation, DDR3 SDRAM, its pre-charge command, the Bank is in IDLE state and the next
performance has greatly improved. When applied to FPGA command can be executed. This row must be activated before
system based on UltraScale architecture, DDR4 SDRAM data sending read and write commands to any ROW in the Bank.
transfer rate up to 2400Mb/s, increased by 30% compared to
DDR3.At the same time, its power consumption is very low, B. Activation Command (ACT)
the data voltage is only 1.2V, which is 20% less than that of The ACT command is used to open (or activate) a row of a
DDR3, but the memory capacity is greatly increased. DDR4 specified Bank. The BG0-BG1 in the X8 device is used to
has newly added the Bank Group data group design. Each select the Bank group, and the BA0- BA1 is used to select a
Bank Group has the characteristics of independent startup, specific Bank of the Bank group, and A0-A17 is the choice of
operation reading and writing, which makes it more efficient the specific row. The row remains active until the self- refresh
than DDR3. In addition, the functions of DBI (Bata Bus command arrives. In the same Bank, if you need to open
Inversion), CRC (Cyclic Redundancy Check) and CA parity another row, you need to close the already open row, that is,
are also added. These functions enhance the signal integrity of you need to send a self-refresh command.
DDR4 and improve the reliability of data transmission and
storage. In addition, DDR4 also inherits the function of DDR3. C. Refresh Command
It has three channel modes of x4, X8 and x16. It is compatible
with AXI interface protocol, supports ECC, data mask, and has Refresh command is used in different operations, and the
reset and ZQ calibration functions. command does not continue. Before entering the refresh
command, all the banks need to complete the PRECHARGE
This paper introduces the design and implementation of command [3]. After the refresh command is completed, all the
DDR4 SDRAM read and write controller based on UltraScale banks enter the IDLE state. The refresh addressing is generated
DDR4_v2.2 IP core, and finally completes the DDR4 SDRAM by the internal refresh controller and does not require external
read and write controller tests based on Airtex UltraScale series address information.
FPGA [1]. The test results show that the DDR4 SDRAM read-
write controller can meet the data rate requirements, and has D. Self-refresh Command
the advantages of good stability, simple interface and strong
DDR4 SDRAM, like DDR3 SDRAM, requires constant
portability.
self-refresh operations to maintain the effective storage of data
onto the storage unit. The self-refresh command has an

978-1-5386-1803-5/18/$31.00 ©2018 IEEE 421


Authorized licensed use limited to: Northrop Grumman Space Systems. Downloaded on June 11,2023 at 03:46:29 UTC from IEEE Xplore. Restrictions apply.
inherent operation cycle that operates on all rows in turn. The the input/output buffer, and ensure the instruction and address,
self-refresh command also does not require the external supply data synchronization and signal maintenance. The memory
of row address information on operation. When the other parts control module is located between the user interface module
of the system power down, the self-refresh command still and the physical layer module. The front end of the memory
maintains its function. control module provides a local interface for the user interface
module. The rear interface connects to the physical layer
E. Read/Write Command interface and handles all the interface requests for the module.
When DDR4's Bank executes the row activation command, Users can directly control the user interface module read and
the read / write command can be sent to the row to read / write. write operations to meet the user interface module timing and
When the read / write command is executed, it is possible to logic requirements can be.
choose whether an automatic PRECHARGE operation is sys_clk_p DDR4 IP CORE
allowed. When the command is read, the data transfer will be sys_clk_n
triggered after the column address is submitted to the DDR4 sys_rst Physical
interface again [5]. However, after the data is triggered, it takes Layer
a certain amount of drive time to reach the data I/O bus and ddr_cs_n
output it. app_en
app_rdy ddr_ui_clk_sync_rst
app_autoprecharge ddr_cke
ddr_ck_n
III. DESIGN OF DDR4 SDRAM READ WRITE CONTROLLER app_wdf_rdy ddr_act_n
User
Memory
The DDR4 SDRAM read-write controller of this paper is app_wdf_wren Interface Native Control MC/PHY IOB ddr_ui_clk
Interface
Module Interface ddr_ck_c
designed based on the UltraScale DDR4_v2.2 IP core. This ddr_reset_n
section first introduces the internal structure of the IP core, app_wdf_end ddr_ck_t
secondly introduces the overall structure of the design, and
finally introduces the principle of read-write controls state app_rd_data
machine. The structure of the DDR4 SDRAM IP core based on app_rd_data_valid
the UltraScale architecture is shown in Fig.1 [6]. app_rd_data_end
Init_calib_complete
app_hi_pri ddr_odt
The IP core consists of three parts: user interface module, ddr_parity
memory control module and physical layer interface module.
The back end of the physical interface module is directly Fig. 1. UltraScale Architecture-Based FPGAs DDR4 Memory Interface
Solution
connected to the peripheral circuit of the DDR4 hardware, and
the front end is connected to the memory control module. Its In the design, first consider the system structure as a whole.
main function is to capture the data sent by DDR4, generate the In order to facilitate the user, this article will be read-write
control instruction signals required by DDR4, and send all controller package in the form of FIFO. The overall structure
DDR4 control signals, address signals and data signals through shown in Fig.2.

read_fifo_rd_en

data fifo_out_data fifo_in_data data


valid valid
DDR4_read_write_c
write_fifo wr_prog_full read_fifo
ontrol valid
valid wr_prog_empty rd_prog_empty
fifo_rd_en rd_prog_full

DDR4 IP Core

Fig. 2. The overall structure of the read-write controller

As a whole, the user's method of using the read-write


A. Wait State
controller is similar to the FIFO. This saves more control signal
lines of the IP core, which is more convenient. At the beginning, DDR4 SDRAM needs to initialize the
To read and write controller module, read and write control configuration, so first need to wait for the initialization
process is divided into three state processes, respectively, the completion. If the initialization is not completed, or the
wait state, write state and read state. The conversion to these app_rdy signal is not raised, or the read and write condition is
three states is controlled by the signal line init_calib_complete not satisfied when writing FIFO and read FIFO, the read and
of the IP core along with the read/write FIFO empty flag write control logic will always be in wait state. Only when
signals line and the internal flag signals line. The specific conditions are satisfied, they begin to enter the next state.
schematic diagram of state switching is shown in Fig.3.

422
Authorized licensed use limited to: Northrop Grumman Space Systems. Downloaded on June 11,2023 at 03:46:29 UTC from IEEE Xplore. Restrictions apply.
B. Write Status is ready, and app_wdf_rdy is a ready signal for the user data
When the IP core is initialized and the FIFO fifo_prog_full interface. Only when the write address and write data are valid,
signal is pulled high, the read and write control logic enters the the data is written into the correct address. As shown in the
write state until the write FIFO fifo_prog_empty is pulled high following write timing diagram, the write address is valid only
to stop writing. During the writing process, DDR4 SDRAM when the app_rdy signal and app_en signal are both high.
cannot be full. For the IP core, when the IP core is given a When app_wdf_rdy and app_wdf_wren both go high, the write
write command and the app_rdy and app_wdf_rdy signals are data is valid. However, writing addresses and writing data does
both high, it indicates that the IP core is ready to write. The not require that it was valid at the same time, and can differ by
app_rdy signal is an indication that user interface of the IP core a few clock cycles.

!wr_fifo_prog_full && !rd_fifo_prog_full


&& cnt >= low_cnt

wr_fifo_prog_full &&!ddr_full

IDLE WRITE READ

wr_fifo_prog_empty ||
ddr_full

wr_fifo_prog_full || rd_fifo_prog_full
|| cnt <= low_cnt

Fig. 3. Read write state machine

When designing the write state in this paper, write address control logic enter the read state. When writing a state, the
and write data is controlled to be valid at the same time in amount of data required to be read out should be less than the
order to prevent the clock cycle of writing address and write amount of data written. The read state stops until the
data onto exceeding the valid value. That is, both app_rdy and fifo_prog_full signal of the FIFO is pulled up, or the FIFO is
app_wdf_rdy are simultaneously written with valid addresses read, or the remaining unread data onto memory is less than
and valid data. Other clock cycles pull down the address valid low_cnt.
signal app_en and the data valid signal app_wdf_wren.
For the IP core, when the IP core is given a read command
and the app_rdy signal is pulled high, it indicates that the IP
clk core is ready to read. When the read address is valid, the data
corresponding to the address in DDR4 will be read out after
app_cmd WRITE WRITE WRITE several cycles. When the read and write control logic are in the
app_addr Addr a Addr b Addr c
read state, and when the app_rdy signal is high, the effective
read address is written, and the address effective signal app_en
app_en is pulled down in other clock cycles.
app_rdy

app_wdf_rdy
clk

app_maks app_cmd WRITE WRITE

app_wdf_data W a0 W b0 W c0 app_addr Addr a Addr b

app_wdf_wren app_en

app_wdf_end
app_rdy

Fig. 4. Write operation timing diagram


app_rd_data R0 R1

C. Read State app_rd_data_valid

When the IP core is initialized and the capacity of writing app_rd_data_end


FIFO is in the process from fifo_prog_empty to fifo_prog_full,
and when the read FIFO is not yet full, the read and write Fig. 5. Read operation timing diagram

423
Authorized licensed use limited to: Northrop Grumman Space Systems. Downloaded on June 11,2023 at 03:46:29 UTC from IEEE Xplore. Restrictions apply.
IV. READING AND WRITING EFFICIENCY TEST AND efficiency is the read-write efficiency of the read-write control
ANALYSIS module.
Because the activation command and PRECHARGE In order to test the read-write controller module, the
command will be activated when the row address is refreshed memory capacity of DDR4 SDRAM used in this paper is 8GB
in BANK. When DDR4 SDRAM read and write data, there and the maximum communication speed is 2400MT/s. IP core
will be some time gaps. Therefore, reading and writing control user interface data width is 512 bits, and the interface clock
modules need to be read and write efficiency test. rate is 300MHz. The steady reading and writing efficiency of
First, in the actual test, an error checking module was added the final test results is 90%. According to the formula, the final
to the DDR4 read-write controller. This article gives the actual data rate can be calculated to be 8.64GB/s, which fully meets
signal waveform captured by the ILA, as shown in Fig. 6: the data rate requirements of the DDR4 SDRAM cache part in
the ultra-high speed acquisition and processing system.

V. CONCLUSIONS
This paper analyzes the DDR4 SDRAM operation principle,
and analyzes, designs and realizes the DDR4 read-write
controller logic based on the Virtex UltraScale DDR4_v2.2 IP
core. In order to make the module easier to use, the read-write
controller is packaged as a FIFO. Finally, this paper tested read
and write efficiency in a Virtex UltraScale series of FPGAs.
After testing, the controller has the advantages of stable work,
high efficiency, simple interface and good portability.

REFERENCES
[1] To Thoma, Niu Penglin; Wang, Juan, Su Changyi, Khoo Chong Lin,
Sharma, Ajay Kumar, Klokotov, Dmitry, Liu Wei, and Wang Yong,
Ultrascale FPGA DDR4 2400 Mbps system level design optimization
and validation, 2015.
[2] ZHANG Gang, JIA Jianchao, and ZHAO Long, “Design and realization
of DDR3 SDRAM Controller Based on FPGA ,” Electronic Sci. &Tech.,
vol. 27, issue 1, pp. 70-73, 2014.
[3] Tao Yue, “Digital Test System Design and Realization Based on
DDR3,” Applied Mechanics and Materials, vol. 543, issue 3082,pp.
Fig. 6. DDR4 read and write operation test diagram
1128-1131, 2014.
[4] Anonymous,JEDEC Solid State Technology Association; JEDEC
As you can see in Fig. 6, when reading and writing, the Announces Key Attributes of Upcoming DDR4 Standard. Electronics
error signal has been low, and the error is not caught. Business Journal, 2011.
Second, the data rate calculation formula for DDR4 read- [5] Pham.N.; DrepsD.; Mandrekar.R.; Na.N., “Driver design for DDR4
memory subsystems,” IEEE 19th Electrical Performance of Electronic
write controller is given. Packaging and Systems (EPEPS), pp. 297-300, 2010.
1 [6] SONG Ming, ZHAO Yingxiao, and LIN Qianqiang, “Design and
Data rate width u clk u efficiency u (1) Optimization of DDR3 SDRAM Controller Based on FPGA,” Electronic
2 Sci. & Tech., vol. 29, issue 11, pp. 47-50, 2016.
Where, width is the data bit width of the IP core user
interface, clk is the clock rate of the user interface, and

424
Authorized licensed use limited to: Northrop Grumman Space Systems. Downloaded on June 11,2023 at 03:46:29 UTC from IEEE Xplore. Restrictions apply.

You might also like