From 3672a2e409c1995bb463376ecc2a4b5be777dabe Mon Sep 17 00:00:00 2001 From: Joshua Bassett Date: Sun, 27 Sep 2020 20:51:44 +1000 Subject: [PATCH] Fix initialization delay There was an issue where the initialization sequence wasn't being calculated correctly. It could result in the SDRAM not being initialized properly. --- rtl/mem/sdram.vhd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rtl/mem/sdram.vhd b/rtl/mem/sdram.vhd index 04d8ac7..291cd5d 100644 --- a/rtl/mem/sdram.vhd +++ b/rtl/mem/sdram.vhd @@ -160,7 +160,7 @@ architecture arch of sdram is constant CLK_PERIOD : real := 1.0/CLK_FREQ*1000.0; -- the number of clock cycles to wait before initialising the device - constant DESELECT_WAIT : natural := natural(ceil(T_DESL/CLK_PERIOD)); + constant INIT_WAIT : natural := natural(ceil(T_DESL/CLK_PERIOD)); -- the number of clock cycles to wait while a LOAD MODE command is being -- executed @@ -234,13 +234,13 @@ begin when INIT => if wait_counter = 0 then next_cmd <= CMD_DESELECT; - elsif wait_counter = DESELECT_WAIT-1 then + elsif wait_counter = INIT_WAIT-1 then next_cmd <= CMD_PRECHARGE; - elsif wait_counter = PRECHARGE_WAIT-1 then + elsif wait_counter = INIT_WAIT+PRECHARGE_WAIT-1 then next_cmd <= CMD_AUTO_REFRESH; - elsif wait_counter = PRECHARGE_WAIT+REFRESH_WAIT-1 then + elsif wait_counter = INIT_WAIT+PRECHARGE_WAIT+REFRESH_WAIT-1 then next_cmd <= CMD_AUTO_REFRESH; - elsif wait_counter = PRECHARGE_WAIT+REFRESH_WAIT+REFRESH_WAIT-1 then + elsif wait_counter = INIT_WAIT+PRECHARGE_WAIT+REFRESH_WAIT+REFRESH_WAIT-1 then next_state <= MODE; next_cmd <= CMD_LOAD_MODE; end if;