1 |
2 |
galland |
----------------------------------------------------------------------------------
|
2 |
3 |
galland |
-- Company: VISENGI S.L. (www.visengi.com) - URJC FRAV Group (www.frav.es)
|
3 |
|
|
-- Engineer: Victor Lopez Lorenzo (victor.lopez (at) visengi (dot) com)
|
4 |
2 |
galland |
--
|
5 |
|
|
-- Create Date: 12:39:50 06-Oct-2008
|
6 |
|
|
-- Project Name: ZBT SRAM WISHBONE Controller
|
7 |
|
|
-- Target Devices: Xilinx ML506 board
|
8 |
|
|
-- Tool versions: Xilinx ISE 9.2i
|
9 |
|
|
-- Description: This is a ZBT SRAM controller which is Wishbone rev B.3 compatible (classic + burst r/w operations).
|
10 |
|
|
--
|
11 |
|
|
-- Dependencies: It may be run on any board/FPGA with a ZBT SRAM pin compatible (or at least in the control signals)
|
12 |
|
|
-- with the one on the ML506 board (ISSI IS61NLP 256kx36 ZBT SRAM)
|
13 |
|
|
--
|
14 |
|
|
--
|
15 |
4 |
galland |
-- LICENSE TERMS: (CCPL) Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported.
|
16 |
|
|
-- http://creativecommons.org/licenses/by-nc-sa/3.0/
|
17 |
3 |
galland |
--
|
18 |
|
|
-- That is you may use it only in NON-COMMERCIAL projects.
|
19 |
4 |
galland |
-- You are required to include in the copyrights/about section
|
20 |
|
|
-- that your system contains a "ZBT SRAM Controller (C) Victor Lopez Lorenzo under CCPL license"
|
21 |
2 |
galland |
-- This holds also in the case where you modify the core, as the resulting core
|
22 |
|
|
-- would be a derived work.
|
23 |
3 |
galland |
-- Also, we would like to know if you use this core in a project of yours, just an email will do.
|
24 |
2 |
galland |
--
|
25 |
4 |
galland |
-- Please take good note of the disclaimer section of the CCPL license, as we don't
|
26 |
2 |
galland |
-- take any responsability for anything that this core does.
|
27 |
|
|
----------------------------------------------------------------------------------
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
library IEEE;
|
31 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
32 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
33 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
34 |
|
|
|
35 |
|
|
-- WB: MASTER MUST NOT insert wait states!
|
36 |
|
|
-- WB: maximum burst length is 4 (but bursts may follow without wait states in between)
|
37 |
|
|
|
38 |
|
|
entity zbt_top is
|
39 |
|
|
Port ( clk : in STD_LOGIC;
|
40 |
|
|
reset : in STD_LOGIC;
|
41 |
|
|
|
42 |
|
|
SRAM_CLK : out STD_LOGIC; --Synchronous Clock (up to 200 MHz)
|
43 |
|
|
|
44 |
|
|
--A burst mode pin (MODE) defines the order of the burst sequence. When tied HIGH, the interleaved burst sequence is selected.
|
45 |
|
|
--When tied LOW, the linear burst sequence is selected.
|
46 |
|
|
SRAM_MODE : out STD_LOGIC; --Burst Sequence Selection (pulled down on PCB)
|
47 |
|
|
|
48 |
|
|
SRAM_CS_B : out STD_LOGIC; --Synchronous Chip Enable (CE\, pulled up on PCB)
|
49 |
|
|
|
50 |
|
|
--For write cycles following read cycles, the output buffers must be disabled with OE\, otherwise data bus contention will occur
|
51 |
|
|
SRAM_OE_B : out STD_LOGIC; --Output Enable (OE\, pulled up on PCB)
|
52 |
|
|
|
53 |
|
|
--Write cycles are internally self-timed and are initiated by the rising edge of the clock inputs and when WE\ is LOW.
|
54 |
|
|
SRAM_FLASH_WE_B : out STD_LOGIC; --Synchronous Read/Write Control Input (pulled up on PCB)
|
55 |
|
|
|
56 |
|
|
--All Read, Write and Deselect cycles are initiated by the ADV input. When the ADV input is HIGH the internal
|
57 |
|
|
--burst counter is incremented. New external addresses can be loaded when ADV is LOW.
|
58 |
|
|
SRAM_ADV_LD_B : out STD_LOGIC; --Synchronous Burst Address Advance/Load (pulled down on PCB)
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
SRAM_BW0 : out STD_LOGIC; --Synchronous Byte Write Enable 0 (active low)
|
62 |
|
|
SRAM_BW1 : out STD_LOGIC; --Synchronous Byte Write Enable 1 (active low)
|
63 |
|
|
SRAM_BW2 : out STD_LOGIC; --Synchronous Byte Write Enable 2 (active low)
|
64 |
|
|
SRAM_BW3 : out STD_LOGIC; --Synchronous Byte Write Enable 3 (active low)
|
65 |
|
|
|
66 |
|
|
--SRAM_FLASH_A0 : out STD_LOGIC; --not connected to SRAM!
|
67 |
|
|
SRAM_FLASH_A1 : out STD_LOGIC; --Synchronous Address Input 0
|
68 |
|
|
SRAM_FLASH_A2 : out STD_LOGIC; --Synchronous Address Input 1
|
69 |
|
|
SRAM_FLASH_A3 : out STD_LOGIC;
|
70 |
|
|
SRAM_FLASH_A4 : out STD_LOGIC;
|
71 |
|
|
SRAM_FLASH_A5 : out STD_LOGIC;
|
72 |
|
|
SRAM_FLASH_A6 : out STD_LOGIC;
|
73 |
|
|
SRAM_FLASH_A7 : out STD_LOGIC;
|
74 |
|
|
SRAM_FLASH_A8 : out STD_LOGIC;
|
75 |
|
|
SRAM_FLASH_A9 : out STD_LOGIC;
|
76 |
|
|
SRAM_FLASH_A10 : out STD_LOGIC;
|
77 |
|
|
SRAM_FLASH_A11 : out STD_LOGIC;
|
78 |
|
|
SRAM_FLASH_A12 : out STD_LOGIC;
|
79 |
|
|
SRAM_FLASH_A13 : out STD_LOGIC;
|
80 |
|
|
SRAM_FLASH_A14 : out STD_LOGIC;
|
81 |
|
|
SRAM_FLASH_A15 : out STD_LOGIC;
|
82 |
|
|
SRAM_FLASH_A16 : out STD_LOGIC;
|
83 |
|
|
SRAM_FLASH_A17 : out STD_LOGIC;
|
84 |
|
|
SRAM_FLASH_A18 : out STD_LOGIC;
|
85 |
|
|
|
86 |
|
|
SRAM_FLASH_D0 : inout STD_LOGIC;
|
87 |
|
|
SRAM_FLASH_D1 : inout STD_LOGIC;
|
88 |
|
|
SRAM_FLASH_D2 : inout STD_LOGIC;
|
89 |
|
|
SRAM_FLASH_D3 : inout STD_LOGIC;
|
90 |
|
|
SRAM_FLASH_D4 : inout STD_LOGIC;
|
91 |
|
|
SRAM_FLASH_D5 : inout STD_LOGIC;
|
92 |
|
|
SRAM_FLASH_D6 : inout STD_LOGIC;
|
93 |
|
|
SRAM_FLASH_D7 : inout STD_LOGIC;
|
94 |
|
|
SRAM_FLASH_D8 : inout STD_LOGIC;
|
95 |
|
|
SRAM_FLASH_D9 : inout STD_LOGIC;
|
96 |
|
|
SRAM_FLASH_D10 : inout STD_LOGIC;
|
97 |
|
|
SRAM_FLASH_D11 : inout STD_LOGIC;
|
98 |
|
|
SRAM_FLASH_D12 : inout STD_LOGIC;
|
99 |
|
|
SRAM_FLASH_D13 : inout STD_LOGIC;
|
100 |
|
|
SRAM_FLASH_D14 : inout STD_LOGIC;
|
101 |
|
|
SRAM_FLASH_D15 : inout STD_LOGIC;
|
102 |
|
|
SRAM_D16 : inout STD_LOGIC;
|
103 |
|
|
SRAM_D17 : inout STD_LOGIC;
|
104 |
|
|
SRAM_D18 : inout STD_LOGIC;
|
105 |
|
|
SRAM_D19 : inout STD_LOGIC;
|
106 |
|
|
SRAM_D20 : inout STD_LOGIC;
|
107 |
|
|
SRAM_D21 : inout STD_LOGIC;
|
108 |
|
|
SRAM_D22 : inout STD_LOGIC;
|
109 |
|
|
SRAM_D23 : inout STD_LOGIC;
|
110 |
|
|
SRAM_D24 : inout STD_LOGIC;
|
111 |
|
|
SRAM_D25 : inout STD_LOGIC;
|
112 |
|
|
SRAM_D26 : inout STD_LOGIC;
|
113 |
|
|
SRAM_D27 : inout STD_LOGIC;
|
114 |
|
|
SRAM_D28 : inout STD_LOGIC;
|
115 |
|
|
SRAM_D29 : inout STD_LOGIC;
|
116 |
|
|
SRAM_D30 : inout STD_LOGIC;
|
117 |
|
|
SRAM_D31 : inout STD_LOGIC;
|
118 |
|
|
|
119 |
|
|
SRAM_DQP0 : inout STD_LOGIC; --Parity Data I/O 0
|
120 |
|
|
SRAM_DQP1 : inout STD_LOGIC; --Parity Data I/O 1
|
121 |
|
|
SRAM_DQP2 : inout STD_LOGIC; --Parity Data I/O 2
|
122 |
|
|
SRAM_DQP3 : inout STD_LOGIC; --Parity Data I/O 3
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
wb_adr_i : in std_logic_vector(17 downto 0);
|
127 |
|
|
wb_we_i : in std_logic;
|
128 |
|
|
wb_dat_i : in std_logic_vector(35 downto 0);
|
129 |
|
|
wb_sel_i : in std_logic_vector(3 downto 0);
|
130 |
|
|
wb_dat_o : out std_logic_vector(35 downto 0);
|
131 |
|
|
wb_cyc_i : in std_logic;
|
132 |
|
|
wb_stb_i : in std_logic;
|
133 |
|
|
wb_cti_i : in std_logic_vector(2 downto 0);
|
134 |
|
|
wb_bte_i : in std_logic_vector(1 downto 0);
|
135 |
|
|
wb_ack_o : out std_logic;
|
136 |
|
|
wb_err_o : out std_logic;
|
137 |
|
|
wb_tga_i: in std_logic := '0' --'0' to mean last (or single) 4 words burst
|
138 |
|
|
|
139 |
|
|
);
|
140 |
|
|
end zbt_top;
|
141 |
|
|
|
142 |
|
|
architecture Behavioral of zbt_top is
|
143 |
|
|
signal ZBT_addr, ZBT_addr2 : std_logic_vector(17 downto 0);
|
144 |
|
|
signal ZBT_din, ZBT_din2, ZBT_din1 : std_logic_vector(35 downto 0);
|
145 |
|
|
signal ZBT_dout : std_logic_vector(35 downto 0);
|
146 |
|
|
signal BW_enable, SRAM_OE_B2 : std_logic;
|
147 |
|
|
|
148 |
|
|
signal State : integer;
|
149 |
|
|
|
150 |
|
|
constant IDLE : integer := 0;
|
151 |
|
|
constant C1 : integer := 1;
|
152 |
|
|
constant C2 : integer := 2;
|
153 |
|
|
constant C3 : integer := 3;
|
154 |
|
|
constant C4 : integer := 4;
|
155 |
|
|
constant B1 : integer := 5;
|
156 |
|
|
constant B2 : integer := 6;
|
157 |
|
|
constant B3 : integer := 7;
|
158 |
|
|
constant B4 : integer := 8;
|
159 |
|
|
constant B5 : integer := 9;
|
160 |
|
|
constant B6 : integer := 10;
|
161 |
|
|
constant B4L : integer := 11;
|
162 |
|
|
constant B5L : integer := 12;
|
163 |
|
|
constant B6L : integer := 13;
|
164 |
|
|
constant B0W : integer := 14;
|
165 |
|
|
constant B1W : integer := 15;
|
166 |
|
|
constant B2W : integer := 16;
|
167 |
|
|
constant B3W : integer := 17;
|
168 |
|
|
constant B4WL : integer := 18;
|
169 |
|
|
constant B5WL : integer := 19;
|
170 |
|
|
begin
|
171 |
|
|
|
172 |
|
|
FSM_State_Control : process (clk, reset)
|
173 |
|
|
begin
|
174 |
|
|
if (reset = '1') then
|
175 |
|
|
State <= IDLE;
|
176 |
|
|
elsif (clk = '1' and clk'event) then
|
177 |
|
|
case State is
|
178 |
|
|
when IDLE =>
|
179 |
|
|
if (wb_cyc_i = '1' and wb_stb_i = '1') then --start of WB cycle?
|
180 |
|
|
if (wb_bte_i /= "00" or wb_cti_i /= "010") then --classic cycle
|
181 |
|
|
--(WB rule 4.25, only linear bursts accepted, WB permission 4.40: EOB=single access~=sync.classic cycle, WB rule 4.10: unknown=classic cycles)
|
182 |
|
|
--we were in idle state, so any classic cycle, EOB cycle or any cycle with a non linear burst is executed as a classic one
|
183 |
|
|
State <= C1;
|
184 |
|
|
else --Incrementing burst cycle with linear burst type
|
185 |
|
|
assert (wb_bte_i = "00" and wb_cti_i="010") report "Bad else on IDLE state (cti=" & integer'image(conv_integer(wb_cti_i)) & ", bte=" & integer'image(conv_integer(wb_bte_i)) & ")" severity FAILURE;
|
186 |
|
|
if (wb_we_i = '0') then --wb burst read?
|
187 |
|
|
State <= B1;
|
188 |
|
|
else --wb burst write?
|
189 |
|
|
State <= B0W;
|
190 |
|
|
end if;
|
191 |
|
|
end if;
|
192 |
|
|
else
|
193 |
|
|
State <= IDLE;
|
194 |
|
|
end if;
|
195 |
|
|
|
196 |
|
|
--start single word read/write
|
197 |
|
|
when C1 =>
|
198 |
|
|
if (wb_cyc_i = '1' and wb_stb_i = '1') then State <= C2; else State <= IDLE; end if;
|
199 |
|
|
when C2 => --wb_ack <= '1' in this cycle
|
200 |
|
|
if (wb_cyc_i = '1' and wb_stb_i = '1') then State <= C3; else State <= IDLE; end if;
|
201 |
|
|
when C3 => --wb_ack = '1' in this cycle
|
202 |
|
|
State <= C4;
|
203 |
|
|
when C4 =>
|
204 |
|
|
State <= IDLE;
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
--Burst read
|
208 |
|
|
when B1 =>
|
209 |
|
|
if (wb_cyc_i = '1' and wb_stb_i = '1' and wb_cti_i /= "111") then State <= B2; else State <= IDLE; end if;
|
210 |
|
|
when B2 =>
|
211 |
|
|
if (wb_cyc_i = '1' and wb_stb_i = '1' and wb_cti_i /= "111") then State <= B3; else State <= IDLE; end if;
|
212 |
|
|
when B3 =>
|
213 |
|
|
if (wb_cyc_i = '1' and wb_stb_i = '1' and wb_cti_i /= "111") then
|
214 |
|
|
if (wb_tga_i = '0') then --last burst?
|
215 |
|
|
State <= B4L;
|
216 |
|
|
else
|
217 |
|
|
State <= B4;
|
218 |
|
|
end if;
|
219 |
|
|
else
|
220 |
|
|
State <= IDLE;
|
221 |
|
|
end if;
|
222 |
|
|
when B4 =>
|
223 |
|
|
if (wb_cyc_i = '1' and wb_stb_i = '1' and wb_cti_i /= "111") then State <= B5; else State <= IDLE; end if;
|
224 |
|
|
when B5 =>
|
225 |
|
|
if (wb_cyc_i = '1' and wb_stb_i = '1' and wb_cti_i /= "111") then State <= B6; else State <= IDLE; end if;
|
226 |
|
|
when B6 => --go back to B3
|
227 |
|
|
if (wb_cyc_i = '1' and wb_stb_i = '1' and wb_cti_i /= "111") then State <= B3; else State <= IDLE; end if;
|
228 |
|
|
--last burst read
|
229 |
|
|
when B4L =>
|
230 |
|
|
if (wb_cyc_i = '1' and wb_stb_i = '1' and wb_cti_i /= "111") then State <= B5L; else State <= IDLE; end if;
|
231 |
|
|
when B5L =>
|
232 |
|
|
if (wb_cyc_i = '1' and wb_stb_i = '1' and wb_cti_i /= "111") then State <= B6L; else State <= IDLE; end if;
|
233 |
|
|
when B6L => --in this cycle wb_cti_i must be 111 because the ZBT has a burst length of 4
|
234 |
|
|
State <= IDLE;
|
235 |
|
|
|
236 |
|
|
--Burst write
|
237 |
|
|
when B0W =>
|
238 |
|
|
if (wb_cyc_i = '1' and wb_stb_i = '1' and wb_cti_i /= "111") then State <= B1W; else State <= IDLE; end if;
|
239 |
|
|
when B1W =>
|
240 |
|
|
if (wb_cyc_i = '1' and wb_stb_i = '1' and wb_cti_i /= "111") then State <= B2W; else State <= IDLE; end if;
|
241 |
|
|
when B2W =>
|
242 |
|
|
if (wb_cyc_i = '1' and wb_stb_i = '1' and wb_cti_i /= "111") then State <= B3W; else State <= IDLE; end if;
|
243 |
|
|
when B3W =>
|
244 |
|
|
if (wb_cyc_i = '1' and wb_stb_i = '1') then --wb_cti should be "111" if it is the last burst
|
245 |
|
|
if (wb_tga_i = '0') then --last burst?
|
246 |
|
|
State <= B4WL;
|
247 |
|
|
else
|
248 |
|
|
State <= B0W;
|
249 |
|
|
end if;
|
250 |
|
|
else
|
251 |
|
|
State <= IDLE;
|
252 |
|
|
end if;
|
253 |
|
|
|
254 |
|
|
--last burst write
|
255 |
|
|
when B4WL => --don't check cti as it was 111 in B3W for the last burst!
|
256 |
|
|
State <= B5WL;
|
257 |
|
|
when B5WL =>
|
258 |
|
|
State <= IDLE;
|
259 |
|
|
|
260 |
|
|
when others =>
|
261 |
|
|
report "Bad state on FSM_State_Control " & integer'image(State) severity FAILURE;
|
262 |
|
|
end case;
|
263 |
|
|
end if;
|
264 |
|
|
end process FSM_State_Control;
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
|
268 |
|
|
Wishbone_Slave_Control : process (clk, reset)
|
269 |
|
|
begin
|
270 |
|
|
if (reset = '1') then
|
271 |
|
|
wb_ack_o <= '0';
|
272 |
|
|
wb_err_o <= '0';
|
273 |
|
|
elsif (clk = '1' and clk'event) then
|
274 |
|
|
wb_err_o <= '0';
|
275 |
|
|
case State is
|
276 |
|
|
when IDLE =>
|
277 |
|
|
if (wb_cyc_i='1' and wb_stb_i='1' and wb_we_i='1' and wb_bte_i="00" and wb_cti_i="010") then --burst write cycle?
|
278 |
|
|
wb_ack_o <= '1'; --preack the master to have it give us the next wb_sel_i and wb_dat_i signals
|
279 |
|
|
else
|
280 |
|
|
wb_ack_o <= '0';
|
281 |
|
|
end if;
|
282 |
|
|
|
283 |
|
|
when C1 | C3 | C4 | B1 | B6L | B4WL | B5WL => --in the case of bursts cyc MUST be lowered after cti="111"
|
284 |
|
|
wb_ack_o <= '0'; --in the case of classic cycles, we have C3 and C4 where ack is lowered, to make the master lower cyc
|
285 |
|
|
|
286 |
|
|
when C2 | B2 | B3 | B4 | B5 | B6 | B4L | B5L | B0W | B1W | B2W =>
|
287 |
|
|
wb_ack_o <= wb_cyc_i and wb_stb_i; --ack should be 1, but it will only go up if cyc and stb are so
|
288 |
|
|
|
289 |
|
|
when B3W => --last write burst?
|
290 |
|
|
wb_ack_o <= wb_tga_i and wb_cyc_i and wb_stb_i; --ack should be 1, but it will only go up if cyc and stb are so (and if it is not the last burst)
|
291 |
|
|
|
292 |
|
|
when others =>
|
293 |
|
|
report "Bad state on WB_Slave_Control " & integer'image(State) severity FAILURE;
|
294 |
|
|
end case;
|
295 |
|
|
end if;
|
296 |
|
|
end process Wishbone_Slave_Control;
|
297 |
|
|
|
298 |
|
|
wb_dat_o <= ZBT_dout;
|
299 |
|
|
|
300 |
|
|
ZBT_SRAM_Control : process (clk, reset)
|
301 |
|
|
variable vBW_enable : std_logic;
|
302 |
|
|
begin
|
303 |
|
|
if (reset = '1') then
|
304 |
|
|
SRAM_ADV_LD_B <= '0';
|
305 |
|
|
SRAM_CS_B <= '1'; --chip NOT selected
|
306 |
|
|
SRAM_FLASH_WE_B <= '1'; --DON'T write anything
|
307 |
|
|
|
308 |
|
|
--by default output is not enabled to avoid bus contemption with the wb master
|
309 |
|
|
SRAM_OE_B2 <= '1'; --output NOT enabled
|
310 |
|
|
|
311 |
|
|
ZBT_addr <= (others => '0');
|
312 |
|
|
ZBT_addr2 <= (others => '0');
|
313 |
|
|
|
314 |
|
|
ZBT_din2 <= (others => '0');
|
315 |
|
|
ZBT_din1 <= (others => '0');
|
316 |
|
|
ZBT_din <= (others => '0');
|
317 |
|
|
|
318 |
|
|
BW_enable <= '0';
|
319 |
|
|
vBW_enable := '0';
|
320 |
|
|
SRAM_BW0 <= '1';
|
321 |
|
|
SRAM_BW1 <= '1';
|
322 |
|
|
SRAM_BW2 <= '1';
|
323 |
|
|
SRAM_BW3 <= '1';
|
324 |
|
|
elsif (clk = '1' and clk'event) then
|
325 |
|
|
--two stage datain pipeline
|
326 |
|
|
ZBT_din2 <= wb_dat_i;
|
327 |
|
|
ZBT_din1 <= ZBT_din2;
|
328 |
|
|
ZBT_din <= ZBT_din1;
|
329 |
|
|
|
330 |
|
|
--REASON WHY THERE IS A DATAIN PIPELINE:
|
331 |
|
|
--Based on the ZBT SRAM datasheet:
|
332 |
|
|
--it doesn't make much sense but the "byte write enables" are not fed to the ZBT
|
333 |
|
|
--at the same time than the data to be written, so the wb_sel_i lines arrive late
|
334 |
|
|
--(because they arrive, obviously, at the same time than their associated wb_dat_i lines)
|
335 |
|
|
--which is 2 cycles later than when they should be fed to the ZBT
|
336 |
|
|
--the only solution is, on wb writes:
|
337 |
|
|
-- 1) start wb_acking soon (to have the master give us soon enough the right wb_sel lines for each data word to write)
|
338 |
|
|
-- 2) make two registers to have a two stage pipeline for the data words in order to feed them to the ZBT at the 3rd cycle
|
339 |
|
|
-- this means 72 extra FFs for the registers and a more complex wb slave logic (differentiate if read or write)
|
340 |
|
|
-- there would be the same number of acks but the 2 cycles response latency would happen at the end of the last burst of the wb write
|
341 |
|
|
|
342 |
|
|
case State is
|
343 |
|
|
when IDLE => --prepare signals for next cycle
|
344 |
|
|
vBW_enable := '0';
|
345 |
|
|
SRAM_ADV_LD_B <= '0';
|
346 |
|
|
if (wb_cyc_i = '1' and wb_stb_i = '1') then
|
347 |
|
|
ZBT_addr <= wb_adr_i;
|
348 |
|
|
ZBT_addr2 <= wb_adr_i + x"4";
|
349 |
|
|
if (wb_bte_i /= "00" or wb_cti_i /= "010") then --classic cycle?
|
350 |
|
|
SRAM_CS_B <= '0'; --chip selected
|
351 |
|
|
SRAM_OE_B2 <= wb_we_i; --if it's a read -> enable outputs
|
352 |
|
|
SRAM_FLASH_WE_B <= not wb_we_i;
|
353 |
|
|
vBW_enable := wb_we_i;
|
354 |
|
|
else --burst
|
355 |
|
|
if (wb_we_i = '0') then --wb burst read?
|
356 |
|
|
SRAM_CS_B <= '0'; --chip selected
|
357 |
|
|
SRAM_OE_B2 <= wb_we_i; --if it's a read -> enable outputs
|
358 |
|
|
SRAM_FLASH_WE_B <= not wb_we_i;
|
359 |
|
|
else --wb burst write? start ZBT in B0W but get now ZBT_addr2!
|
360 |
|
|
ZBT_addr2 <= wb_adr_i; --important because ZBT_addr2 will be assigned in next cycle (so don't sum 4 to it)
|
361 |
|
|
SRAM_CS_B <= '1'; --chip NOT selected
|
362 |
|
|
SRAM_OE_B2 <= '1'; --output NOT enabled for next cycle
|
363 |
|
|
SRAM_FLASH_WE_B <= '1'; --DON'T write anything
|
364 |
|
|
end if;
|
365 |
|
|
end if;
|
366 |
|
|
else
|
367 |
|
|
SRAM_CS_B <= '1'; --chip NOT selected
|
368 |
|
|
SRAM_OE_B2 <= '1'; --output NOT enabled for next cycle
|
369 |
|
|
SRAM_FLASH_WE_B <= '1'; --DON'T write anything
|
370 |
|
|
ZBT_addr <= (others => '0');
|
371 |
|
|
ZBT_addr2 <= (others => '0');
|
372 |
|
|
end if;
|
373 |
|
|
|
374 |
|
|
|
375 |
|
|
when C1 | C2 =>
|
376 |
|
|
SRAM_CS_B <= '1'; --chip NOT selected (doesn't affect current op.: don't care in datasheet)
|
377 |
|
|
SRAM_ADV_LD_B <= '0'; --NOT a burst
|
378 |
|
|
--SRAM_OE_B2 keep the selected output enable for the current WB operation
|
379 |
|
|
vBW_enable := '0'; --it only matters for the ADV=0 cycle of the ZBT operation
|
380 |
|
|
|
381 |
|
|
when C3 | C4 =>
|
382 |
|
|
SRAM_CS_B <= '1'; --chip NOT selected (doesn't affect current op.: don't care in datasheet)
|
383 |
|
|
SRAM_ADV_LD_B <= '0'; --NOT a burst
|
384 |
|
|
SRAM_OE_B2 <= '1'; --output NOT enabled for next cycle
|
385 |
|
|
vBW_enable := '0';
|
386 |
|
|
|
387 |
|
|
|
388 |
|
|
|
389 |
|
|
when B1 | B2 | B3 | B5 | B6 =>
|
390 |
|
|
SRAM_ADV_LD_B <= '1';
|
391 |
|
|
|
392 |
|
|
when B4 => --precharge address for next 4 word burst
|
393 |
|
|
SRAM_ADV_LD_B <= '0';
|
394 |
|
|
ZBT_addr <= ZBT_addr2;
|
395 |
|
|
ZBT_addr2 <= ZBT_addr2 + x"4";
|
396 |
|
|
|
397 |
|
|
when B4L | B5L | B6L => --last burst
|
398 |
|
|
SRAM_ADV_LD_B <= '0';
|
399 |
|
|
SRAM_CS_B <= '1'; --chip NOT selected
|
400 |
|
|
|
401 |
|
|
|
402 |
|
|
when B0W => --a wb write starts here
|
403 |
|
|
SRAM_ADV_LD_B <= '0'; --first write cycle
|
404 |
|
|
SRAM_OE_B2 <= '1'; --keep output NOT enabled (it's a write)
|
405 |
|
|
SRAM_CS_B <= '0'; --chip selected
|
406 |
|
|
SRAM_FLASH_WE_B <= '0'; --start writing
|
407 |
|
|
ZBT_addr <= ZBT_addr2;
|
408 |
|
|
ZBT_addr2 <= ZBT_addr2 + x"4";
|
409 |
|
|
vBW_enable := '1';
|
410 |
|
|
|
411 |
|
|
when B1W | B2W | B3W =>
|
412 |
|
|
SRAM_ADV_LD_B <= '1';
|
413 |
|
|
vBW_enable := '1';
|
414 |
|
|
|
415 |
|
|
when B4WL | B5WL =>
|
416 |
|
|
SRAM_CS_B <= '1'; --chip NOT selected (don't care in datasheet)
|
417 |
|
|
SRAM_FLASH_WE_B <= '1'; --DON'T write (don't care in datasheet)
|
418 |
|
|
SRAM_ADV_LD_B <= '0';
|
419 |
|
|
vBW_enable := '0';
|
420 |
|
|
|
421 |
|
|
when others =>
|
422 |
|
|
report "Bad state on ZBT_SRAM_Control " & integer'image(State) severity FAILURE;
|
423 |
|
|
end case;
|
424 |
|
|
|
425 |
|
|
BW_enable <= vBW_enable;
|
426 |
|
|
--Byte write enables are active low
|
427 |
|
|
SRAM_BW0 <= not (wb_sel_i(0) and vBW_enable);
|
428 |
|
|
SRAM_BW1 <= not (wb_sel_i(1) and vBW_enable);
|
429 |
|
|
SRAM_BW2 <= not (wb_sel_i(2) and vBW_enable);
|
430 |
|
|
SRAM_BW3 <= not (wb_sel_i(3) and vBW_enable);
|
431 |
|
|
end if;
|
432 |
|
|
end process ZBT_SRAM_Control;
|
433 |
|
|
|
434 |
|
|
|
435 |
|
|
|
436 |
|
|
SRAM_CLK <= clk;
|
437 |
|
|
SRAM_MODE <= '0'; --linear bursts
|
438 |
|
|
SRAM_OE_B <= SRAM_OE_B2; --to let OE_B2 be read to mux the data lines
|
439 |
|
|
|
440 |
|
|
|
441 |
|
|
---------------------------------
|
442 |
|
|
-- DATA IN LINES
|
443 |
|
|
---------------------------------
|
444 |
|
|
SRAM_FLASH_D0 <= ZBT_din(0) when (SRAM_OE_B2 = '1') else 'Z';
|
445 |
|
|
SRAM_FLASH_D1 <= ZBT_din(1) when (SRAM_OE_B2 = '1') else 'Z';
|
446 |
|
|
SRAM_FLASH_D2 <= ZBT_din(2) when (SRAM_OE_B2 = '1') else 'Z';
|
447 |
|
|
SRAM_FLASH_D3 <= ZBT_din(3) when (SRAM_OE_B2 = '1') else 'Z';
|
448 |
|
|
SRAM_FLASH_D4 <= ZBT_din(4) when (SRAM_OE_B2 = '1') else 'Z';
|
449 |
|
|
SRAM_FLASH_D5 <= ZBT_din(5) when (SRAM_OE_B2 = '1') else 'Z';
|
450 |
|
|
SRAM_FLASH_D6 <= ZBT_din(6) when (SRAM_OE_B2 = '1') else 'Z';
|
451 |
|
|
SRAM_FLASH_D7 <= ZBT_din(7) when (SRAM_OE_B2 = '1') else 'Z';
|
452 |
|
|
SRAM_FLASH_D8 <= ZBT_din(8) when (SRAM_OE_B2 = '1') else 'Z';
|
453 |
|
|
SRAM_FLASH_D9 <= ZBT_din(9) when (SRAM_OE_B2 = '1') else 'Z';
|
454 |
|
|
SRAM_FLASH_D10 <= ZBT_din(10) when (SRAM_OE_B2 = '1') else 'Z';
|
455 |
|
|
SRAM_FLASH_D11 <= ZBT_din(11) when (SRAM_OE_B2 = '1') else 'Z';
|
456 |
|
|
SRAM_FLASH_D12 <= ZBT_din(12) when (SRAM_OE_B2 = '1') else 'Z';
|
457 |
|
|
SRAM_FLASH_D13 <= ZBT_din(13) when (SRAM_OE_B2 = '1') else 'Z';
|
458 |
|
|
SRAM_FLASH_D14 <= ZBT_din(14) when (SRAM_OE_B2 = '1') else 'Z';
|
459 |
|
|
SRAM_FLASH_D15 <= ZBT_din(15) when (SRAM_OE_B2 = '1') else 'Z';
|
460 |
|
|
SRAM_D16 <= ZBT_din(16) when (SRAM_OE_B2 = '1') else 'Z';
|
461 |
|
|
SRAM_D17 <= ZBT_din(17) when (SRAM_OE_B2 = '1') else 'Z';
|
462 |
|
|
SRAM_D18 <= ZBT_din(18) when (SRAM_OE_B2 = '1') else 'Z';
|
463 |
|
|
SRAM_D19 <= ZBT_din(19) when (SRAM_OE_B2 = '1') else 'Z';
|
464 |
|
|
SRAM_D20 <= ZBT_din(20) when (SRAM_OE_B2 = '1') else 'Z';
|
465 |
|
|
SRAM_D21 <= ZBT_din(21) when (SRAM_OE_B2 = '1') else 'Z';
|
466 |
|
|
SRAM_D22 <= ZBT_din(22) when (SRAM_OE_B2 = '1') else 'Z';
|
467 |
|
|
SRAM_D23 <= ZBT_din(23) when (SRAM_OE_B2 = '1') else 'Z';
|
468 |
|
|
SRAM_D24 <= ZBT_din(24) when (SRAM_OE_B2 = '1') else 'Z';
|
469 |
|
|
SRAM_D25 <= ZBT_din(25) when (SRAM_OE_B2 = '1') else 'Z';
|
470 |
|
|
SRAM_D26 <= ZBT_din(26) when (SRAM_OE_B2 = '1') else 'Z';
|
471 |
|
|
SRAM_D27 <= ZBT_din(27) when (SRAM_OE_B2 = '1') else 'Z';
|
472 |
|
|
SRAM_D28 <= ZBT_din(28) when (SRAM_OE_B2 = '1') else 'Z';
|
473 |
|
|
SRAM_D29 <= ZBT_din(29) when (SRAM_OE_B2 = '1') else 'Z';
|
474 |
|
|
SRAM_D30 <= ZBT_din(30) when (SRAM_OE_B2 = '1') else 'Z';
|
475 |
|
|
SRAM_D31 <= ZBT_din(31) when (SRAM_OE_B2 = '1') else 'Z';
|
476 |
|
|
SRAM_DQP0 <= ZBT_din(32) when (SRAM_OE_B2 = '1') else 'Z';
|
477 |
|
|
SRAM_DQP1 <= ZBT_din(33) when (SRAM_OE_B2 = '1') else 'Z';
|
478 |
|
|
SRAM_DQP2 <= ZBT_din(34) when (SRAM_OE_B2 = '1') else 'Z';
|
479 |
|
|
SRAM_DQP3 <= ZBT_din(35) when (SRAM_OE_B2 = '1') else 'Z';
|
480 |
|
|
|
481 |
|
|
|
482 |
|
|
---------------------------------
|
483 |
|
|
-- DATA OUT LINES
|
484 |
|
|
---------------------------------
|
485 |
|
|
ZBT_dout(0) <= SRAM_FLASH_D0;
|
486 |
|
|
ZBT_dout(1) <= SRAM_FLASH_D1;
|
487 |
|
|
ZBT_dout(2) <= SRAM_FLASH_D2;
|
488 |
|
|
ZBT_dout(3) <= SRAM_FLASH_D3;
|
489 |
|
|
ZBT_dout(4) <= SRAM_FLASH_D4;
|
490 |
|
|
ZBT_dout(5) <= SRAM_FLASH_D5;
|
491 |
|
|
ZBT_dout(6) <= SRAM_FLASH_D6;
|
492 |
|
|
ZBT_dout(7) <= SRAM_FLASH_D7;
|
493 |
|
|
ZBT_dout(8) <= SRAM_FLASH_D8;
|
494 |
|
|
ZBT_dout(9) <= SRAM_FLASH_D9;
|
495 |
|
|
ZBT_dout(10) <= SRAM_FLASH_D10;
|
496 |
|
|
ZBT_dout(11) <= SRAM_FLASH_D11;
|
497 |
|
|
ZBT_dout(12) <= SRAM_FLASH_D12;
|
498 |
|
|
ZBT_dout(13) <= SRAM_FLASH_D13;
|
499 |
|
|
ZBT_dout(14) <= SRAM_FLASH_D14;
|
500 |
|
|
ZBT_dout(15) <= SRAM_FLASH_D15;
|
501 |
|
|
ZBT_dout(16) <= SRAM_D16;
|
502 |
|
|
ZBT_dout(17) <= SRAM_D17;
|
503 |
|
|
ZBT_dout(18) <= SRAM_D18;
|
504 |
|
|
ZBT_dout(19) <= SRAM_D19;
|
505 |
|
|
ZBT_dout(20) <= SRAM_D20;
|
506 |
|
|
ZBT_dout(21) <= SRAM_D21;
|
507 |
|
|
ZBT_dout(22) <= SRAM_D22;
|
508 |
|
|
ZBT_dout(23) <= SRAM_D23;
|
509 |
|
|
ZBT_dout(24) <= SRAM_D24;
|
510 |
|
|
ZBT_dout(25) <= SRAM_D25;
|
511 |
|
|
ZBT_dout(26) <= SRAM_D26;
|
512 |
|
|
ZBT_dout(27) <= SRAM_D27;
|
513 |
|
|
ZBT_dout(28) <= SRAM_D28;
|
514 |
|
|
ZBT_dout(29) <= SRAM_D29;
|
515 |
|
|
ZBT_dout(30) <= SRAM_D30;
|
516 |
|
|
ZBT_dout(31) <= SRAM_D31;
|
517 |
|
|
ZBT_dout(32) <= SRAM_DQP0;
|
518 |
|
|
ZBT_dout(33) <= SRAM_DQP1;
|
519 |
|
|
ZBT_dout(34) <= SRAM_DQP2;
|
520 |
|
|
ZBT_dout(35) <= SRAM_DQP3;
|
521 |
|
|
|
522 |
|
|
|
523 |
|
|
---------------------------------
|
524 |
|
|
-- ADDRESS LINES
|
525 |
|
|
---------------------------------
|
526 |
|
|
SRAM_FLASH_A1 <= ZBT_addr(0);
|
527 |
|
|
SRAM_FLASH_A2 <= ZBT_addr(1);
|
528 |
|
|
SRAM_FLASH_A3 <= ZBT_addr(2);
|
529 |
|
|
SRAM_FLASH_A4 <= ZBT_addr(3);
|
530 |
|
|
SRAM_FLASH_A5 <= ZBT_addr(4);
|
531 |
|
|
SRAM_FLASH_A6 <= ZBT_addr(5);
|
532 |
|
|
SRAM_FLASH_A7 <= ZBT_addr(6);
|
533 |
|
|
SRAM_FLASH_A8 <= ZBT_addr(7);
|
534 |
|
|
SRAM_FLASH_A9 <= ZBT_addr(8);
|
535 |
|
|
SRAM_FLASH_A10 <= ZBT_addr(9);
|
536 |
|
|
SRAM_FLASH_A11 <= ZBT_addr(10);
|
537 |
|
|
SRAM_FLASH_A12 <= ZBT_addr(11);
|
538 |
|
|
SRAM_FLASH_A13 <= ZBT_addr(12);
|
539 |
|
|
SRAM_FLASH_A14 <= ZBT_addr(13);
|
540 |
|
|
SRAM_FLASH_A15 <= ZBT_addr(14);
|
541 |
|
|
SRAM_FLASH_A16 <= ZBT_addr(15);
|
542 |
|
|
SRAM_FLASH_A17 <= ZBT_addr(16);
|
543 |
|
|
SRAM_FLASH_A18 <= ZBT_addr(17);
|
544 |
|
|
|
545 |
|
|
end Behavioral;
|
546 |
|
|
|