1 |
4 |
rudi |
--
|
2 |
|
|
-- Testbench for memory controller
|
3 |
|
|
--
|
4 |
|
|
-- Uses VGA controller as master device
|
5 |
|
|
--
|
6 |
|
|
--
|
7 |
|
|
|
8 |
|
|
library ieee;
|
9 |
|
|
use ieee.std_logic_1164.all;
|
10 |
|
|
use ieee.std_logic_arith.all;
|
11 |
|
|
|
12 |
|
|
entity testbench is
|
13 |
|
|
end entity;
|
14 |
|
|
|
15 |
|
|
architecture test of testbench is
|
16 |
|
|
--
|
17 |
|
|
-- component declarations
|
18 |
|
|
--
|
19 |
|
|
|
20 |
|
|
-- VHDL declaration of module mc_top
|
21 |
|
|
component mc_top is
|
22 |
|
|
port(
|
23 |
|
|
clk, rst : in std_logic;
|
24 |
|
|
|
25 |
|
|
----------------------------------------
|
26 |
|
|
-- WISHBONE SLAVE INTERFACE
|
27 |
|
|
wb_data_i : in std_logic_vector(31 downto 0);
|
28 |
|
|
wb_data_o : out std_logic_vector(31 downto 0);
|
29 |
|
|
wb_addr_i : in std_logic_vector(31 downto 0);
|
30 |
|
|
wb_sel_i : in std_logic_vector(3 downto 0);
|
31 |
|
|
wb_we_i : in std_logic;
|
32 |
|
|
wb_cyc_i : in std_logic;
|
33 |
|
|
wb_stb_i : in std_logic;
|
34 |
|
|
wb_ack_o : out std_logic;
|
35 |
|
|
wb_err_o : out std_logic;
|
36 |
|
|
|
37 |
|
|
----------------------------------------
|
38 |
|
|
-- Suspend Resume Interface
|
39 |
|
|
susp_req : in std_logic;
|
40 |
|
|
resume_req : in std_logic;
|
41 |
|
|
suspended : out std_logic;
|
42 |
|
|
|
43 |
|
|
-- POC
|
44 |
|
|
poc : out std_logic_vector(31 downto 0);
|
45 |
|
|
|
46 |
|
|
----------------------------------------
|
47 |
|
|
-- Memory Bus Signals
|
48 |
|
|
mc_clk : in std_logic;
|
49 |
|
|
mc_br : in std_logic;
|
50 |
|
|
mc_bg : out std_logic;
|
51 |
|
|
mc_ack : in std_logic;
|
52 |
|
|
mc_addr : out std_logic_vector(23 downto 0);
|
53 |
|
|
mc_data_i : in std_logic_vector(31 downto 0);
|
54 |
|
|
mc_data_o : out std_logic_vector(31 downto 0);
|
55 |
|
|
mc_dp_i : in std_logic_vector(3 downto 0);
|
56 |
|
|
mc_dp_o : out std_logic_vector(3 downto 0);
|
57 |
|
|
mc_data_oe : out std_logic;
|
58 |
|
|
mc_dqm : out std_logic_vector(3 downto 0);
|
59 |
|
|
\mc_oe_\ : out std_logic;
|
60 |
|
|
\mc_we_\ : out std_logic;
|
61 |
|
|
\mc_cas_\ : out std_logic;
|
62 |
|
|
\mc_ras_\ : out std_logic;
|
63 |
|
|
\mc_cke_\ : out std_logic;
|
64 |
|
|
\mc_cs_\ : out std_logic_vector(7 downto 0);
|
65 |
|
|
mc_sts : in std_logic;
|
66 |
|
|
\mc_rp_\ : out std_logic;
|
67 |
|
|
mc_vpen : out std_logic;
|
68 |
|
|
\mc_adsc_\ : out std_logic;
|
69 |
|
|
\mc_adv_\ : out std_logic;
|
70 |
|
|
mc_zz : out std_logic;
|
71 |
|
|
mc_c_oe : out std_logic
|
72 |
|
|
);
|
73 |
|
|
end component mc_top;
|
74 |
|
|
|
75 |
|
|
-- sdram (Micron)
|
76 |
|
|
component mt48lc2m32b2 is
|
77 |
|
|
generic(
|
78 |
|
|
addr_bits : natural := 11;
|
79 |
|
|
data_bits : natural := 32;
|
80 |
|
|
col_bits : natural := 8;
|
81 |
|
|
mem_sizes : natural := 524287
|
82 |
|
|
);
|
83 |
|
|
port(
|
84 |
|
|
dq : inout std_logic_vector(data_bits -1 downto 0);
|
85 |
|
|
|
86 |
|
|
addr : in std_logic_vector(addr_bits -1 downto 0);
|
87 |
|
|
ba : in std_logic_vector(1 downto 0);
|
88 |
|
|
|
89 |
|
|
clk : in std_logic;
|
90 |
|
|
cke : in std_logic;
|
91 |
|
|
cs_n : in std_logic;
|
92 |
|
|
|
93 |
|
|
ras_n : in std_logic;
|
94 |
|
|
cas_n : in std_logic;
|
95 |
|
|
we_n : in std_logic;
|
96 |
|
|
dqm : in std_logic_vector(3 downto 0)
|
97 |
|
|
);
|
98 |
|
|
end component mt48lc2m32b2;
|
99 |
|
|
|
100 |
|
|
-- sram (cypress Cy7C185-20)
|
101 |
|
|
component A8Kx8 is
|
102 |
|
|
generic (
|
103 |
|
|
Trc : TIME := 20 ns;
|
104 |
|
|
Taa : TIME := 20 ns;
|
105 |
|
|
Toha : TIME := 05 ns;
|
106 |
|
|
Tace : TIME := 20 ns;
|
107 |
|
|
Tdoe : TIME := 09 ns;
|
108 |
|
|
Thzoe: TIME := 08 ns;
|
109 |
|
|
Thzce: TIME := 08 ns;
|
110 |
|
|
Twc : TIME := 20 ns;
|
111 |
|
|
Tsce : TIME := 15 ns;
|
112 |
|
|
Taw : TIME := 15 ns;
|
113 |
|
|
Tha : TIME := 0 ns;
|
114 |
|
|
Tsa : TIME := 0 ns;
|
115 |
|
|
Tpwe : TIME := 15 ns;
|
116 |
|
|
Tsd : TIME := 10 ns;
|
117 |
|
|
Thd : TIME := 0 ns
|
118 |
|
|
);
|
119 |
|
|
port (
|
120 |
|
|
CE_b, WE_b, OE_n : IN Std_Logic;
|
121 |
|
|
A : IN Std_Logic_Vector(12 downto 0);
|
122 |
|
|
IO : INOUT Std_Logic_Vector(7 downto 0):=(others=>'Z')
|
123 |
|
|
);
|
124 |
|
|
end component A8Kx8;
|
125 |
|
|
|
126 |
|
|
-- vga controller
|
127 |
|
|
component VGA is
|
128 |
|
|
port (
|
129 |
|
|
CLK_I : in std_logic;
|
130 |
|
|
RST_I : in std_logic := '0';
|
131 |
|
|
NRESET : in std_logic := '1';
|
132 |
|
|
INTA_O : out std_logic;
|
133 |
|
|
|
134 |
|
|
-- slave signals
|
135 |
|
|
ADR_I : in unsigned(4 downto 2); -- only 32bit databus accesses supported
|
136 |
|
|
SDAT_I : in std_logic_vector(31 downto 0);
|
137 |
|
|
SDAT_O : out std_logic_vector(31 downto 0);
|
138 |
|
|
SEL_I : in std_logic_vector(3 downto 0);
|
139 |
|
|
WE_I : in std_logic;
|
140 |
|
|
STB_I : in std_logic;
|
141 |
|
|
CYC_I : in std_logic;
|
142 |
|
|
ACK_O : out std_logic;
|
143 |
|
|
ERR_O : out std_logic;
|
144 |
|
|
|
145 |
|
|
-- master signals
|
146 |
|
|
ADR_O : out unsigned(31 downto 2);
|
147 |
|
|
MDAT_I : in std_logic_vector(31 downto 0);
|
148 |
|
|
SEL_O : out std_logic_vector(3 downto 0);
|
149 |
|
|
WE_O : out std_logic;
|
150 |
|
|
STB_O : out std_logic;
|
151 |
|
|
CYC_O : out std_logic;
|
152 |
|
|
CAB_O : out std_logic;
|
153 |
|
|
ACK_I : in std_logic;
|
154 |
|
|
ERR_I : in std_logic;
|
155 |
|
|
|
156 |
|
|
-- VGA signals
|
157 |
|
|
PCLK : in std_logic; -- pixel clock
|
158 |
|
|
HSYNC : out std_logic; -- horizontal sync
|
159 |
|
|
VSYNC : out std_logic; -- vertical sync
|
160 |
|
|
CSYNC : out std_logic; -- composite sync
|
161 |
|
|
BLANK : out std_logic; -- blanking signal
|
162 |
|
|
R,G,B : out std_logic_vector(7 downto 0) -- RGB color signals
|
163 |
|
|
);
|
164 |
|
|
end component vga;
|
165 |
|
|
|
166 |
|
|
-- wishbone host. Testvector generator
|
167 |
|
|
component wb_host is
|
168 |
|
|
port(
|
169 |
|
|
clk_i : in std_logic;
|
170 |
|
|
rst_i : in std_logic;
|
171 |
|
|
|
172 |
|
|
cyc_o : out std_logic;
|
173 |
|
|
stb_o : out std_logic;
|
174 |
|
|
we_o : out std_logic;
|
175 |
|
|
adr_o : out std_logic_vector(31 downto 0);
|
176 |
|
|
dat_o : out std_logic_vector(31 downto 0);
|
177 |
|
|
dat_i : in std_logic_vector(31 downto 0);
|
178 |
|
|
sel_o : out std_logic_vector(3 downto 0);
|
179 |
|
|
ack_i : in std_logic;
|
180 |
|
|
err_i : in std_logic
|
181 |
|
|
);
|
182 |
|
|
end component wb_host;
|
183 |
|
|
|
184 |
|
|
--
|
185 |
|
|
-- signal declarations
|
186 |
|
|
--
|
187 |
|
|
signal clk, clk2, vga_clk : std_logic := '0'; -- initially clear clocks
|
188 |
|
|
signal rst, init : std_logic := '0'; -- reset signal
|
189 |
|
|
|
190 |
|
|
-- memory controller signals
|
191 |
|
|
signal mc_data_i, mc_data_o : std_logic_vector(31 downto 0); -- memory controller data-in/data-out signals
|
192 |
|
|
signal mc_data_oe : std_logic; -- memory controller data-lines tri-state control
|
193 |
|
|
signal mc_data : std_logic_vector(31 downto 0); -- memory controller data-lines (tri-state signals)
|
194 |
|
|
|
195 |
|
|
signal \mc_cs_\ : std_logic_vector(7 downto 0); -- memory controller chip-select outputs
|
196 |
|
|
|
197 |
|
|
signal \mc_oe_\ : std_logic; -- memory controller output_enable signal
|
198 |
|
|
|
199 |
|
|
signal \mc_ras_\, \mc_cas_\, \mc_cke_\, \mc_we_\ : std_logic; -- memory controller SDRAM control signals
|
200 |
|
|
signal mc_dqm : std_logic_vector(3 downto 0);
|
201 |
|
|
|
202 |
|
|
signal mc_addr : std_logic_vector(23 downto 0); -- memory controller address output
|
203 |
|
|
|
204 |
|
|
-- memory controller wishbone signals
|
205 |
|
|
signal mc_cyc_i, mc_stb_i, mc_we_i : std_logic;
|
206 |
|
|
signal mc_adr_i : std_logic_vector(31 downto 0);
|
207 |
|
|
signal mc_dat_o : std_logic_vector(31 downto 0);
|
208 |
|
|
signal mc_sel_i : std_logic_vector(3 downto 0);
|
209 |
|
|
signal mc_ack_o, mc_err_o : std_logic;
|
210 |
|
|
signal mc_ack_o_temp : std_logic;
|
211 |
|
|
|
212 |
|
|
-- memory controller additional signals
|
213 |
|
|
signal mc_susp_req, mc_resume_req : std_logic := '0';
|
214 |
|
|
signal mc_br, mc_ack, mc_sts : std_logic := '0';
|
215 |
|
|
signal mc_dp_i : std_logic_vector(3 downto 0);
|
216 |
|
|
|
217 |
|
|
-- vga wishbone signals
|
218 |
|
|
signal vga_cyc_o, vga_stb_o, vga_we_o, vga_ack_i : std_logic;
|
219 |
|
|
signal vga_adr_o : std_logic_vector(31 downto 2);
|
220 |
|
|
signal vga_dat_o : std_logic_vector(31 downto 0);
|
221 |
|
|
signal vga_sel_o : std_logic_vector(3 downto 0);
|
222 |
|
|
signal vga_stb_i, vga_ack_o, vga_err_o, vga_err_i : std_logic;
|
223 |
|
|
|
224 |
|
|
-- host wishbone signals
|
225 |
|
|
signal h_cyc_o, h_stb_o, h_we_o : std_logic;
|
226 |
|
|
signal h_adr_o : std_logic_vector(31 downto 0);
|
227 |
|
|
signal h_dat_o, h_dat_i : std_logic_vector(31 downto 0);
|
228 |
|
|
signal h_sel_o : std_logic_vector(3 downto 0);
|
229 |
|
|
signal h_ack_i, h_err_i : std_logic;
|
230 |
|
|
|
231 |
|
|
begin
|
232 |
|
|
|
233 |
|
|
-- generate clocks
|
234 |
|
|
clk_block: block
|
235 |
|
|
begin
|
236 |
|
|
process(clk)
|
237 |
|
|
begin
|
238 |
|
|
clk <= not clk after 2.5 ns; -- 200MHz wishbone clock
|
239 |
|
|
if (clk = '1') then
|
240 |
|
|
clk2 <= not clk2; -- after 0.5 ns; -- some delay
|
241 |
|
|
end if;
|
242 |
|
|
end process;
|
243 |
|
|
|
244 |
|
|
process(vga_clk)
|
245 |
|
|
begin
|
246 |
|
|
vga_clk <= not vga_clk after 12.5 ns; -- 40MHz vga clock
|
247 |
|
|
end process;
|
248 |
|
|
end block clk_block;
|
249 |
|
|
|
250 |
|
|
-- generate reset signal
|
251 |
|
|
gen_rst: process(init, rst)
|
252 |
|
|
begin
|
253 |
|
|
if (init = '0') then
|
254 |
|
|
rst <= '1' after 100 ns;
|
255 |
|
|
init <= '1';
|
256 |
|
|
end if;
|
257 |
|
|
end process gen_rst;
|
258 |
|
|
|
259 |
|
|
-- generate mini-TCOP
|
260 |
|
|
mini_tcop: block
|
261 |
|
|
signal sel_vga, dh_cyc_o : std_logic;
|
262 |
|
|
begin
|
263 |
|
|
process(clk)
|
264 |
|
|
begin
|
265 |
|
|
if (clk'event and clk = '1') then
|
266 |
|
|
sel_vga <= vga_cyc_o and not (h_cyc_o and dh_cyc_o and not sel_vga);
|
267 |
|
|
dh_cyc_o <= h_cyc_o;
|
268 |
|
|
end if;
|
269 |
|
|
end process;
|
270 |
|
|
|
271 |
|
|
mc_cyc_i <= vga_cyc_o or h_cyc_o;
|
272 |
|
|
mc_stb_i <= vga_stb_o when (sel_vga = '1') else h_stb_o;
|
273 |
|
|
mc_we_i <= vga_we_o when (sel_vga = '1') else h_we_o;
|
274 |
|
|
mc_adr_i <= (vga_adr_o & "00") when (sel_vga = '1') else h_adr_o;
|
275 |
|
|
mc_sel_i <= vga_sel_o when (sel_vga = '1') else h_sel_o;
|
276 |
|
|
|
277 |
|
|
vga_ack_i <= sel_vga and mc_ack_o;
|
278 |
|
|
vga_err_i <= sel_vga and mc_err_o;
|
279 |
|
|
|
280 |
|
|
h_ack_i <= vga_ack_o or (not sel_vga and mc_ack_o);
|
281 |
|
|
h_err_i <= vga_err_o or (not sel_vga and mc_err_o);
|
282 |
|
|
end block mini_tcop;
|
283 |
|
|
|
284 |
|
|
-- hookup device under test
|
285 |
|
|
dut: mc_top port map (clk => clk, rst => rst, mc_clk => clk2, mc_data_i => mc_data, mc_data_o => mc_data_o, mc_data_oe => mc_data_oe,
|
286 |
|
|
mc_addr => mc_addr, \mc_ras_\ => \mc_ras_\, \mc_cas_\ => \mc_cas_\, \mc_we_\ => \mc_we_\, \mc_cs_\ => \mc_cs_\, \mc_cke_\ => \mc_cke_\,
|
287 |
|
|
mc_dqm => mc_dqm, \mc_oe_\ => \mc_oe_\,
|
288 |
|
|
wb_data_i => h_dat_o, wb_data_o => mc_dat_o, wb_addr_i => mc_adr_i, wb_sel_i => mc_sel_i, wb_we_i => mc_we_i, wb_cyc_i => mc_cyc_i,
|
289 |
|
|
wb_stb_i => mc_stb_i, wb_ack_o => mc_ack_o, wb_err_o => mc_err_o,
|
290 |
|
|
susp_req => mc_susp_req, resume_req => mc_resume_req, mc_br => mc_br, mc_ack => mc_ack, mc_dp_i => mc_dp_i, mc_sts => mc_sts);
|
291 |
|
|
|
292 |
|
|
-- generate tri-state outputs for DUT
|
293 |
|
|
mc_data <= mc_data_o when (mc_data_oe = '1') else (others => 'L');
|
294 |
|
|
|
295 |
|
|
-- hookup sdram
|
296 |
|
|
sdram: mt48lc2m32b2 port map(clk => clk2, cke => \mc_cke_\, cs_n => \mc_cs_\(1), ras_n => \mc_ras_\, cas_n => \mc_cas_\, we_n => \mc_we_\,
|
297 |
|
|
dq => mc_data, dqm => mc_dqm, addr => mc_addr(10 downto 0), ba(0) => mc_addr(14), ba(1) => mc_addr(13) );
|
298 |
|
|
|
299 |
|
|
-- hookup srams
|
300 |
|
|
sram0: a8kx8 port map(ce_b => \mc_cs_\(2), we_b => \mc_we_\, oe_n => \mc_oe_\, A => mc_addr(12 downto 0), io => mc_data( 7 downto 0) );
|
301 |
|
|
sram1: a8kx8 port map(ce_b => \mc_cs_\(2), we_b => \mc_we_\, oe_n => \mc_oe_\, A => mc_addr(12 downto 0), io => mc_data(15 downto 8) );
|
302 |
|
|
sram2: a8kx8 port map(ce_b => \mc_cs_\(2), we_b => \mc_we_\, oe_n => \mc_oe_\, A => mc_addr(12 downto 0), io => mc_data(23 downto 16) );
|
303 |
|
|
sram3: a8kx8 port map(ce_b => \mc_cs_\(2), we_b => \mc_we_\, oe_n => \mc_oe_\, A => mc_addr(12 downto 0), io => mc_data(31 downto 24) );
|
304 |
|
|
|
305 |
|
|
-- hookup vga controller
|
306 |
|
|
vga_stb_i <= h_stb_o and h_adr_o(31) and not h_adr_o(30);
|
307 |
|
|
vga_core: vga port map(clk_i => clk, pclk => vga_clk, nreset => rst,
|
308 |
|
|
cyc_o => vga_cyc_o, stb_o => vga_stb_o, we_o => vga_we_o, std_logic_vector(adr_o) => vga_adr_o, sel_o => vga_sel_o, ack_i => mc_ack_o,
|
309 |
|
|
err_i => vga_err_i, mdat_i => mc_dat_o, cyc_i => h_cyc_o, stb_i => vga_stb_i, we_i => h_we_o, adr_i => unsigned(h_adr_o(4 downto 2)),
|
310 |
|
|
sel_i => h_sel_o, ack_o => vga_ack_o, err_o => vga_err_o, sdat_i => h_dat_o, sdat_o => vga_dat_o);
|
311 |
|
|
|
312 |
|
|
-- hookup wishbone host (testvector generator)
|
313 |
|
|
h_dat_i <= vga_dat_o when (h_adr_o(31 downto 30) = "10") else mc_dat_o;
|
314 |
|
|
host: wb_host port map (clk_i => clk, rst_i => rst, cyc_o => h_cyc_o, stb_o => h_stb_o, we_o => h_we_o, adr_o => h_adr_o, dat_o => h_dat_o,
|
315 |
|
|
dat_i => h_dat_i, sel_o => h_sel_o, ack_i => h_ack_i, err_i => h_err_i);
|
316 |
|
|
end architecture;
|
317 |
|
|
|
318 |
|
|
|
319 |
|
|
|
320 |
|
|
|
321 |
|
|
library ieee;
|
322 |
|
|
use ieee.std_logic_1164.all;
|
323 |
|
|
use ieee.std_logic_arith.all;
|
324 |
|
|
library std;
|
325 |
|
|
use std.standard.all;
|
326 |
|
|
|
327 |
|
|
entity wb_host is
|
328 |
|
|
port(
|
329 |
|
|
clk_i : in std_logic;
|
330 |
|
|
rst_i : in std_logic;
|
331 |
|
|
|
332 |
|
|
cyc_o : out std_logic;
|
333 |
|
|
stb_o : out std_logic;
|
334 |
|
|
we_o : out std_logic;
|
335 |
|
|
adr_o : out std_logic_vector(31 downto 0);
|
336 |
|
|
dat_o : out std_logic_vector(31 downto 0);
|
337 |
|
|
dat_i : in std_logic_vector(31 downto 0);
|
338 |
|
|
sel_o : out std_logic_vector(3 downto 0);
|
339 |
|
|
ack_i : in std_logic;
|
340 |
|
|
err_i : in std_logic
|
341 |
|
|
);
|
342 |
|
|
end entity wb_host;
|
343 |
|
|
|
344 |
|
|
architecture behavioral of wb_host is
|
345 |
|
|
-------------------------------------------
|
346 |
|
|
-- convert a std_logic value to a character
|
347 |
|
|
-------------------------------------------
|
348 |
|
|
type stdlogic_to_char_t is array(std_logic) of character;
|
349 |
|
|
constant to_char : stdlogic_to_char_t := (
|
350 |
|
|
'U' => 'U',
|
351 |
|
|
'X' => 'X',
|
352 |
|
|
'0' => '0',
|
353 |
|
|
'1' => '1',
|
354 |
|
|
'Z' => 'Z',
|
355 |
|
|
'W' => 'W',
|
356 |
|
|
'L' => 'L',
|
357 |
|
|
'H' => 'H',
|
358 |
|
|
'-' => '-');
|
359 |
|
|
|
360 |
|
|
-----------------------------------------
|
361 |
|
|
-- convert a std_logic_vector to a string
|
362 |
|
|
-----------------------------------------
|
363 |
|
|
function slv_to_string(inp : std_logic_vector) return string is
|
364 |
|
|
alias vec : std_logic_vector(1 to inp'length) is inp;
|
365 |
|
|
variable result : string(vec'range);
|
366 |
|
|
begin
|
367 |
|
|
for i in vec'range loop
|
368 |
|
|
result(i) := to_char(vec(i));
|
369 |
|
|
end loop;
|
370 |
|
|
return result;
|
371 |
|
|
end;
|
372 |
|
|
|
373 |
|
|
-- type declarations
|
374 |
|
|
type vector_type is
|
375 |
|
|
record
|
376 |
|
|
adr : std_logic_vector(31 downto 0); -- wishbone address output
|
377 |
|
|
we : std_logic; -- wishbone write enable output
|
378 |
|
|
dat : std_logic_vector(31 downto 0); -- wishbone data output (write) or input compare value (read)
|
379 |
|
|
sel : std_logic_vector(3 downto 0); -- wishbone byte select output
|
380 |
|
|
burst : std_logic; -- perform next cycle as part of a burst
|
381 |
|
|
stop : std_logic; -- last field, stop wishbone activities
|
382 |
|
|
end record;
|
383 |
|
|
|
384 |
|
|
type vector_list is array(0 to 102) of vector_type;
|
385 |
|
|
|
386 |
|
|
type states is (chk_stop, assert_cyc, gen_cycle);
|
387 |
|
|
|
388 |
|
|
-- signal declarations
|
389 |
|
|
signal state : states;
|
390 |
|
|
signal cnt : natural := 0;
|
391 |
|
|
signal cyc, stb : std_logic;
|
392 |
|
|
signal cyc_delay : natural := 0;
|
393 |
|
|
|
394 |
|
|
shared variable vectors : vector_list :=
|
395 |
|
|
(
|
396 |
|
|
-- program memory controller
|
397 |
|
|
(x"E0000008",'1',x"000000FF","1111",'0','0'), --0 program base address register
|
398 |
|
|
(x"E0000008",'0',x"000000FF","1111",'0','0'), -- verify written data
|
399 |
|
|
(x"E0000000",'1',x"61000400","1111",'0','0'), --2 memory controller CSR register
|
400 |
|
|
(x"E0000000",'0',x"61000400","1111",'0','0'), -- verify written data
|
401 |
|
|
(x"E0000008",'0',x"000000FF","1111",'0','0'), -- re-read BA_MASK (bug ???) => fixed
|
402 |
|
|
-- program SDRAM chip select
|
403 |
|
|
(x"E0000018",'1',x"00800421","1111",'0','0'), --5 program chip-select 1 config register (sdram, 32bit, 0x10000000)
|
404 |
|
|
(x"E0000018",'0',x"00800421","1111",'0','0'), -- verify written data
|
405 |
|
|
(x"E000001c",'1',x"07260232","1111",'0','0'), --7 program TMS1 register (bl=4, bt=seq, cl=3, wbl=1)
|
406 |
|
|
(x"E000001c",'0',x"07260232","1111",'0','0'), -- verify written data
|
407 |
|
|
|
408 |
|
|
-- write some data in sdrams
|
409 |
|
|
(x"10000000",'1',x"01234567","1111",'0','0'), --9 write data in sdram
|
410 |
|
|
(x"E0000018",'1',x"00800421","1111",'0','0'), --5 program chip-select 1 config register (sdram, 32bit, 0x10000000)
|
411 |
|
|
(x"E0000018",'0',x"00800421","1111",'0','0'), -- verify written data
|
412 |
|
|
(x"E000001c",'1',x"07260232","1111",'0','0'), --7 program TMS1 register (bl=4, bt=seq, cl=3, wbl=1)
|
413 |
|
|
(x"E000001c",'0',x"07260232","1111",'0','0'), -- verify written data
|
414 |
|
|
|
415 |
|
|
(x"10000004",'1',x"89abcdef","1111",'0','0'),
|
416 |
|
|
(x"10000008",'1',x"00112233","1111",'0','0'),
|
417 |
|
|
(x"1000000C",'1',x"44556677","1111",'0','0'),
|
418 |
|
|
(x"10000010",'1',x"8899aabb","1111",'0','0'),
|
419 |
|
|
(x"10000014",'1',x"ccddeeff","1111",'0','0'),
|
420 |
|
|
|
421 |
|
|
(x"10000000",'0',x"01234567","1111",'0','0'), --15 verify data in sdram
|
422 |
|
|
(x"10000004",'0',x"89abcdef","1111",'1','0'),
|
423 |
|
|
(x"10000008",'0',x"00112233","1111",'1','0'),
|
424 |
|
|
(x"1000000C",'0',x"44556677","1111",'1','0'),
|
425 |
|
|
(x"10000010",'0',x"8899aabb","1111",'1','0'),
|
426 |
|
|
(x"10000014",'0',x"ccddeeff","1111",'1','0'),
|
427 |
|
|
|
428 |
|
|
-- write more data in sdrams (different column)
|
429 |
|
|
(x"10000200",'1',x"01234567","1111",'0','0'), --21 write data in sdram
|
430 |
|
|
(x"10000204",'1',x"89abcdef","1111",'0','0'),
|
431 |
|
|
(x"10000208",'1',x"00112233","1111",'0','0'),
|
432 |
|
|
(x"1000020C",'1',x"44556677","1111",'0','0'),
|
433 |
|
|
(x"10000210",'1',x"8899aabb","1111",'0','0'),
|
434 |
|
|
(x"10000214",'1',x"ccddeeff","1111",'0','0'),
|
435 |
|
|
|
436 |
|
|
(x"10000200",'0',x"01234567","1111",'0','0'), --27 verify data in sdram
|
437 |
|
|
(x"10000204",'0',x"89abcdef","1111",'1','0'),
|
438 |
|
|
(x"10000208",'0',x"00112233","1111",'1','0'),
|
439 |
|
|
(x"1000020C",'0',x"44556677","1111",'1','0'),
|
440 |
|
|
(x"10000210",'0',x"8899aabb","1111",'1','0'),
|
441 |
|
|
(x"10000214",'0',x"ccddeeff","1111",'1','0'),
|
442 |
|
|
|
443 |
|
|
-- write to another bank in sdram memory (BAS = 0)
|
444 |
|
|
(x"10000400",'1',x"01234567","1111",'0','0'), --33 write data in sdram
|
445 |
|
|
(x"10000404",'1',x"89abcdef","1111",'0','0'),
|
446 |
|
|
(x"10000408",'1',x"00112233","1111",'0','0'),
|
447 |
|
|
(x"1000040C",'1',x"44556677","1111",'0','0'),
|
448 |
|
|
(x"10000410",'1',x"8899aabb","1111",'0','0'),
|
449 |
|
|
(x"10000414",'1',x"ccddeeff","1111",'0','0'),
|
450 |
|
|
|
451 |
|
|
(x"10000400",'0',x"01234567","1111",'0','0'), --39 verify data in sdram
|
452 |
|
|
(x"10000404",'0',x"89abcdef","1111",'1','0'),
|
453 |
|
|
(x"10000408",'0',x"00112233","1111",'1','0'),
|
454 |
|
|
(x"1000040C",'0',x"44556677","1111",'1','0'),
|
455 |
|
|
(x"10000410",'0',x"8899aabb","1111",'1','0'),
|
456 |
|
|
(x"10000414",'0',x"ccddeeff","1111",'1','0'),
|
457 |
|
|
|
458 |
|
|
-- program SRAM timing register
|
459 |
|
|
(x"E0000024",'1',x"00001201","1111",'0','0'), --45 program TMS2 register (Twwd=5(10)ns, Twd=0(0)ns, Twpw=15(20)ns, Trdz=8(10)ns, Trdv=20(20)ns read after 30ns)
|
460 |
|
|
(x"E0000024",'0',x"00001201","1111",'0','0'), -- verify written data
|
461 |
|
|
|
462 |
|
|
-- program SRAM chip select for 32bit wide databus
|
463 |
|
|
(x"E0000020",'1',x"00810025","1111",'0','0'), --47 program chip-selec2 2 config register (sram, 32bit, 0x10200000)
|
464 |
|
|
(x"E0000020",'0',x"00810025","1111",'0','0'), -- verify written data
|
465 |
|
|
|
466 |
|
|
-- write some data in sram
|
467 |
|
|
(x"10200000",'1',x"a5a5a5a5","1111",'0','0'), --49 write data in srams
|
468 |
|
|
(x"10200004",'1',x"5a5a5a5a","1111",'0','0'),
|
469 |
|
|
(x"10200008",'1',x"00112233","1111",'0','0'),
|
470 |
|
|
|
471 |
|
|
-- verify data written
|
472 |
|
|
(x"10200000",'0',x"a5a5a5a5","1111",'0','0'), --52 write data in srams
|
473 |
|
|
(x"10200004",'0',x"5a5a5a5a","1111",'0','0'),
|
474 |
|
|
(x"10200008",'0',x"00112233","1111",'0','0'),
|
475 |
|
|
|
476 |
|
|
-- program SRAM chip select for 16bit wide databus
|
477 |
|
|
(x"E0000020",'1',x"00810015","1111",'0','0'), --55 program chip-selec2 2 config register (sram, 16bit, 0x10200000)
|
478 |
|
|
(x"E0000020",'0',x"00810015","1111",'0','0'), -- verify written data
|
479 |
|
|
|
480 |
|
|
-- write some data in sram
|
481 |
|
|
(x"10200000",'1',x"00005a5a","1111",'0','0'), --57 write data in srams
|
482 |
|
|
(x"10200002",'1',x"00005a5a","1111",'0','0'),
|
483 |
|
|
(x"10200004",'1',x"0000a5a5","1111",'0','0'),
|
484 |
|
|
(x"10200006",'1',x"0000a5a5","1111",'0','0'),
|
485 |
|
|
(x"10200008",'1',x"00005566","1111",'0','0'),
|
486 |
|
|
(x"1020000A",'1',x"00003344","1111",'0','0'),
|
487 |
|
|
|
488 |
|
|
-- verify data written
|
489 |
|
|
(x"10200000",'0',x"5a5a5a5a","1111",'0','0'), --63 write data in srams
|
490 |
|
|
(x"10200004",'0',x"a5a5a5a5","1111",'0','0'),
|
491 |
|
|
(x"10200008",'0',x"33445566","1111",'0','0'),
|
492 |
|
|
|
493 |
|
|
-- program SRAM chip select for 8bit wide databus
|
494 |
|
|
(x"E0000020",'1',x"00810005","1111",'0','0'), --66 program chip-selec2 2 config register (sram, 8bit, 0x10200000)
|
495 |
|
|
(x"E0000020",'0',x"00810005","1111",'0','0'), -- verify written data
|
496 |
|
|
|
497 |
|
|
|
498 |
|
|
--write some data in srams
|
499 |
|
|
(x"10200000",'1',x"00000003","1111",'0','0'), --68 write data in srams (8bit srams; for write only single access is supported)
|
500 |
|
|
(x"10200001",'1',x"00000002","1111",'0','0'),
|
501 |
|
|
(x"10200002",'1',x"00000001","1111",'0','0'),
|
502 |
|
|
(x"10200003",'1',x"00000000","1111",'0','0'),
|
503 |
|
|
(x"10200004",'1',x"00000006","1111",'0','0'), --72
|
504 |
|
|
(x"10200005",'1',x"00000005","1111",'0','0'),
|
505 |
|
|
(x"10200006",'1',x"00000004","1111",'0','0'),
|
506 |
|
|
(x"10200007",'1',x"00000000","1111",'0','0'),
|
507 |
|
|
(x"1020008C",'1',x"00000009","1111",'0','0'), --76
|
508 |
|
|
(x"1020008D",'1',x"00000008","1111",'0','0'),
|
509 |
|
|
(x"1020008E",'1',x"00000007","1111",'0','0'),
|
510 |
|
|
(x"1020008F",'1',x"00000000","1111",'0','0'),
|
511 |
|
|
(x"10200114",'1',x"0000000c","1111",'0','0'), --80
|
512 |
|
|
(x"10200115",'1',x"0000000b","1111",'0','0'),
|
513 |
|
|
(x"10200116",'1',x"0000000a","1111",'0','0'),
|
514 |
|
|
(x"10200117",'1',x"00000000","1111",'0','0'),
|
515 |
|
|
(x"1020019C",'1',x"0000000f","1111",'0','0'), --84
|
516 |
|
|
(x"1020019D",'1',x"0000000e","1111",'0','0'),
|
517 |
|
|
(x"1020019E",'1',x"0000000d","1111",'0','0'),
|
518 |
|
|
(x"1020019F",'1',x"00000000","1111",'0','0'),
|
519 |
|
|
|
520 |
|
|
(x"10200000",'0',x"00010203","1111",'0','0'), --88 verify written data (read as 32bit data)
|
521 |
|
|
(x"10200004",'0',x"00040506","1111",'0','0'),
|
522 |
|
|
(x"1020008C",'0',x"00070809","1111",'0','0'),
|
523 |
|
|
(x"10200114",'0',x"000a0b0c","1111",'0','0'),
|
524 |
|
|
(x"1020019C",'0',x"000d0e0f","1111",'0','0'),
|
525 |
|
|
|
526 |
|
|
-- program vga controller
|
527 |
|
|
(x"80000008",'1',x"04090018","1111",'0','0'), --93 program horizontal timing register
|
528 |
|
|
(x"8000000c",'1',x"05010002","1111",'0','0'), -- program vertical timing register
|
529 |
|
|
(x"80000010",'1',x"00640064","1111",'0','0'), -- program horizontal/vertical length register (100x100 pixels)
|
530 |
|
|
(x"80000014",'1',x"10000000","1111",'0','0'), -- program video base address 0 register (sdram)
|
531 |
|
|
(x"8000001c",'1',x"10200000","1111",'0','0'), -- program color lookup table (sram)
|
532 |
|
|
(x"80000000",'1',x"00000901","1111",'0','0') --98 program control register (enable video system)
|
533 |
|
|
|
534 |
|
|
-- end list
|
535 |
|
|
);
|
536 |
|
|
|
537 |
|
|
begin
|
538 |
|
|
process(clk_i, cnt, cyc_delay, ack_i, err_i)
|
539 |
|
|
variable nxt_state : states;
|
540 |
|
|
variable icnt : natural;
|
541 |
|
|
variable icyc_delay : natural;
|
542 |
|
|
begin
|
543 |
|
|
|
544 |
|
|
nxt_state := state;
|
545 |
|
|
icnt := cnt;
|
546 |
|
|
icyc_delay := cyc_delay;
|
547 |
|
|
|
548 |
|
|
case state is
|
549 |
|
|
when chk_stop =>
|
550 |
|
|
cyc <= '0'; -- no valid bus-cycle
|
551 |
|
|
stb <= '0'; -- disable strobe output
|
552 |
|
|
-- if (vectors(cnt).stop = '0') then
|
553 |
|
|
if (cnt /= vectors'high) then
|
554 |
|
|
cyc <= '1';
|
555 |
|
|
|
556 |
|
|
if (cyc_delay > 0) then
|
557 |
|
|
nxt_state := assert_cyc;
|
558 |
|
|
stb <= '0';
|
559 |
|
|
else
|
560 |
|
|
nxt_state := gen_cycle;
|
561 |
|
|
stb <= '1';
|
562 |
|
|
end if;
|
563 |
|
|
else
|
564 |
|
|
if (cyc_delay = 0) then
|
565 |
|
|
icyc_delay := 1;
|
566 |
|
|
icnt := 0; -- start testbench again, this time with a delay between STB and CYC assertion
|
567 |
|
|
end if;
|
568 |
|
|
end if;
|
569 |
|
|
|
570 |
|
|
when assert_cyc =>
|
571 |
|
|
cyc <= '1';
|
572 |
|
|
stb <= '1';
|
573 |
|
|
nxt_state := gen_cycle;
|
574 |
|
|
|
575 |
|
|
when gen_cycle =>
|
576 |
|
|
cyc <= '1';
|
577 |
|
|
stb <= '1';
|
578 |
|
|
|
579 |
|
|
if (ack_i = '1') or (err_i = '1') then
|
580 |
|
|
|
581 |
|
|
icnt := cnt +1;
|
582 |
|
|
if (cnt /= vectors'high) and (vectors(icnt).burst = '1') then
|
583 |
|
|
nxt_state := gen_cycle;
|
584 |
|
|
cyc <= '1';
|
585 |
|
|
stb <= '1';
|
586 |
|
|
else
|
587 |
|
|
nxt_state := chk_stop;
|
588 |
|
|
cyc <= '0';
|
589 |
|
|
stb <= '0';
|
590 |
|
|
end if;
|
591 |
|
|
|
592 |
|
|
if (err_i = '1') then
|
593 |
|
|
if (clk_i'event and clk_i = '1') then -- display warning only at rising edge of clock
|
594 |
|
|
-- report ("ERR_I asserted at vectorno. ")& cnt
|
595 |
|
|
-- severity err0r;
|
596 |
|
|
report ("ERR_I asserted at vectorno. ") severity error;
|
597 |
|
|
end if;
|
598 |
|
|
end if;
|
599 |
|
|
|
600 |
|
|
if (vectors(cnt).we = '0') then
|
601 |
|
|
if (vectors(cnt).dat /= dat_i) then
|
602 |
|
|
if (clk_i'event and clk_i = '1') then -- display warning only at rising edge of clock
|
603 |
|
|
report "DAT_I not equal to compare value. Expected " & slv_to_string(vectors(cnt).dat) & " received " & slv_to_string(dat_i)
|
604 |
|
|
severity error;
|
605 |
|
|
end if;
|
606 |
|
|
end if;
|
607 |
|
|
end if;
|
608 |
|
|
end if;
|
609 |
|
|
end case;
|
610 |
|
|
|
611 |
|
|
|
612 |
|
|
if (clk_i'event and clk_i = '1') then
|
613 |
|
|
if (rst_i = '0') then
|
614 |
|
|
state <= chk_stop;
|
615 |
|
|
cyc_o <= '0';
|
616 |
|
|
stb_o <= '0';
|
617 |
|
|
adr_o <= (others => 'X');
|
618 |
|
|
dat_o <= (others => 'X');
|
619 |
|
|
we_o <= 'X';
|
620 |
|
|
sel_o <= (others => 'X');
|
621 |
|
|
else
|
622 |
|
|
state <= nxt_state;
|
623 |
|
|
cyc_o <= cyc;
|
624 |
|
|
stb_o <= stb;
|
625 |
|
|
|
626 |
|
|
if (cyc = '1') then
|
627 |
|
|
adr_o <= vectors(icnt).adr;
|
628 |
|
|
dat_o <= vectors(icnt).dat;
|
629 |
|
|
we_o <= vectors(icnt).we;
|
630 |
|
|
sel_o <= vectors(icnt).sel;
|
631 |
|
|
else
|
632 |
|
|
adr_o <= (others => 'X');
|
633 |
|
|
dat_o <= (others => 'X');
|
634 |
|
|
we_o <= 'X';
|
635 |
|
|
sel_o <= (others => 'X');
|
636 |
|
|
end if;
|
637 |
|
|
end if;
|
638 |
|
|
|
639 |
|
|
cnt <= icnt;
|
640 |
|
|
cyc_delay <= icyc_delay;
|
641 |
|
|
end if;
|
642 |
|
|
end process;
|
643 |
|
|
|
644 |
|
|
-- fetch vector field
|
645 |
|
|
-- check stop-bit
|
646 |
|
|
-- if not(stop) generate wishbone bus-cycle
|
647 |
|
|
-- wait for ack/err
|
648 |
|
|
-- if (err) generate message
|
649 |
|
|
-- if (read) compare dat_i and vector field dat_i
|
650 |
|
|
-- if not equal generate message
|
651 |
|
|
end architecture behavioral;
|
652 |
|
|
|
653 |
|
|
|
654 |
|
|
|