Design of High Speed Ddr3 Sdram Controller
Design of High Speed Ddr3 Sdram Controller
Design of High Speed Ddr3 Sdram Controller
CHAPTER 1
INTRODUCTION OF DDR3 SDRAM
The DDR3 SDRAM is not very much different from the previous
generation DDR memory in terms of its design and working principles. In
fact, it is true: DDR3 SDRAM is a sort of third reincarnation of DDR
SDRAM principles. Therefore, we are comparing DDR3 and DDR2
SDRAM side by side here.
Courtesy: http://www.ijettjournal.org
Courtesy: http://www.ijettjournal.org
The BGA chip packaging also underwent a few modifications, and now it
features more contact pins. This simplifies the chip mounting procedure
and increases mechanical
The stored data & addresses in the memory are read back to the
Hash-CAM circuit in order to validate the match. In the case of
corresponding reference address is reference address is returned.
DDR2 is a 240 pin DIMM design that operates at 1.8 volts. The
lower voltage counters the heat effect of the higher frequency data
transfer. DRR operates at 2.5 volts and is a 188 pin DIMM design. DDR2
uses a different motherboard socket than DDR, and is not compatible
with motherboards designed for DDR. The DDR2 DIMM key will not align
with DDR DIMM key. If the DDR2 is forced into the DDR socket, it will
damage the socket and the memory will be exposed to a high voltage
level. Also be aware that DDR is 188 pin DIMM design and DDR2 is a
240 pin DIMM design.
1.3.3 DOUBLE DATA RATE-SYNCHRONOUS DYNAMIC
RANDOM ACCESS MEMORY (DDR3 SDRAM) CONTROLLER
DDR3 was the next generation memory introduced in the summer
of 2007 as the natural successor to DDR2. DDR3 increased the pre-fetch
buffer size to 8-bits an increased the operating frequency once again
resulting in high data transfer rates than its predecessor DDR2. In
addition, to the increased data transfer rate memory chip voltage level
was lowered to 1.5 V to counter the heating effects of the high frequency.
By now we can see the trend of memory to increase pre-fetch
buffer size and chip operating frequency, and lowering the operational
voltage level to counter heat. The physical DDR3 is also designed with
240 pins, but the notched key is in a different position to prevent the
insertion into a motherboard RAM socket designed for DDR2.
DDR3 is both electrical and physically incompatible with previous
versions of RAM. In addition to high frequency and lower applied voltage
level, the DDR3 has a memory reset option which DDR2 and DDR1 do
not have. The memory reset allows the memory to be cleared by a
software reset action. Other memory types do not have this feature which
means the memory state is uncertain after a system reboot. The memory
reset feature insures that the memory will be clean or empty after a
system reboot. This feature will result in a more stable memory system.
DDR3 uses the same 240-pin design as DDR2, but the memory module
key notch is at a different location.
four to six, for each memory cell but doesn't have a capacitor in each
cell. It is used primarily for cache. So static RAM is fast and expensive,
and dynamic RAM is less expensive and slower. So, the static RAM is
used to create the CPU's speed-sensitive cache, while dynamic RAM
forms the larger system RAM space.
CHAPTER 2
LITERATURE SURVEY
OVERVIEW OF VERILOG:
VERILOG EVOLUTION:
VERILOG ATTRIBUTES:
Verilog is a hardware description language for describing hardware
from transistor level to behavioral. The language supports timing
constructs for switch level timing simulation and at the same time, it has
FOUNDATION OF XILINX:
CHAPTER 3
PROBLEM DEFINITION OF
DDR3 SDRAM CONTROLLER
CHAPTER 4
DEISGN IMPLEMENTATION OF
DDR3 SDRAM CONTROLLER
The DDR3 controller gets the address, data and control from the
HASH CAM circuit in to the Address FIFO. Write data FIFO and control
FIFO respectively.
Courtesy: http://www.ijettjournal.org
1. IDLE:
When reset is applied the initial FSM is forced to IDLE state
irrespective of which state it is actually in when system is in idle it
remains idle without performing any operations.
2. NO OPERATION (NOP):
The NO OPERATION (NOP) command is used to instruct the
selected DDR SDRAM to perform a NOP. This prevents unwanted
commands from being registered during idle or wait states. Operations
already in progress are not affected.
3. PRECHARGE (PRE):
The PRECHARGE command is used to deactivate the open row in a
particular bank or the open row in all banks as shown in Figure 4.2. The
value on the BA0, BA1 inputs selects the bank, and the A10 input
selects whether a single bank is precharged or whether all banks are
precharged.
All rows are in the “closed” status after the DDR initialization. The
rows need to be “opened” before they can be accessed. However, only one
row in the same bank can be opened at a time. Since there are four
banks, there can be at most four rows opened at the same time. If a row
in one bank is currently opened, it needs to be closed before another row
in the same bank can be opened. ACTIVE command is used to open the
rows and PRECHARGE (or the AUTO PRECHARGE hidden in the WRITE
and READ commands as used in this design) is used to close the rows.
When issuing the commands for opening or closing the rows, both row
address and bank address need to be provided.
In this design, the ACTIVE command will be issued for each read
or write access to open the row. After a tRCD delay is satisfied, READA or
WRITEA commands will be issued with a high ddr_add[10] to enable the
AUTO REFRESH for closing the row after access. Therefore, the clocks
required for read/write cycle are fixed and the access can be random
over the full address range. Read or write is determined by the sys_r_wn
status sampled at the rising edge of the clock before the tRCD delay is
satisfied. If logic high is sampled, the state machine switches to
c_READA. If a logic low is sampled, the state machine switches to
c_WRITEA.
DEPT OF ECE, SBIT, KMM 35
DESIGN OF HIGH SPEED DDR3 SDRAM CONTROLLER
For read cycles, the state machine switches from, c_READA to c_cl
for CAS latency, then switches to crate for transferring data from DDR to
processor. The burst length determines the number of clocks the state
machine stays in c_rdata state. After the data is transferred, it switches
back to c_idle.
The dashed lines indicate possible state switching paths when the
tCK period is larger than the timing delay specification.
Fast read can be achieved by switching banks. Bank control logic is used
to issue desired bank addresses at each cycle when a bank active
command or read command is issued. The state machine for this method
is given in Figure 4.4. The proposed controller provides the control
interface for switching between normal write/read mode and fast read
mode. Unlike other data processing techniques, the distinct
characteristic of the random data lookup is the uncertainty of the
incoming data. In this work, address FIFOs are applied to buffer the
row/column addresses separately for each read request. The “empty” flag
of the row address FIFO (addr_fifo_empty) is checked in order to evaluate
whether the next command is active (ACT) or read (RDA).
DEPT OF ECE, SBIT, KMM 36
DESIGN OF HIGH SPEED DDR3 SDRAM CONTROLLER
2. ACTIVE (ACT):
3. READ:
4. WRITE:
The WRITE command is used to initiate a burst write access to an
active row as shown in Figure 4.4. The value on the BA0, BA1 inputs
selects the bank, and the address provided on inputs A0–Ai (where Ai is
the most significant column address bit for a given density and
configuration) selects the starting column location.
In this design, the ACTIVE command will be issued for each read
or write access to open the row. After a tRCD delay is satisfied, READ or
WRITE commands will be issued with a high sdr_A[10] to enable the
AUTO REFRESH for closing the row after access. So, the clocks required
for read/write cycle are fixed and the access can be random over the full
address range.
For read cycles, the state machine switches from c_READA to c_cl
for CAS latency, then switches to c_rdata for transferring data from
SDRAM to bus master. The number of clocks the state machine stays in
c_rdata state is determined by the burst length. After the data is
transferred, it switches back to c_idle.
CHAPTER 5
FLOW CHART, SOURCE CODE
AND SAMPLE OUTPUTS OF DDR3
SDRAM CONTROLLER
module TOP_tb();
reg sys_CLKX;
reg sys_CLK3X;
reg sys_RESET;
reg write_to_Add_fifo;
reg write_to_WD_fifo;
reg write_to_cntrl_fifo;
reg sys_DLY_200US;
reg [12:0] Address;
reg [1: 0] Control;
reg [63:0] Data_in;
reg [63:0] sdr_DQ_IN;
//--------------------------------------------------------------------//
// outputs //
//--------------------------------------------------------------------//
wire [63:0]final_out;
wire sys_CYC_END;
wire [1:0]ddr_R_Wn;
wire sys_REF_REQ;
wire sdr_CKE; //sdr clock enable
wire [3:0]sdr_CSn; // sdr chip select
wire [3:0]sdr_RASn; // sdr row address
wire [3:0]sdr_CASn; // sdr column select
wire [3:0]sdr_WEn; // sdr write enable
wire [2:0]ddr_BA;
wire [12:0]ddr_A;
wire [2:0] Bank;
wire Bank_sel_0;
wire Bank_sel_1;
wire Bank_sel_2;
wire Bank_sel_3;
wire Bank_sel_4;
wire Bank_sel_5;
wire Bank_sel_6;
wire Bank_sel_7;
.sys_REF_REQ(sys_REF_REQ),
.sdr_CKE(sdr_CKE), //sdr clock enable
.sdr_CSn(sdr_CSn), // sdr chip select
.sdr_RASn(sdr_RASn), // sdr row address
.sdr_CASn(sdr_CASn), // sdr column select
.sdr_WEn(sdr_WEn), // sdr write enable
.ddr_BA(ddr_BA),
.ddr_A(ddr_A),
.Bank(Bank),
.Bank_sel_0(Bank_sel_0),
.Bank_sel_1(Bank_sel_1),
.Bank_sel_2(Bank_sel_2),
.Bank_sel_3(Bank_sel_3),
.Bank_sel_4(Bank_sel_4),
.Bank_sel_5(Bank_sel_5),
.Bank_sel_6(Bank_sel_6),
.Bank_sel_7(Bank_sel_7));
initial
begin
sys_CLKX=1'b1;
sys_CLK3X=1'b1;
end
always
begin
#50 sys_CLKX <= ~ sys_CLKX;
#25 sys_CLK3X <= ~ sys_CLK3X;
end
initial
begin
sys_RESET = 1'b1;
write_to_Add_fifo = 1'b1;
write_to_WD_fifo = 1'b1;
write_to_cntrl_fifo = 1'b1;
sys_DLY_200US = 1'b1;
Address = 13'b0001001010101;
Control = 2'b10;
Data_in = 64'b
00000111110000000011000101010101010000000000000000111100010100010;
sdr_DQ_IN = 64'b
1010000000100010000100001010001001000000101010101010100000011110;
#100 sys_RESET = 1'b0;
#100 Control = 2'b01;
#300 Address = 13'b 0001001010101;
Data_in = 64'b
10000101010001010000010100010110101001001000000100010101010100011;
#4600 sdr_DQ_IN = 64'b
1010000011110000000001010100000000001010000000000000100000011110;
Control = 2'b11;
#1000 sdr_DQ_IN =64'b
0000000010101001000000000000000101010100010100101010100000011110 ;
#700 Control = 2'b10;
end
endmodule
Bank_sel_6,
Bank_sel_7
);
//---------------------------------------------------------------//
// CAS Latency
parameter Latency_2 = 3'b010;
parameter Latency_3 = 3'b011;
// Burst Length
parameter Length_1 = 3'b000;
parameter Length_2 = 3'b001;
parameter Length_4 = 3'b010;
parameter Length_8 = 3'b011;
//-----------------------------------------------------Control---------//
// User modifiable parameters //
//--------------------------------------------------------------//
/****************************
* Mode register setting
****************************/
parameter MR_CAS_Latency = Latency_3;
parameter MR_Burst_Length = Length_4;
//----------------------------------------------------------------//
// SDRAM AC timing spec (User Specifications) //
//-----------------------------------------------------------------//
parameter tCK = 100; // clock peroid
parameter tMRD = 2*tCK; // load mode register peroid
parameter tRP = 210; // precharge peroid
parameter tRFC = 180; // auto refresh period
parameter tRCD = 190; // delay before read/write is sampled
parameter tWR = tCK + 7; // write recovery time
parameter tDAL = tWR + tRP; // sum of write recovery, precharge
//-----------------------------------------------------Control-----------//
// Clock count definition for meeting SDRAM AC timing spec //
//----------------------------------------------------------------//
reg [2:0] NUM1_CLK_tMRD = tMRD/tCK;
reg [2:0] NUM1_CLK_tRP = tRP/tCK;
reg [2:0] NUM1_CLK_tRFC1 = tRFC/tCK;
reg [2:0] NUM1_CLK_tRFC2 = tRFC/tCK;
//--------------------------------------------------------------------//
// outputs //
//--------------------------------------------------------------------//
output [63:0]final_out;
output sys_CYC_END;
output [1:0]ddr_R_Wn;
output sys_REF_REQ;
output sdr_CKE; //sdr clock enable
output [3:0]sdr_CSn; // sdr chip select
output [3:0]sdr_RASn; // sdr row address
output [3:0]sdr_CASn; // sdr column select
output [3:0]sdr_WEn; // sdr write enable
output [2:0]ddr_BA;
output [12:0]ddr_A;
output [2:0] Bank;
output Bank_sel_0;
output Bank_sel_1;
output Bank_sel_2;
output Bank_sel_3;
output Bank_sel_4;
output Bank_sel_5;
output Bank_sel_6;
output Bank_sel_7;
//-------------------------------------------------------------------//
// Wires //
//-------------------------------------------------------------------//
wire [1:0]command;
wire [1: 0]Control;
wire [12:0]sys_A;
wire [63:0]Data_in,sys_D_IN,sys_D_OUT;
wire [12:0]sdr_A;
wire [2 :0]sdr_BA;
wire [63:0]sdr_DQ_IN,sdr_DQ_OUT;
wire sys_D_VALID,sdrclk_DQS,sys_INIT_DONE;
wire Add_Rd_En,Data_Rd_En,Cnt_Rd_En;
wire [1:0]sdr_R_Wn;
wire sys_REF_ACK;
wire write_to_Add_fifo,write_to_WD_fifo,write_to_cntrl_fifo;
wire Add_stack_full,Add_stack_almost_full,Add_stack_half_full,Add_
stack_almost_empty,Add_stack_empty;
wire Data_stack_full,Data_stack_almost_full,Data_stack_half_full,Data_
stack_almost_empty,Data_stack_empty;
wire cntrl_stack_full,cntrl_stack_almost_full,cntrl_stack_half_full,cntrl_
stack_almost_empty,cntrl_stack_empty;
wire [4:0] istate;
wire [4:0] cstate;
wire [4:0] clkCNT;
//wire Add_stack_empty;
//-------------------------------------------------------------------//
// Instantiation of Components //
//-------------------------------------------------------------------//
Add_FIFO Address_FIFO (.clk(sys_CLKX), //i
.rst(sys_RESET), //i
.Address_in(Address),//i
.write_to_Add_fifo(write_to_Add_fifo),//i
.read_from_Add_fifo(Add_Rd_En),
.Address_out(sys_A), //i
.Add_stack_full(Add_stack_full),
.Add_stack_almost_full(Add_stack_almost_full),
.Add_stack_half_full(Add_stack_half_full),
.Add_stack_almost_empty(Add_stack_almost_empty),
.Add_stack_empty(Add_stack_empty));
WR_Data_FIFO Write_Data_FIFO (.clk(sys_CLKX),
.rst(sys_RESET),
.Data_in(Data_in),
.write_to_WD_fifo(write_to_WD_fifo),
.read_from_WD_fifo(Data_Rd_En),
.Data_out(sys_D_IN),
.Data_stack_full(Data_stack_full),
.Data_stack_almost_full(Data_stack_almost_full),
.Data_stack_half_full(Data_stack_half_full),
.Data_stack_almost_empty(Data_stack_almost_empty),
.Data_stack_empty(Data_stack_empty));
Cntrl_FIFO Control_FIFO (.clk(sys_CLKX),
.rst(sys_RESET),
.control_in(Control),
.write_to_cntrl_fifo(write_to_cntrl_fifo),
.read_from_cntrl_fifo(Cnt_Rd_En),
.control_out(command),
.cntrl_stack_full(cntrl_stack_full),
.cntrl_stack_almost_full(cntrl_stack_almost_full),
.cntrl_stack_half_full(cntrl_stack_half_full),
.cntrl_stack_almost_empty(cntrl_stack_almost_empty),
.cntrl_stack_empty(cntrl_stack_empty));
RD_D_reg Read_Data_Register (.clock(sys_CLKX),
.sys_RESET(sys_RESET),
.RD_REG_data_in(sys_D_OUT),
.enable(sys_D_VALID),
.RD_REG_data_out(final_out));
Inti_fsm Initialization_FSM (.sys_CLKX(sys_CLKX),
.sys_RESET(sys_RESET),
.sys_DLY_200US(sys_DLY_200US),//i
.sys_REF_REQ(sys_REF_REQ),
.sys_ADSn(sys_ADSn), //i
.sys_INIT_DONE(sys_INIT_DONE), //i
.istate(istate));
clk_counter Clock_counter ( .sys_CLKX(sys_CLKX),
.sys_RESET(sys_RESET),
.clkCNT(clkCNT),
.iState(istate),
.cState(cstate));
ref_counter Refresh_counter (.sys_CLKX(sys_CLKX),
.sys_RESET(sys_RESET),
.sys_REF_REQ(sys_REF_REQ),
.sdr_REF_REQ(sdr_REF_REQ),
.sys_INIT_DONE(sys_INIT_DONE),
.sys_REF_ACK(sys_REF_ACK),
.cState(cstate));
cmd_fsm Command_FSM (.sys_CLKX(sys_CLKX),
.sys_RESET(sys_RESET),
.sys_ADSn(sys_ADSn), //i
.sdr_REF_REQ(sdr_REF_REQ),
.sys_A(sys_A), //i
.sdr_A(sdr_A),
.sdr_BA(sdr_BA),
.command(command),
.addr_fifo_empty(add_fifo_empty),
.Data_Rd_En(Data_Rd_En),
.cstate(cstate),
.sys_INIT_DONE(sys_INIT_DONE),//o
.sys_CYC_END(sys_CYC_END),//o
.Cnt_Rd_En(Cnt_Rd_En),
.Add_Rd_En(Add_Rd_En),
.sdr_R_Wn(sdr_R_Wn));
Datapath Datapath_control (.sys_CLKX(sys_CLKX),
.sys_CLK3X(sys_CLK3X),
.sys_RESET(sys_RESET),
.sys_D_VALID(sys_D_VALID),
.sdrclk_DQS(sdrclk_DQS),
.sys_D_IN(sys_D_IN),
.sdr_DQ_IN(sdr_DQ_IN),
.sys_D_OUT(sys_D_OUT),
.sdr_DQ_OUT(sdr_DQ_OUT),
.cstate(cstate));
.sys_CLK3X(sys_CLK3X),
.sys_RESET(sys_RESET),
.sdr_A(sdr_A),
.sdr_BA(sdr_BA),
.sys_REF_ACK(sys_REF_ACK),
.sdr_CKE(sdr_CKE),
.sdr_CSn(sdr_CSn),
.sdr_RASn(sdr_RASn),
.sdr_CASn(sdr_CASn),
.sdr_WEn(sdr_WEn),
.ddr_BA(ddr_BA),
.ddr_A(ddr_A),
.iState(istate),
.cState(cstate),
.sdr_R_Wn(sdr_R_Wn),
.ddr_R_Wn(ddr_R_Wn),
.Bank(Bank),
.Bank_sel_0(Bank_sel_0),
.Bank_sel_1(Bank_sel_1),
.Bank_sel_2(Bank_sel_2),
.Bank_sel_3(Bank_sel_3),
.Bank_sel_4(Bank_sel_4),
.Bank_sel_5(Bank_sel_5),
.Bank_sel_6(Bank_sel_6),
.Bank_sel_7(Bank_sel_7));
endmodule
//ADDRESS FIFO
module Add_FIFO(clk,
rst,
Address_in,
write_to_Add_fifo,
read_from_Add_fifo,
Address_out,
Add_stack_full,
Add_stack_almost_full,
Add_stack_half_full,
Add_stack_almost_empty,
Add_stack_empty);
parameter stack_width=13;
parameter stack_height=8;
parameter stack_ptr_width=3;
parameter AE_level=2;
parameter AF_level=6;
parameter HF_level=4;
input[stack_width-1:0] Address_in;
input write_to_Add_fifo,read_from_Add_fifo;
input clk,rst;
output [stack_width-1:0] Address_out;
output Add_stack_full,Add_stack_almost_full,Add_stack_half_full;
output Add_stack_almost_empty,Add_stack_empty;
reg[stack_ptr_width-1:0] read_ptr,write_ptr;
reg[stack_ptr_width:0] ptr_gap;
reg[stack_width-1:0] Address_out;
reg[stack_width-1:0] stack[stack_height-1:0];
assign Add_stack_full=(ptr_gap==stack_height);
assign Add_stack_almost_full=(ptr_gap==AF_level);
assign Add_stack_half_full=(ptr_gap==HF_level);
assign Add_stack_almost_empty=(ptr_gap==AE_level);
assign Add_stack_empty=(ptr_gap==0);
endmodule
//CONTROL FIFO
module
Cntrl_FIFO(clk,rst,control_in,write_to_cntrl_fifo,read_from_cntrl_fifo,control_out,cntrl_st
ack_full,
cntrl_stack_almost_full,cntrl_stack_half_full,cntrl_stack_almost_empty,cntrl_stack_emp
ty);
parameter stack_width=2;
parameter stack_height=8;
parameter stack_ptr_width=3;
parameter AE_level=2;
parameter AF_level=6;
parameter HF_level=4;
output [stack_width-1:0] control_out;
input[stack_width-1:0] control_in;
input write_to_cntrl_fifo,read_from_cntrl_fifo;
input clk,rst;
output cntrl_stack_full,cntrl_stack_almost_full,cntrl_stack_half_full;
output cntrl_stack_almost_empty,cntrl_stack_empty;
reg[stack_ptr_width-1:0] read_ptr,write_ptr;
reg[stack_ptr_width:0] ptr_gap;
reg[stack_width-1:0] control_out;
reg[stack_width-1:0] stack[stack_height-1:0];
assign cntrl_stack_full=(ptr_gap==stack_height);
assign cntrl_stack_almost_full=(ptr_gap==AF_level);
assign cntrl_stack_half_full=(ptr_gap==HF_level);
assign cntrl_stack_almost_empty=(ptr_gap==AE_level);
assign cntrl_stack_empty=(ptr_gap==0);
module
WR_Data_FIFO(clk,rst,Data_in,write_to_WD_fifo,read_from_WD_fifo,Data_out,Data_stac
k_full,
Data_stack_almost_full,Data_stack_half_full,Data_stack_almost_empty,Data_stack_emp
ty);
parameter stack_width=64;
parameter stack_height=8;
parameter stack_ptr_width=3;
parameter AE_level=2;
parameter AF_level=6;
parameter HF_level=4;
input clk,rst;
input[stack_width-1:0] Data_in;
input write_to_WD_fifo,read_from_WD_fifo;
reg[stack_ptr_width-1:0] read_ptr,write_ptr;
reg[stack_ptr_width:0] ptr_gap;
reg[stack_width-1:0] Data_out;
reg[stack_width-1:0] stack[stack_height-1:0];
assign Data_stack_full=(ptr_gap==stack_height);
assign Data_stack_almost_full=(ptr_gap==AF_level);
assign Data_stack_half_full=(ptr_gap==HF_level);
assign Data_stack_almost_empty=(ptr_gap==AE_level);
assign Data_stack_empty=(ptr_gap==0);
write_ptr<=0;
ptr_gap<=0;
end
else if(write_to_WD_fifo &&(!Data_stack_full)&&(!read_from_WD_fifo))begin
stack[write_ptr]<=Data_in;
write_ptr<=write_ptr+1;
ptr_gap<=ptr_gap+1;
end
else if((!write_to_WD_fifo)&&(!Data_stack_empty)&&read_from_WD_fifo)begin
Data_out<=stack[read_ptr];
read_ptr<=read_ptr+1;
ptr_gap<=ptr_gap-1;
end
else if(write_to_WD_fifo &&read_from_WD_fifo&&Data_stack_empty)begin
stack[write_ptr]<=Data_in;
write_ptr<=write_ptr+1;
ptr_gap<=ptr_gap+1;
end
else if(write_to_WD_fifo &&read_from_WD_fifo&&Data_stack_full)begin
Data_out<=stack[read_ptr];
read_ptr<=read_ptr+1;
ptr_gap<=ptr_gap-1;
end
else if(write_to_WD_fifo&&read_from_WD_fifo&&(!Data_stack_full)&&(!
Data_stack_empty))
begin
Data_out<=stack[read_ptr];
stack[write_ptr]<=Data_in;
read_ptr<=read_ptr+1;
write_ptr<=write_ptr+1;
end
endmodule
input clock,enable,sys_RESET;
input [63:0] RD_REG_data_in;
output reg [63:0] RD_REG_data_out;
else if (enable)
RD_REG_data_out <= RD_REG_data_in;
else
RD_REG_data_out <= 64'b0;
end
endmodule
//INITIALIZATION FSM
module Inti_fsm
(sys_CLKX,sys_RESET,sys_DLY_200US,sys_ADSn,sys_INIT_DONE,sys_REF_REQ,istate)
;
input sys_CLKX;
input sys_RESET;
input sys_DLY_200US;
reg [4:0]presentstate,nextstate;
reg load_mrs_done ;
reg load_mrs_af ;
//-----------------------------------------------------------------//
// SDRAM AC timing spec (User Specifications) //
//-----------------------------------------------------------------//
parameter tCK = 100; // clock peroid
parameter tMRD = 2*tCK; // load mode register peroid
parameter tRP = 210; // precharge peroid
parameter tRFC = 180; // auto refresh period
parameter tRCD = 190; // delay before read/write is sampled
parameter tWR = tCK + 7; // write recovery time
parameter tDAL = tWR + tRP; // sum of write recovery, precharge
//----------------------------------------------------------------//
// Clock count definition for meeting SDRAM AC timing spec //
//----------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------
presentstate = 5'b00000;
end
else
presentstate = nextstate;
end
5'b00000 : //i_IDLE
begin
if (sys_DLY_200US)
begin
load_mrs_done = 1'b0;
load_mrs_af = 1'b0;
sys_INIT_DONE = 1'b0;
sys_ADSn = 1'b1;
nextstate = 5'b00001;
end
else nextstate = 5'b00000;
end
5'b00001: //i_NOP
begin
if (sys_DLY_200US) nextstate = 5'b00010; // wait for 100 us delay by checking
sys_DLY_100US
end
5'b00010: //i_PRE
begin
5'b00011: //i_tRP
begin
if ((NUM1_CLK_tRP == 0 && NUM2_CLK_tRP >= 0) || (NUM1_CLK_tRP == 1
&& NUM2_CLK_tRP == 0))
begin // wait until tRP satisfied
if (load_mrs_done)
nextstate = 5'b00101; // i_AR1
else
nextstate = 5'b00100; // i_EMRS
end
else
begin
nextstate = 5'b00011; //i_tRP
NUM1_CLK_tRP = NUM1_CLK_tRP - 1;
end
end
5'b00100: // i_EMRS
begin
if ((NUM1_CLK_tMRD == 0 && NUM2_CLK_tMRD >= 0) ||
(NUM1_CLK_tMRD == 1 && NUM2_CLK_tMRD == 0))
nextstate = 5'b01001; // i_MRS
else
begin
nextstate = 5'b01010; //i_tMRD
NUM1_CLK_tMRD = NUM1_CLK_tMRD - 1;
end
end
end
5'b00110 : //i_tRFC1
begin
if ((NUM1_CLK_tRFC1 == 0 && NUM2_CLK_tRFC1 >= 0) || (NUM1_CLK_tRFC1
== 1 && NUM2_CLK_tRFC1 == 0))
nextstate = 5'b00111; //i_AR2 // wait until tRFC
satisfied
else
begin
nextstate = 5'b00110; //i_tRFC1
NUM1_CLK_tRFC1 = NUM1_CLK_tRFC1 - 1;
end
end
5'b00111 : //i_AR2
begin
if ((NUM1_CLK_tRFC2 == 0 && NUM2_CLK_tRFC2 >= 0) ||
(NUM1_CLK_tRFC2 == 1 && NUM2_CLK_tRFC2 == 0))
nextstate = 5'b01001; //i_MRS
else
begin
nextstate = 5'b01000; // i_tRFC2
NUM1_CLK_tRFC2 = NUM1_CLK_tRFC2 - 1;
end
end
5'b01000 : // i_tRFC2
begin
load_mrs_af = 1'b1; // auto referesh
if ((NUM1_CLK_tRFC2 == 0 && NUM2_CLK_tRFC2 >=
0) || (NUM1_CLK_tRFC2 == 1 && NUM2_CLK_tRFC2 == 0))
begin
nextstate = 5'b01001; // i_MRS
end
else
begin
nextstate = 5'b01000; // i_tRFC2
NUM1_CLK_tRFC2 = NUM1_CLK_tRFC2 - 1;
end
end
5'b01001 : //i_MRS
begin
load_mrs_done = 1'b1; // load mode register
else
begin
nextstate = 5'b01010; //i_tMRD
NUM1_CLK_tMRD = NUM1_CLK_tMRD - 1;
end
end
5'b01010 : //i_tMRD
begin
if ((NUM1_CLK_tMRD == 0 && NUM2_CLK_tMRD >= 0) || (NUM1_CLK_tMRD
== 1 && NUM2_CLK_tMRD == 0))
begin // wait until tMRD satisfied
if(load_mrs_done)
begin
if(load_mrs_af)
nextstate = 5'b01011; // i_ready
else
nextstate = 5'b00010; // i_PRE
end
else
nextstate = 5'b01001; //i_MRS
end
else
begin
nextstate = 5'b01010; //i_tMRD
NUM1_CLK_tMRD = NUM1_CLK_tMRD - 1;
end
end
5'b01011 : //i_ready
begin // stay at this state for normal operation
nextstate = 5'b01011; //i_ready
sys_INIT_DONE = 1'b1;
sys_ADSn = 1'b0;
end
default :
begin
nextstate = 5'b00000; //i_IDLE
sys_INIT_DONE = 1'b0;
sys_ADSn = 1'b1;
end
endcase
end
//CLOCK COUNTER
input sys_CLKX;
input sys_RESET;
reg syncResetClkCNT;
//---------------------------------------------------------------//
// CAS Latency
parameter Latency_2 = 3'b010;
parameter Latency_3 = 3'b011;
// Burst Length
parameter Length_1 = 3'b000;
parameter Length_2 = 3'b001;
parameter Length_4 = 3'b010;
parameter Length_8 = 3'b011;
//--------------------------------------------------------------//
// User modifiable parameters //
//--------------------------------------------------------------//
/****************************
* Mode register setting
****************************/
//-----------------------------------------------------------------//
// SDRAM AC timing spec (User Specifications) //
//-----------------------------------------------------------------//
parameter tCK = 100; // clock peroid
parameter tMRD = 2*tCK; // load mode register peroid
parameter tRP = 210; // precharge peroid
parameter tRFC = 180; // auto refresh period
parameter tRCD = 190; // delay before read/write is sampled
parameter tWR = tCK + 7; // write recovery time
parameter tDAL = tWR + tRP; // sum of write recovery, precharge
//----------------------------------------------------------------//
// Clock count definition for meeting SDRAM AC timing spec //
//----------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------
5'b00000 : //i_IDLE
begin
syncResetClkCNT <= 1'b1;
end
5'b00001 :
syncResetClkCNT <= 1'b1;
5'b00010 : //i_NOP
begin
if ((NUM1_CLK_tRP == 0 && NUM2_CLK_tRP >= 0) || (NUM1_CLK_tRP == 1
&& NUM2_CLK_tRP == 0))
syncResetClkCNT <= 1'b1;
else
syncResetClkCNT <= 1'b0;
end
5'b00011 : //i_PRE
begin
if ((NUM1_CLK_tRP == 0 && NUM2_CLK_tRP >= 0) || (NUM1_CLK_tRP == 1
&& NUM2_CLK_tRP == 0))
syncResetClkCNT <= 1'b1;
else
syncResetClkCNT <= 1'b0;
end
5'b00100: // i_EMRS
begin
if ((NUM1_CLK_tMRD == 0 && NUM2_CLK_tMRD >= 0) ||
(NUM1_CLK_tMRD == 1 && NUM2_CLK_tMRD == 0))
syncResetClkCNT <= 1'b1;
else
syncResetClkCNT <= 1'b0;
end
5'b00101 : //i_AR1
begin
if ((NUM1_CLK_tRFC1 == 0 && NUM2_CLK_tRFC1 >= 0) || (NUM1_CLK_tRFC1
== 1 && NUM2_CLK_tRFC1 == 0))
syncResetClkCNT <= 1'b1;
else
syncResetClkCNT <= 1'b0;
end
5'b00110 : //i_tRFC1
begin
if ((NUM1_CLK_tRFC1 == 0 && NUM2_CLK_tRFC1 >= 0) || (NUM1_CLK_tRFC1
== 1 && NUM2_CLK_tRFC1 == 0))
syncResetClkCNT <= 1'b1;
else
syncResetClkCNT <= 1'b0;
end
5'b00111 : //i_AR2
begin
5'b01000 : //i_tRFC2
begin
if ((NUM1_CLK_tRFC2 == 0 && NUM2_CLK_tRFC2 >= 0) || (NUM1_CLK_tRFC2
== 1 && NUM2_CLK_tRFC2 == 0))
5'b01001 : //i_MRS
begin
if ((NUM1_CLK_tMRD == 0 && NUM2_CLK_tMRD >= 0) || (NUM1_CLK_tMRD
== 1 && NUM2_CLK_tMRD == 0))
syncResetClkCNT <= 1'b1;
else
syncResetClkCNT <= 1'b0;
end
5'b01010 : // i_tMRD
begin
if ((NUM1_CLK_tMRD == 0 && NUM2_CLK_tMRD >= 0) || (NUM1_CLK_tMRD
== 1 && NUM2_CLK_tMRD == 0))
syncResetClkCNT <= 1'b1;
else
syncResetClkCNT <= 1'b0;
end
5'b01011 : //i_ready
begin
case (cState)
5'b01100 : //c_ACTIVE
begin
if ((NUM1_CLK_tMRD == 0 && NUM2_CLK_tMRD >= 0) ||
(NUM1_CLK_tMRD == 1 && NUM2_CLK_tMRD == 0))
syncResetClkCNT <= 1'b1;
else
syncResetClkCNT <= 1'b0;
end
5'b01101 : //c_tRCD
begin
if ((NUM1_CLK_tRCD == 1'b0 && NUM2_CLK_tRCD >= 1'b0) ||
(NUM1_CLK_tRCD == 1'b1 && NUM2_CLK_tRCD == 1'b0))
syncResetClkCNT <= 1'b1;
else
syncResetClkCNT <= 1'b0;
end
5'b01110 : //c_READA
5'b01111 : //c_tRC
begin
if(NUM_CLK_tRC == 1)
syncResetClkCNT <= 1'b1;
else
syncResetClkCNT <= 1'b0;
end
5'b10000 : //c_rdata
begin
if (NUM_CLK_READ == 1)
syncResetClkCNT <= 1'b1;
else
syncResetClkCNT <= 1'b0;
end
5'b10001 : //c_WRITEA
syncResetClkCNT <= 1'b1;
5'b10010 : //c_tWL
begin
if(NUM_CLK_tWL == 1'b1)
syncResetClkCNT <= 1'b1;
else
syncResetClkCNT <= 1'b0;
end
5'b10011 : //c_wdata
begin
if(NUM_CLK_WRITE == 1'b1)
syncResetClkCNT <= 1'b1;
else
syncResetClkCNT <= 1'b0;
end
5'b10100 : //c_tDAL
begin
if ((NUM1_CLK_tDAL == 0 & NUM2_CLK_tDAL >= 0)
| (NUM1_CLK_tDAL == 1'b1 & NUM2_CLK_tDAL == 1'b0))
syncResetClkCNT <= 1'b1;
else
syncResetClkCNT <= 1'b0;
end
default :
syncResetClkCNT <= 1'b0;
endcase
end
default :
syncResetClkCNT <= 1'b1;
endcase
end
end
endmodule
//REFRESH COUNTER
module ref_counter
(sys_CLKX,sys_RESET,sys_REF_REQ,sys_INIT_DONE,sys_REF_ACK,sdr_REF_REQ,cSta
te);
input sys_CLKX;
input sys_RESET;
input sys_REF_REQ;//from initialization fsm
input sdr_REF_REQ; //from command fsm
input sys_INIT_DONE;
input [4:0]cState;
output reg sys_REF_ACK;
always@(posedge sys_CLKX)
begin :REFRESH
if (sys_RESET)
sys_REF_ACK <= 1'b0;
else
begin
case (cState)
5'b10001 : //c_WRITEA
begin
if (sys_REF_REQ == 1'b1 | sdr_REF_REQ == 1'b1)
//COMMAND FSM
// **** for normal write or read operation
//---------------------------------------------------------------------------------------------------------
module cmd_fsm (sys_CLKX,
sys_RESET,
sys_ADSn,
sys_A,
sdr_A,
sdr_BA,
Add_Rd_En,
Data_Rd_En,
Cnt_Rd_En,
sys_INIT_DONE,
addr_fifo_empty,
sys_CYC_END,
command,
sdr_R_Wn,
sdr_REF_REQ,
cstate);
input sys_CLKX;
input sys_RESET;
input [1:0] command; // from control fifo
input sys_ADSn; // from initialization fsm
input [12:0]sys_A; // from Adress fifo
input sys_INIT_DONE; // from initialization fsm
input addr_fifo_empty; // from Adress fifo
// CAS Latency
parameter Latency_2 = 3'b010;
parameter Latency_3 = 3'b011;
// Burst Length
parameter Length_1 = 3'b000;
parameter Length_2 = 3'b001;
parameter Length_4 = 3'b010;
parameter Length_8 = 3'b011;
/
**************************************************************************************************
****
* User modifiable parameters
**************************************************************************************************
*****/
//-----------------------------------------------------------------//
// SDRAM AC timing spec (User Specifications) //
//-----------------------------------------------------------------//
parameter tCK = 100; // clock peroid
parameter tMRD = 2*tCK; // load mode register peroid
parameter tRP = 210; // precharge peroid
parameter tRFC = 180; // auto refresh period
parameter tRCD = 190; // delay before read/write is sampled
parameter tRCD0 = 190; // delay before read/write is sampled IN FAST READ
parameter tRRD = 190; // delay before read is sampled
parameter tWR = tCK + 7; // write recovery time
parameter tRTP = tCK + 11; // read peroid when precharge
parameter tDAL = tWR + tRP; // sum of write recovery, precharge peroid
parameter tRAL = tRTP + tRP; // sum of read peroid when precharge, precharge
peroid
//----------------------------------------------------------------//
// Clock count definition for meeting SDRAM AC timing spec //
//----------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------
presentstate = nextstate;
end
5'b01100: //c_ACTIVE
begin
if ((NUM1_CLK_tRCD == 0 && NUM2_CLK_tRCD >= 0) || (NUM1_CLK_tRCD
== 1 && NUM2_CLK_tRCD == 0))
begin
if (command == 2'b01)
begin
nextstate = 5'b01110; //c_READA
end
if (command == 2'b10)
begin
nextstate = 5'b10001; // c_WRITEA
end
if (command == 2'b11)
begin
nextstate = 5'b10101; // c_wait0 (5'b10101)
end
end
else
nextstate = 5'b01101; // c_tRCD
end
5'b01101 : // c_tRCD
begin
if ((NUM1_CLK_tRCD == 0 && NUM2_CLK_tRCD >= 0) || (NUM1_CLK_tRCD
== 1 && NUM2_CLK_tRCD == 0))
begin
if(command == 2'b01)
begin
nextstate = 5'b01110; //c_READA
end
if(command == 2'b10) // c_WRITEA
begin
nextstate = 5'b10001;
end
if(command == 2'b11) // c_Fast Read
begin
nextstate = 5'b10101;
end
end
else
begin
NUM1_CLK_tRCD = NUM1_CLK_tRCD - 1;
nextstate = 5'b01101; // c_tRCD
end
end
5'b01110 : //c_READA **** assert col/bank addr for read with auto-precharge
begin
nextstate = 5'b01111; //c_tRC
end
5'b01111 : //c_tRC ***** CASn latency
begin
case (NUM_CLK_tRC)
1 : begin
nextstate = 5'b10000; // c_rdata
end
default : begin
nextstate = 5'b01111; //c_tRC
NUM_CLK_tRC = NUM_CLK_tRC - 1;
end
endcase
end
1 : begin
nextstate = 5'b00000;
NUM_CLK_READ = 2'd2;
end
default : begin
nextstate = 5'b10000; // c_rdata
NUM_CLK_READ = NUM_CLK_READ - 1;
end
endcase
end
5'b10001 : // c_WRITEA**** assert col/bank addr for write with auto-precharge
begin
nextstate = 5'b10010; // C_tWL
end
default : begin
nextstate = 5'b10010; // C_tWL
NUM_CLK_tWL = NUM_CLK_tWL - 1;
end
endcase
end
5'b10011 : //c_wdata
begin
case (NUM_CLK_WRITE)
1 : begin
nextstate = 5'b10100 ; // c_tDAL
NUM_CLK_WRITE = 2'd2;
end
default : begin
nextstate = 5'b10011; //c_wdata
NUM_CLK_WRITE = NUM_CLK_WRITE - 1;
end
endcase
end
5'b10100 : // c_tDAL wait until (tWR + tRP) satisfied before issuing next
begin
if ((NUM1_CLK_tDAL == 0 && NUM2_CLK_tDAL >= 0) || (NUM1_CLK_tDAL == 1
&& NUM2_CLK_tDAL == 0))
begin
end
end
5'b10111: //c_tRRD
begin
if ((NUM1_CLK_tRRD == 0 && NUM2_CLK_tRRD >= 0) || (NUM1_CLK_tRRD
== 1 && NUM2_CLK_tRRD >= 0))
begin
if(addr_fifo_empty)
nextstate = 5'b11000; //c_tRCD0
else if (!addr_fifo_empty)
nextstate = 5'b11011; //c_ACTn
5'b11001 : //c_RDA0
begin
case (NUM_CLK_READ)
1 : begin
nextstate = 5'b11010; //c_RDexit
NUM_CLK_READ = 2'd2;
end
default : begin
nextstate = 5'b11001; //c_RDA0
NUM_CLK_READ = NUM_CLK_READ - 1;
end
endcase
end
5'b11010 : // c_RDexit wait until (tRTP + tRP) satisfied before issuing next
begin
if ((NUM1_CLK_tRAL == 0 && NUM2_CLK_tRAL >= 0) || (NUM1_CLK_tRAL == 1
&& NUM2_CLK_tRAL == 0))
begin
nextstate = 5'b00000; //c_idle
end
else
begin
NUM1_CLK_tRAL = NUM1_CLK_tRAL - 1;
nextstate = 5'b11010; // c_RDexit
end
end
5'b11011:// c_ACTn
begin
nextstate = 5'b11100; //c_tRCdn-1 Read Cycle delay
end
5'b11100:// c_tRCdn-1
begin
if ((NUM1_CLK_tRCD == 0 && NUM2_CLK_tRCD >= 0) || (NUM1_CLK_tRCD
== 1 && NUM2_CLK_tRCD == 0))
5'b11101: //c_RDAn-1
begin
if(addr_fifo_empty)
begin
case (NUM_CLK_READ)
1 : begin
nextstate = 5'b11111; //c_RDAn
NUM_CLK_READ = 2'd2;
end
default : begin
nextstate = 5'b11101; //c_RDAn-1
NUM_CLK_READ = NUM_CLK_READ - 1;
end
endcase
end
else nextstate = 5'b11011;// c_ACTn
end
5'b11111: //c_RDAn
begin
case (NUM_CLK_READ)
1 : begin
nextstate = 5'b11010; //c_RDexit
NUM_CLK_READ = 2'd2;
end
default : begin
nextstate = 5'b11111; //c_RDAn
NUM_CLK_READ = NUM_CLK_READ - 1;
end
endcase
end
//***********************************************************************************************
***************
always @ (posedge sys_CLKX)
begin
sdr_R_Wn =command ;
end
if (sys_RESET)
sys_CYC_END = 1'b1;
else
begin
case (presentstate)
5'b10011 : // C_wdata
case (NUM_CLK_WRITE)
1 : sys_CYC_END = 1'b1;
endcase
5'b10000 : //c_rdata
case (NUM_CLK_READ)
1 : sys_CYC_END = 1'b1;
endcase
default:
sys_CYC_END = 1'b0;
endcase
end
end
//******************** Signals to fifo generation ***************************
always @ (posedge sys_CLKX)
begin
case (presentstate)
5'b10000 : //c_rdata
begin
Add_Rd_En = 1'b1;
Cnt_Rd_En = 1'b0;
Data_Rd_En = 1'b0;
end
5'b10011 : //c_wdata
begin
Add_Rd_En = 1'b1;
Cnt_Rd_En = 1'b0;
Data_Rd_En = 1'b1;
end
5'b01100 : //c_ACTIVE
begin
Add_Rd_En = 1'b0;
Cnt_Rd_En = 1'b1;
Data_Rd_En = 1'b0;
end
default :
begin
Add_Rd_En = 1'b0;
Cnt_Rd_En = 1'b0;
Data_Rd_En = 1'b0;
end
endcase
end
endmodule
input sys_CLKX;
input sys_CLK3X;
input sys_RESET;
input [4 :0]cstate;
input [63:0]sys_D_IN; // from wr data fifo
input [63:0]sdr_DQ_IN; // from memory
reg enableSysD ;
end
//c_wdata
if((cstate == 5'b10011 ) && (!sys_RESET)) //Write Cycle Data Path
begin
sdr_DQ_OUT <= sys_D_IN;
end
end
end
end
end
endmodule
//BANK CONTROL
module Bank_cntl(sys_CLKX,sys_CLK3X,sys_RESET,sdr_A,sdr_BA,sys_REF_ACK,Bank,
sdr_CKE,sdr_CSn,sdr_RASn,sdr_CASn,sdr_WEn,ddr_BA,ddr_A,Bank_sel_0,Bank_sel_1,
Bank_sel_2,
Bank_sel_3,Bank_sel_4,Bank_sel_5,Bank_sel_6,Bank_sel_7,iState,cState,sdr_R_Wn,ddr
_R_Wn);
input sys_CLKX;
input sys_CLK3X;
input sys_RESET;
input [2: 0]sdr_BA; // from command fsm
input [12:0]sdr_A;
input sys_REF_ACK;
input [1:0] sdr_R_Wn;
input [4:0] iState;
input [4:0] cState;
5'b00000: //i_IDLE
begin
sdr_CSn <= IDLE;
sdr_RASn<= IDLE;
sdr_CASn<= IDLE;
sdr_WEn <= IDLE;
sdr_CKE <= 1'b0;
ddr_BA <= sdr_BA;
ddr_A <= sdr_A;
end
// i_tRP | i_tRFC1 | i_tRFC2 | i_tMRD |i_NOP
5'b00011 |5'b00110 |5'b01000 |5'b01010 |5'b00001 :
begin
sdr_CSn <= NOP;
sdr_RASn<= NOP;
sdr_CASn<= NOP;
sdr_WEn <= NOP;
sdr_CKE <= 1'b1;
ddr_BA <= sdr_BA;
ddr_A <= sdr_A;
end
5'b00010: //i_PRE
begin
sdr_CSn <= PRECHARGE;
sdr_RASn<= PRECHARGE;
sdr_CASn<= PRECHARGE;
sdr_WEn <= PRECHARGE;
sdr_CKE <= 1'b1;
ddr_BA <= sdr_BA;
ddr_A <= sdr_A;
end
5'b00100: //i_EMRS
begin
sdr_CSn <= LOAD_MODE_REGISTER;
sdr_RASn<= LOAD_MODE_REGISTER;
sdr_CASn<= LOAD_MODE_REGISTER;
sdr_WEn <= LOAD_MODE_REGISTER;
sdr_CKE <= 1'b1;
ddr_BA <= sdr_BA;
ddr_A <= sdr_A;
end
//i_AR1 |i_AR2
5'b00101 | 5'b00111:
begin
sdr_CSn <= AUTO_REFRESH;
sdr_RASn<= AUTO_REFRESH;
sdr_CASn<= AUTO_REFRESH;
sdr_WEn <= AUTO_REFRESH;
sdr_CKE <= 1'b1;
ddr_BA <= sdr_BA;
ddr_A <= sdr_A;
end
5'b01001 : //i_MRS
begin
sdr_CSn <= LOAD_MODE_REGISTER;
sdr_RASn<= LOAD_MODE_REGISTER;
sdr_CASn<= LOAD_MODE_REGISTER;
sdr_WEn <= LOAD_MODE_REGISTER;
sdr_CKE <= 1'b1;
ddr_BA <= sdr_BA;
ddr_A <= sdr_A;
end
5'b01011 : //i_ready
begin
case (cState)
//c_idle | c_tRCD | c_tWL | c_rdata | c_wdata | c_tDAL
5'b00000 |5'b01101 |5'b10010 |5'b10000 | 5'b10011 | 5'b10100 :
begin
sdr_CSn <= NOP;
sdr_RASn<= NOP;
sdr_CASn<= NOP;
sdr_WEn <= NOP;
sdr_CKE <= 1'b1;
ddr_BA <= sdr_BA;
ddr_A <= sdr_A;
end
5'b01100 : //c_ACTIVE
begin
sdr_CSn <= ACTIVE;
sdr_RASn<= ACTIVE;
sdr_CASn<= ACTIVE;
sdr_WEn <= ACTIVE;
sdr_CKE <= 1'b1;
ddr_BA <= sdr_BA;
ddr_A <= sdr_A;
end
5'b01110 : //c_READA
begin
sdr_CSn <= READ;
sdr_RASn<= READ;
sdr_CASn<= READ;
sdr_WEn <= READ;
sdr_CKE <= 1'b1;
ddr_BA <= sdr_BA;
ddr_A <= sdr_A;
end
5'b10001 : //c_WRITEA
begin
sdr_CSn <= WRITE;
sdr_RASn<= WRITE;
sdr_CASn<= WRITE;
sdr_WEn <= WRITE;
sdr_CKE <= 1'b1;
ddr_BA <= sdr_BA;
ddr_A <= sdr_A;
end
default :
begin
sdr_CSn <= NOP;
sdr_RASn<= NOP;
sdr_CASn<= NOP;
sdr_WEn <= NOP;
sdr_CKE <= 1'b1;
ddr_BA <= sdr_BA;
ddr_A <= sdr_A;
end
endcase
end
default: begin
sdr_CSn <= NOP;
sdr_RASn<= NOP;
sdr_CASn<= NOP;
sdr_WEn <= NOP;
sdr_CKE <= 1'b1;
ddr_BA <= sdr_BA;
ddr_A <= sdr_A;
end
endcase
end
begin
if(sys_RESET)
begin
Bank_sel_0 <= 1'b0;
Bank_sel_1 <= 1'b0;
Bank_sel_2 <= 1'b0;
Bank_sel_3 <= 1'b0;
Bank_sel_4 <= 1'b0;
Bank_sel_5 <= 1'b0;
Bank_sel_6 <= 1'b0;
Bank_sel_7 <= 1'b0;
end
else if(sdr_BA == 3'b000)
begin
Bank <=3'b000;
Bank_sel_0 <= 1'b1;
end
else if(sdr_BA == 3'b001)
begin
Bank <=3'b001;
Bank_sel_1 <= 1'b1;
end
else if(sdr_BA == 3'b010)
begin
Bank <=3'b010;
Bank_sel_2 <= 1'b1;
end
else if(sdr_BA == 3'b011)
begin
Bank <=3'b011;
Bank_sel_3 <= 1'b1;
end
else if(sdr_BA == 3'b100)
begin
Bank <=3'b100;
Bank_sel_4 <= 1'b1;
end
else if(sdr_BA == 3'b101)
begin
Bank <=3'b101;
Bank_sel_5 <= 1'b1;
end
else if(sdr_BA == 3'b110)
begin
Bank <=3'b110;
Bank_sel_6 <= 1'b1;
end
else if(sdr_BA == 3'b111)
begin
Bank <=3'b111;
Bank_sel_7 <= 1'b1;
end
else
begin
Bank_sel_0 <= 1'b0;
Bank_sel_1 <= 1'b0;
Bank_sel_2 <= 1'b0;
Bank_sel_3 <= 1'b0;
Bank_sel_4 <= 1'b0;
Bank_sel_5 <= 1'b0;
Bank_sel_6 <= 1'b0;
Bank_sel_7 <= 1'b0;
end
end
always @ (posedge sys_CLKX)
begin
ddr_R_Wn <=sdr_R_Wn ;
end
endmodule
Read State
Write State
CHAPTER 6
ADVANTAGES OF DDR3 SDRAM
CONTROLLER
6.1 ADVANTAGES:
1. Higher bandwidth performance, effectively up to 2400MHz.
4. Compared with DDR SDRAM the voltage of DDR3 SDRAM was lowered
from 2.5V to 1.5V. This improves power consumption and reduces power
dissipation, enables more dense memory configurations for higher
capacities
CHAPTER 7
RESULT, CONCLUSION AND
FUTURE SCOPE
BIBILOGRAPHY
1. A. J. McAuley, et al, “Fast Routing Table Lookup Using CAMs”,
Proceedings on 12th Annual Joint Conference of the IEEE Computer and
Communications Societies (INFOCOM), Vol.3, March 1993, pp.1382 –
1391.
2. X. Yang, et al, “High Performance IP Lookup Circuit Using DDR
SDRAM”, IEEE International SOC Conference (SOCC), Sept. 2008, pp.
371-374.
3. G. Allan, “The Love/Hate Relationship with DDR SDRAM Controllers”,
MOSAID Technologies Whitepaper, 2006.
4. H. Kim, et al, “High-Performance and Low-Power Memory- Interface
Architecture for Video Processing Application”, IEEE Transactions on
Circuit and Systems for Video Technology, Vol. 11, Nov. 2001, pp. 1160-
1170.
5. E. G. T. Jaspers, et al, “Bandwidth Reduction for Video Processing in
Consumer Systems”, IEEE Transactions on Consumer Electronics, Vol.
47, No. 4, Nov. 2001, pp. 885- 894.
6. N. Zhang, et al, “High Performance and High Efficiency Memory
Management System for H.264/AVC Application in the Dual-Core
Platform”, ICASE, Oct. 2006, pp. 5719-5722.
7. J. Zhu, et al, “”High Performance Synchronous DRAMs Controller in
H. 264 HDTV Decoder”, Proceedings of International Conference on
Solid-State and Integrated Circuits Technology, Vol. 3, Oct. 2004, pp.
1621-1624.
8. “High-Performance DDR3 SDRAM Interface in Virtex-5 Devices”,
Xilinx, XAPP867 (v1.0), Sept 24, 2007.
9. T. Mladenov, “Bandwidth, Area Efficient and Target Device
Independent DDR SDRAM Controller”, Proceedings of World Academy of
Science, Engineering and Technology, Vol. 18, De. 2006, pp. 102-106.
APPENDIX
There are now two industry standard hardware description
languages, VHDL and Verilog. Verilog is easier to understand and use.
For several years it has been the language of choice for industrial
applications that required both simulation and synthesis. It lacks,
however, constructs needed for system level specifications. VHDL is more
complex, thus difficult to learn and use. However it offers a lot more
flexibility of the coding styles and is suitable for handling very complex
designs.
Verilg-HDL is a Hardware Description Language used to describe
digital circuit and system operation. It is one of the two IEEE standard
HDLs in use today:
Verilg-HDL IEEE Standard 1364-2001
VHDL IEEE Standard 1076-2002
Verilog-HDL was released in 1983 by Gateway Design System
Corporation, together with a Verilog-HDL Simulator. In 1985 the
language and simulator were enhanced-with the introduction of the
Gateway Design System Corporation. In early 1990, Verilog-HDL and
Verilg-XL were separated to become two separate products. Verilog-HDL,
until then a proprietary language, was released into the public domain.
This was to facilitate the dissemination of knowledge relating to Verilog-
HDL and to compete with VHDL, with VHDL already existing as a non-
proprietary language. Additionally, in 1990, open Verilog International
(OVI) was formed as an industry consortium, consisting of a Computer
Aided Engineering (CAE) vendors and Verilog-HDL users, in order to
control the language specification. In 1995, Verilog-HDL was reviewed
and then adopted as an IEEE standard-IEEE Standard 1364. In 2001,
the standars was reviewed, the latest version of the standard now being
IEEE Std 1364-2001. Within Verilog-HDL, the module describes the
design. All functions and procedures are contained within the module