集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 1280|回复: 0

SDRAM刷新状态机设计程序——仅供参考

[复制链接]
fpga_feixiang 发表于 2019-11-26 17:51:17 | 显示全部楼层 |阅读模式
/*---------------------------------------------------
        模块名称 : AUTO REFRESH(自动刷新模块)非背靠背刷新
        模块说明 : tRP(min)=15ns  tRFC(min)=66ns
                                       
        --2015-10-06
--------------------------------------------------*/
`include "sdram_head.v"

module sdr_ref_fsm(sys_clk, rst_n, ref_done, ref_bus);

        input sys_clk;
        input rst_n;                           //刷新模块启动信号
        output reg ref_done;  //刷新完成标志信号
        output reg [19:0] ref_bus;

        localparam s0 = 2'b00;
        localparam s1 = 2'b01;
        localparam s2 = 2'b10;
       
        reg [2:0] count;  //延时计数器
        reg [1:0] state;
       
        always @ (posedge sys_clk)
        begin
                if (!rst_n)
                        begin
                                ref_bus[19:16] <= `NOP;  //cs_ras_cas_we_cke_ba_a
                                ref_bus[15] <= 1;
                                ref_bus[14:0] <= 0;
                                ref_done <= 0;
                                count <= 3'd0;
                                state <= s0;
                        end
                else
                        case (state)
                                s0 :  begin       
                                                        ref_bus[19:16] <= `PRECHANGE; //置位后立刻发送预充电命令
                                                        ref_bus[10] <= 1;                                   //选择所有bank
                                                        state <= s1;
                                                end
                                               
                                s1 :         begin         //从S1到S2已经经过了一拍,所以这里`tRP-1
                                                        ref_bus[19:16] <= `NOP;
                                                        if (count < `tRP-1)
                                                                count <= count + 1'b1;
                                                        else
                                                                begin
                                                                        count <= 0;
                                                                        state <= s2;
                                                                        ref_bus[19:16] <= `REFRESH;   //发送自动刷新命令
                                                                end
                                                end
                                               
                                s2 :         begin
                                                        ref_bus[19:16] <= `NOP;
                                                        if(count < `tRFC-1)
                                                                count <= count + 1'b1;
                                                        else
                                                                begin
                                                                        ref_done <= 1;        //刷新过程全部完成,输出标志信号               
                                                                end
                                                end
                                default : ref_bus[19:16] <= `NOP;
                        endcase
        end

endmodule
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-4-30 12:29 , Processed in 0.055096 second(s), 19 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表