Skip to content

Commit f8bd1b2

Browse files
committed
HyperRAM stability fixes
Taken from the C64 core: MJoergen@a227944 MJoergen@ce927cb
1 parent 1523149 commit f8bd1b2

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

M2M/vhdl/controllers/hyperram/hyperram_ctrl.vhd

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ architecture synthesis of hyperram_ctrl is
5555
INIT_ST,
5656
COMMAND_ADDRESS_ST,
5757
WAIT_ST,
58+
WAIT2_ST,
5859
SAMPLE_RWDS_ST,
5960
LATENCY_ST,
6061
READ_ST,
@@ -144,17 +145,35 @@ begin
144145
end if;
145146

146147
when WAIT_ST =>
148+
state <= WAIT2_ST;
149+
150+
when WAIT2_ST =>
147151
state <= SAMPLE_RWDS_ST;
148152

149153
when SAMPLE_RWDS_ST =>
150154
if hb_rwds_in_i = '1' then
151-
latency_count <= 2*G_LATENCY - 4;
152-
count_long <= count_long + 1;
155+
latency_count <= 2*G_LATENCY - 5;
156+
count_long <= count_long + 1;
157+
state <= LATENCY_ST;
153158
else
154-
latency_count <= G_LATENCY - 4;
155159
count_short <= count_short + 1;
160+
if G_LATENCY >= 5 then
161+
latency_count <= G_LATENCY - 5;
162+
state <= LATENCY_ST;
163+
else
164+
if read = '1' then
165+
read_clk_count <= burst_count+1;
166+
read_return_count <= burst_count;
167+
hb_read_o <= '1';
168+
state <= READ_ST;
169+
else
170+
write_clk_count <= burst_count;
171+
hb_dq_oe_o <= '1';
172+
hb_rwds_oe_o <= '1';
173+
state <= WRITE_ST;
174+
end if;
175+
end if;
156176
end if;
157-
state <= LATENCY_ST;
158177

159178
when LATENCY_ST =>
160179
if latency_count > 0 then

M2M/vhdl/controllers/hyperram/hyperram_rx.vhd

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ architecture synthesis of hyperram_rx is
3636

3737
signal rwds_dq_in : std_logic_vector(15 downto 0);
3838
signal rwds_in_delay : std_logic;
39+
signal rwds_in_delay_idelay : std_logic;
3940

4041
signal ctrl_dq_ie : std_logic;
4142
signal ctrl_dq_ie_d : std_logic;
@@ -58,7 +59,7 @@ begin
5859
generic map (
5960
IDELAY_TYPE => "FIXED",
6061
DELAY_SRC => "IDATAIN",
61-
IDELAY_VALUE => 20, -- Number of taps.
62+
IDELAY_VALUE => 12, -- Number of taps: 6/21/24 sy2002 implemented Antti Lukats proposal
6263
HIGH_PERFORMANCE_MODE => "TRUE",
6364
SIGNAL_PATTERN => "CLOCK",
6465
REFCLK_FREQUENCY => 200.0, -- Each tap on average 5/32 ns.
@@ -76,9 +77,23 @@ begin
7677
idatain => hr_rwds_in_i,
7778
datain => '0',
7879
ldpipeen => '0',
79-
dataout => rwds_in_delay,
80+
dataout => rwds_in_delay_idelay,
8081
cntvalueout => open
8182
); -- delay_rwds_inst
83+
84+
-- 6/21/24 sy2002 implemented Antti Lukats proposal
85+
-- add local buffer, is faster than BUFG insertion!
86+
BUFR_inst : BUFR
87+
generic map (
88+
BUFR_DIVIDE => "BYPASS", -- Values: "BYPASS, 1, 2, 3, 4, 5, 6, 7, 8"
89+
SIM_DEVICE => "7SERIES" -- Must be set to "7SERIES"
90+
)
91+
port map (
92+
O => rwds_in_delay, -- 1-bit output: Clock output port
93+
CE => '1', -- 1-bit input: Active high, clock enable (Divided modes only)
94+
CLR => '0', -- 1-bit input: Active high, asynchronous clear (Divided modes only)
95+
I => rwds_in_delay_idelay -- 1-bit input: Clock buffer input driven by an IBUF, MMCM or local interconnect
96+
);
8297

8398
-- Transfer the RWDS signal to the clk_i domain. This is used solely to determine the
8499
-- latency mode of the current transaction.

0 commit comments

Comments
 (0)