|
/*-----------------------------------
模块名称 : 上电刷新模块
模块说明 : 这仅仅只是一个上电的过程,上电完成后,产生一个标志信号
--2015-10-06
------------------------------------*/
`include "sdram_head.v"
module sdr_init_lsm(sys_clk, rst_n, init_done, init_bus);
input sys_clk;
input rst_n;
output reg init_done; //上电完成输出标志
output reg [19:0] init_bus;
`define T0 `T100us //设置cke=1 系统时钟周期T=10ns Tmin=100us
`define T1 `T0+1 //发送预充电命令
`define TN1 `T1+`tRP //tRP最小需要2拍
`define TO1 `TN1+`tRFC //tRF最小需要7拍
`define TP1 `TO1+`tRFC //模式设置
`define TP3 `TP1+`tMRD //激活
reg [15:0] count;
always @ (posedge sys_clk)
begin : lsm_1
if(!rst_n)
count <= 16'd0;
else
count <= count + 1'b1;
end
always @ (posedge sys_clk)
begin : lsm_2
if(!rst_n)
begin
init_done <= 0;
init_bus[19:16] <= `INH;
init_bus[15:0] <= 16'd0;
end
else
case (count)
`T0 : begin
init_bus[15] <= 1; //上电后延迟100us拉高cke信号
init_bus[19:16] <= `NOP;
end
`T1 : begin
init_bus[19:16] <= `PRECHANGE; //发送预充电命令
init_bus[10] <= 1; //a[10]拉高,选择所有bank
end
`TN1 : init_bus[19:16] <= `REFRESH; //经过tRP之后发送自动刷新命令
`TO1 : init_bus[19:16] <= `REFRESH; //经过tRFC之后发送自动刷新命令
`TP1 : begin
init_bus[19:16] <= `LMR; //经过tRFC之后发送模式寄存器设置命令
init_bus[12:0] <= `OP_CODE; //a=m
end
`TP3 : init_done <= 1; //上电过全部指令发送完毕,输出标志信号
default : init_bus[19:16] <= `NOP; //其他情况设置为空指令
endcase
end
endmodule |
|