[wb_sdram] tidy up refresh time parameterisation

Tue, 10 Aug 2010 22:49:21 +0100

author
Philip Pemberton <philpem@philpem.me.uk>
date
Tue, 10 Aug 2010 22:49:21 +0100
changeset 12
81ec01103af1
parent 11
efeebc7c7498
child 13
07b3fd53e7a5

[wb_sdram] tidy up refresh time parameterisation

wb_sdram.v file | annotate | diff | revisions
     1.1 diff -r efeebc7c7498 -r 81ec01103af1 wb_sdram.v
     1.2 --- a/wb_sdram.v	Tue Aug 10 22:14:22 2010 +0100
     1.3 +++ b/wb_sdram.v	Tue Aug 10 22:49:21 2010 +0100
     1.4 @@ -40,15 +40,17 @@
     1.5   * Timer values
     1.6   ****/
     1.7  // CAS latency -- either 2 or 3
     1.8 -parameter	CAS_LATENCY	= 3'd2;
     1.9 +parameter	CAS_LATENCY		= 3'd2;
    1.10  // T_rp  ==> 20ns
    1.11 -parameter	TIME_Trp		= 32'd1;
    1.12 +parameter	TIME_Trp			= 32'd1;
    1.13  // T_rcd ==> 20ns
    1.14 -parameter	TIME_Trcd	= 32'd1;
    1.15 +parameter	TIME_Trcd		= 32'd1;
    1.16  // T_rfc (a.k.a. T_rc) ==> 70ns
    1.17 -parameter	TIME_Trfc	= 32'd2;
    1.18 +parameter	TIME_Trfc		= 32'd2;
    1.19  // T_mrd ==> 2 clock cycles
    1.20 -parameter	TIME_Tmrd	= 32'd2;
    1.21 +parameter	TIME_Tmrd		= 32'd2;
    1.22 +// Maximum allowed time between two refresh cycles
    1.23 +parameter	TIME_REFRESH	= 32'd390;
    1.24  
    1.25  
    1.26  /****
    1.27 @@ -111,21 +113,20 @@
    1.28  /****
    1.29   * Refresh Timer
    1.30   ****/
    1.31 -parameter REFRESH_INTERVAL = 32'd390 - 32'd1;
    1.32  reg [31:0] refresh_timer;
    1.33  reg refresh_req, refresh_ack, refresh_timer_en;
    1.34  always @(posedge wb_clk_i) begin
    1.35  	if (wb_rst_i | !refresh_timer_en) begin
    1.36  		// Reset; clear timer, unset REFRESH REQUEST
    1.37  		refresh_req <= 1'b0;
    1.38 -		refresh_timer <= REFRESH_INTERVAL;
    1.39 +		refresh_timer <= TIME_REFRESH - 32'd1;
    1.40  	end else if (refresh_ack) begin
    1.41  		// Refresh Ack, clear Refresh Request.
    1.42  		refresh_req <= 1'b0;
    1.43  	end else if (refresh_timer == 0) begin
    1.44  		// Refresh timer timed out, make a Refresh Request and reload the timer
    1.45  		refresh_req <= 1'b1;
    1.46 -		refresh_timer <= REFRESH_INTERVAL;
    1.47 +		refresh_timer <= TIME_REFRESH - 32'd1;
    1.48  	end else begin
    1.49  		// Otherwise just decrement the timer
    1.50  		refresh_timer <= refresh_timer - 32'd1;