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