1 |
2 |
tarookumic |
-----------------------------------------------------------------------------
|
2 |
|
|
-- This file is a part of the LEON VHDL model
|
3 |
|
|
-- Copyright (C) 1999 European Space Agency (ESA)
|
4 |
|
|
--
|
5 |
|
|
-- This program is free software; you can redistribute it and/or modify
|
6 |
|
|
-- it under the terms of the GNU General Public License as published by
|
7 |
|
|
-- the Free Software Foundation; either version 2 of the License, or
|
8 |
|
|
-- (at your option) any later version.
|
9 |
|
|
--
|
10 |
|
|
-- See the file COPYING for the full details of the license.
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
-----------------------------------------------------------------------------
|
14 |
|
|
-- Entity: tbgen
|
15 |
|
|
-- File: tbgen.vhd
|
16 |
|
|
-- Author: Jiri Gaisler - ESA/ESTEC
|
17 |
|
|
-- Description: Generic test bench for LEON. The test bench uses generate
|
18 |
|
|
-- statements to build a LEON system with the desired memory
|
19 |
|
|
-- size and data width.
|
20 |
|
|
------------------------------------------------------------------------------
|
21 |
|
|
-- Version control:
|
22 |
|
|
-- 11-08-1999: First implemetation
|
23 |
|
|
-- 26-09-1999: Release 1.0
|
24 |
|
|
------------------------------------------------------------------------------
|
25 |
|
|
|
26 |
|
|
library IEEE;
|
27 |
|
|
use IEEE.std_logic_1164.all;
|
28 |
|
|
use work.config.all;
|
29 |
|
|
use work.iface.all;
|
30 |
|
|
use work.leonlib.all;
|
31 |
|
|
use work.debug.all;
|
32 |
|
|
use STD.TEXTIO.all;
|
33 |
|
|
|
34 |
|
|
entity tbgen is
|
35 |
|
|
generic (
|
36 |
|
|
|
37 |
|
|
msg1 : string := "32 kbyte 32-bit rom, 0-ws";
|
38 |
|
|
msg2 : string := "2x128 kbyte 32-bit ram, 0-ws";
|
39 |
|
|
pcihost : boolean := false; -- be PCI host
|
40 |
|
|
DISASS : integer := 0; -- enable disassembly to stdout
|
41 |
|
|
clkperiod : integer := 20; -- system clock period
|
42 |
|
|
romfile : string := "tsource/rom.dat"; -- rom contents
|
43 |
|
|
ramfile : string := "tsource/ram.dat"; -- ram contents
|
44 |
|
|
sdramfile : string := "tsource/sdram.rec"; -- sdram contents
|
45 |
|
|
romwidth : integer := 32; -- rom data width (8/32)
|
46 |
|
|
romdepth : integer := 13; -- rom address depth
|
47 |
|
|
romtacc : integer := 10; -- rom access time (ns)
|
48 |
|
|
ramwidth : integer := 32; -- ram data width (8/16/32)
|
49 |
|
|
ramdepth : integer := 15; -- ram address depth
|
50 |
|
|
rambanks : integer := 2; -- number of ram banks
|
51 |
|
|
bytewrite : boolean := true; -- individual byte write strobes
|
52 |
|
|
ramtacc : integer := 10 -- ram access time (ns)
|
53 |
|
|
);
|
54 |
|
|
end;
|
55 |
|
|
|
56 |
|
|
architecture behav of tbgen is
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
component iram
|
60 |
|
|
generic (index : integer := 0; -- Byte lane (0 - 3)
|
61 |
|
|
Abits: Positive := 10; -- Default 10 address bits (1 Kbyte)
|
62 |
|
|
echk : integer := 0; -- Generate EDAC checksum
|
63 |
|
|
tacc : integer := 10; -- access time (ns)
|
64 |
|
|
fname : string := "ram.dat"); -- File to read from
|
65 |
|
|
port (
|
66 |
|
|
A : in std_logic_vector;
|
67 |
|
|
D : inout std_logic_vector(7 downto 0);
|
68 |
|
|
CE1 : in std_logic;
|
69 |
|
|
WE : in std_logic;
|
70 |
|
|
OE : in std_logic
|
71 |
|
|
|
72 |
|
|
); end component;
|
73 |
|
|
|
74 |
|
|
component testmod
|
75 |
|
|
port (
|
76 |
|
|
clk : in std_logic;
|
77 |
|
|
dsurx : in std_logic;
|
78 |
|
|
dsutx : out std_logic;
|
79 |
|
|
error : in std_logic;
|
80 |
|
|
iosn : in std_logic;
|
81 |
|
|
oen : in std_logic;
|
82 |
|
|
read : in std_logic;
|
83 |
|
|
writen : in std_logic;
|
84 |
|
|
brdyn : out std_logic;
|
85 |
|
|
bexcn : out std_logic;
|
86 |
|
|
address : in std_logic_vector(7 downto 0);
|
87 |
|
|
data : inout std_logic_vector(31 downto 0);
|
88 |
|
|
ioport : out std_logic_vector(15 downto 0)
|
89 |
|
|
);
|
90 |
|
|
end component;
|
91 |
|
|
|
92 |
|
|
component mt48lc16m16a2
|
93 |
|
|
generic (index : integer := 0; -- Byte lane (0 - 3)
|
94 |
|
|
fname : string := "tsrouce/sdram.rec"); -- File to read from
|
95 |
|
|
PORT (
|
96 |
|
|
Dq : INOUT STD_LOGIC_VECTOR (15 DOWNTO 0);
|
97 |
|
|
Addr : IN STD_LOGIC_VECTOR (12 DOWNTO 0);
|
98 |
|
|
Ba : IN STD_LOGIC_VECTOR (1 downto 0);
|
99 |
|
|
Clk : IN STD_LOGIC;
|
100 |
|
|
Cke : IN STD_LOGIC;
|
101 |
|
|
Cs_n : IN STD_LOGIC;
|
102 |
|
|
Ras_n : IN STD_LOGIC;
|
103 |
|
|
Cas_n : IN STD_LOGIC;
|
104 |
|
|
We_n : IN STD_LOGIC;
|
105 |
|
|
Dqm : IN STD_LOGIC_VECTOR (1 DOWNTO 0)
|
106 |
|
|
);
|
107 |
|
|
END component;
|
108 |
|
|
|
109 |
|
|
function to_xlhz(i : std_logic) return std_logic is
|
110 |
|
|
begin
|
111 |
|
|
case to_X01Z(i) is
|
112 |
|
|
when 'Z' => return('Z');
|
113 |
|
|
when '0' => return('L');
|
114 |
|
|
when '1' => return('H');
|
115 |
|
|
when others => return('X');
|
116 |
|
|
end case;
|
117 |
|
|
end;
|
118 |
|
|
|
119 |
|
|
TYPE logic_xlhz_table IS ARRAY (std_logic'LOW TO std_logic'HIGH) OF std_logic;
|
120 |
|
|
|
121 |
|
|
CONSTANT cvt_to_xlhz : logic_xlhz_table := (
|
122 |
|
|
'Z', -- 'U'
|
123 |
|
|
'Z', -- 'X'
|
124 |
|
|
'L', -- '0'
|
125 |
|
|
'H', -- '1'
|
126 |
|
|
'Z', -- 'Z'
|
127 |
|
|
'Z', -- 'W'
|
128 |
|
|
'Z', -- 'L'
|
129 |
|
|
'Z', -- 'H'
|
130 |
|
|
'Z' -- '-'
|
131 |
|
|
);
|
132 |
|
|
function buskeep (signal v : in std_logic_vector) return std_logic_vector is
|
133 |
|
|
variable res : std_logic_vector(v'range);
|
134 |
|
|
begin
|
135 |
|
|
for i in v'range loop res(i) := cvt_to_xlhz(v(i)); end loop;
|
136 |
|
|
return(res);
|
137 |
|
|
end;
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
signal clk : std_logic := '0';
|
141 |
|
|
signal Rst : std_logic := '0'; -- Reset
|
142 |
|
|
constant ct : integer := clkperiod/2;
|
143 |
|
|
|
144 |
|
|
signal address : std_logic_vector(27 downto 0);
|
145 |
|
|
signal data : std_logic_vector(31 downto 0);
|
146 |
|
|
|
147 |
|
|
signal ramsn : std_logic_vector(4 downto 0);
|
148 |
|
|
signal ramoen : std_logic_vector(4 downto 0);
|
149 |
|
|
signal rwen : std_logic_vector(3 downto 0);
|
150 |
|
|
signal rwenx : std_logic_vector(3 downto 0);
|
151 |
|
|
signal romsn : std_logic_vector(1 downto 0);
|
152 |
|
|
signal iosn : std_logic;
|
153 |
|
|
signal oen : std_logic;
|
154 |
|
|
signal read : std_logic;
|
155 |
|
|
signal writen : std_logic;
|
156 |
|
|
signal brdyn : std_logic;
|
157 |
|
|
signal bexcn : std_logic;
|
158 |
|
|
signal wdog : std_logic;
|
159 |
|
|
signal dsuen, dsutx, dsurx, dsubre, dsuact : std_logic;
|
160 |
|
|
signal test : std_logic;
|
161 |
|
|
signal error : std_logic;
|
162 |
|
|
signal pio : std_logic_vector(15 downto 0);
|
163 |
|
|
signal GND : std_logic := '0';
|
164 |
|
|
signal VCC : std_logic := '1';
|
165 |
|
|
signal NC : std_logic := 'Z';
|
166 |
|
|
signal clk2 : std_logic := '1';
|
167 |
|
|
|
168 |
|
|
signal pci_rst_n : std_logic := '0';
|
169 |
|
|
signal pci_clk : std_logic := '0';
|
170 |
|
|
signal pci_gnt_in_n: std_logic := '0';
|
171 |
|
|
signal pci_ad : std_logic_vector(31 downto 0);
|
172 |
|
|
signal pci_cbe_n : std_logic_vector(3 downto 0);
|
173 |
|
|
signal pci_frame_n : std_logic;
|
174 |
|
|
signal pci_irdy_n : std_logic;
|
175 |
|
|
signal pci_trdy_n : std_logic;
|
176 |
|
|
signal pci_devsel_n: std_logic;
|
177 |
|
|
signal pci_stop_n : std_logic;
|
178 |
|
|
signal pci_perr_n : std_logic;
|
179 |
|
|
signal pci_par : std_logic;
|
180 |
|
|
signal pci_req_n : std_logic;
|
181 |
|
|
signal pci_serr_n : std_logic;
|
182 |
|
|
signal pci_idsel_in: std_logic;
|
183 |
|
|
signal pci_lock_n : std_logic;
|
184 |
|
|
signal pci_host : std_logic;
|
185 |
|
|
signal pci_arb_req_n : std_logic_vector(0 to 3);
|
186 |
|
|
signal pci_arb_gnt_n : std_logic_vector(0 to 3);
|
187 |
|
|
signal power_state : std_logic_vector(1 downto 0);
|
188 |
|
|
signal pci_66 : std_logic;
|
189 |
|
|
signal pme_enable : std_logic;
|
190 |
|
|
signal pme_clear : std_logic;
|
191 |
|
|
signal pme_status : std_logic;
|
192 |
|
|
|
193 |
|
|
signal sdcke : std_logic_vector ( 1 downto 0); -- clk en
|
194 |
|
|
signal sdcsn : std_logic_vector ( 1 downto 0); -- chip sel
|
195 |
|
|
signal sdwen : std_logic; -- write en
|
196 |
|
|
signal sdrasn : std_logic; -- row addr stb
|
197 |
|
|
signal sdcasn : std_logic; -- col addr stb
|
198 |
|
|
signal sddqm : std_logic_vector ( 3 downto 0); -- data i/o mask
|
199 |
|
|
signal sdclk : std_logic;
|
200 |
|
|
signal plllock : std_logic;
|
201 |
|
|
|
202 |
|
|
signal emdio : std_logic;
|
203 |
|
|
signal etx_clk : std_logic := '0';
|
204 |
|
|
signal erx_clk : std_logic := '0';
|
205 |
|
|
signal erxd : std_logic_vector(3 downto 0);
|
206 |
|
|
signal erx_dv : std_logic;
|
207 |
|
|
signal erx_er : std_logic;
|
208 |
|
|
signal erx_col : std_logic;
|
209 |
|
|
signal erx_crs : std_logic;
|
210 |
|
|
signal etxd : std_logic_vector(3 downto 0);
|
211 |
|
|
signal etx_en : std_logic;
|
212 |
|
|
signal etx_er : std_logic;
|
213 |
|
|
signal emdc : std_logic;
|
214 |
|
|
signal emddis : std_logic;
|
215 |
|
|
signal epwrdwn : std_logic;
|
216 |
|
|
signal ereset : std_logic;
|
217 |
|
|
signal esleep : std_logic;
|
218 |
|
|
signal epause : std_logic;
|
219 |
|
|
|
220 |
|
|
begin
|
221 |
|
|
|
222 |
|
|
-- clock and reset
|
223 |
|
|
|
224 |
|
|
clk <= not clk after ct * 1 ns;
|
225 |
|
|
rst <= '0', '1' after clkperiod*10 * 1 ns;
|
226 |
|
|
dsuen <= '1'; dsubre <= '0';
|
227 |
|
|
|
228 |
|
|
etx_clk <= not etx_clk after 25 ns when ETHEN else '0';
|
229 |
|
|
erx_clk <= not etx_clk after 25 ns when ETHEN else '0';
|
230 |
|
|
emdio <= 'H'; erxd <= "0011"; erx_dv <= '0'; erx_er <= '0';
|
231 |
|
|
erx_col <= '0'; erx_crs <= '0';
|
232 |
|
|
|
233 |
|
|
pci_clk <= not pci_clk after 15 ns when PCIEN else '0';
|
234 |
|
|
pci_rst_n <= '0', '1' after clkperiod*10 * 1 ns;
|
235 |
|
|
pci_frame_n <= 'H';
|
236 |
|
|
pci_ad <= (others => 'H');
|
237 |
|
|
pci_cbe_n <= (others => 'H');
|
238 |
|
|
pci_par <= 'H';
|
239 |
|
|
pci_req_n <= 'H';
|
240 |
|
|
pci_idsel_in <= 'H';
|
241 |
|
|
pci_lock_n <= 'H';
|
242 |
|
|
pci_irdy_n <= 'H';
|
243 |
|
|
pci_trdy_n <= 'H';
|
244 |
|
|
pci_devsel_n <= 'H';
|
245 |
|
|
pci_stop_n <= 'H';
|
246 |
|
|
pci_perr_n <= 'H';
|
247 |
|
|
pci_serr_n <= 'H';
|
248 |
|
|
pci_host <= '1' when pcihost else '0';
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
-- processor (no PCI, no ethernet)
|
252 |
|
|
p0 : if not PCIEN and not ETHEN generate
|
253 |
|
|
leon0 : leon port map (rst, clk, sdclk, plllock,
|
254 |
|
|
|
255 |
|
|
error, address, data,
|
256 |
|
|
|
257 |
|
|
ramsn, ramoen, rwenx, romsn, iosn, oen, read, writen, brdyn,
|
258 |
|
|
bexcn, sdcke, sdcsn, sdwen, sdrasn, sdcasn, sddqm, sdclk,
|
259 |
|
|
pio, wdog, dsuen, dsutx, dsurx, dsubre, dsuact, test);
|
260 |
|
|
|
261 |
|
|
end generate;
|
262 |
|
|
|
263 |
|
|
-- processor (PCI)
|
264 |
|
|
p1 : if PCIEN and not ETHEN generate
|
265 |
|
|
leon0 : leon_pci
|
266 |
|
|
port map (rst, clk, sdclk, plllock,
|
267 |
|
|
|
268 |
|
|
error, address, data,
|
269 |
|
|
|
270 |
|
|
ramsn, ramoen, rwenx, romsn, iosn, oen, read, writen,
|
271 |
|
|
brdyn, bexcn,
|
272 |
|
|
sdcke, sdcsn, sdwen, sdrasn, sdcasn, sddqm, sdclk,
|
273 |
|
|
pio, wdog, dsuen, dsutx, dsurx, dsubre, dsuact, test,
|
274 |
|
|
pci_rst_n, pci_clk, pci_gnt_in_n, pci_idsel_in,
|
275 |
|
|
pci_lock_n, pci_ad, pci_cbe_n, pci_frame_n, pci_irdy_n,
|
276 |
|
|
pci_trdy_n, pci_devsel_n, pci_stop_n, pci_perr_n, pci_par,
|
277 |
|
|
pci_req_n, pci_serr_n, pci_host, pci_66, pci_arb_req_n,
|
278 |
|
|
pci_arb_gnt_n, power_state, pme_enable, pme_clear, pme_status );
|
279 |
|
|
|
280 |
|
|
end generate;
|
281 |
|
|
|
282 |
|
|
-- processor (PCI, ethernet)
|
283 |
|
|
p2 : if PCIEN and ETHEN generate
|
284 |
|
|
leon0 : leon_eth_pci port map (rst, clk, sdclk, plllock,
|
285 |
|
|
|
286 |
|
|
error, address, data,
|
287 |
|
|
|
288 |
|
|
ramsn, ramoen, rwenx, romsn, iosn, oen, read, writen, brdyn,
|
289 |
|
|
bexcn, sdcke, sdcsn, sdwen, sdrasn, sdcasn, sddqm, sdclk,
|
290 |
|
|
pio, wdog, dsuen, dsutx, dsurx, dsubre, dsuact, test,
|
291 |
|
|
pci_rst_n, pci_clk, pci_gnt_in_n, pci_idsel_in,
|
292 |
|
|
pci_lock_n, pci_ad, pci_cbe_n, pci_frame_n, pci_irdy_n,
|
293 |
|
|
pci_trdy_n, pci_devsel_n, pci_stop_n, pci_perr_n, pci_par,
|
294 |
|
|
pci_req_n, pci_serr_n, pci_host, pci_66, pci_arb_req_n,
|
295 |
|
|
pci_arb_gnt_n, power_state, pme_enable, pme_clear, pme_status,
|
296 |
|
|
emdio, etx_clk, erx_clk, erxd, erx_dv, erx_er, erx_col, erx_crs,
|
297 |
|
|
etxd, etx_en, etx_er, emdc,
|
298 |
|
|
emddis, epwrdwn, ereset, esleep, epause);
|
299 |
|
|
|
300 |
|
|
end generate;
|
301 |
|
|
-- processor (no PCI, ethernet)
|
302 |
|
|
p3 : if not PCIEN and ETHEN generate
|
303 |
|
|
leon0 : leon_eth port map (rst, clk, sdclk, plllock,
|
304 |
|
|
|
305 |
|
|
error, address, data,
|
306 |
|
|
|
307 |
|
|
ramsn, ramoen, rwenx, romsn, iosn, oen, read, writen, brdyn,
|
308 |
|
|
bexcn, sdcke, sdcsn, sdwen, sdrasn, sdcasn, sddqm, sdclk,
|
309 |
|
|
pio, wdog, dsuen, dsutx, dsurx, dsubre, dsuact,
|
310 |
|
|
emdio, etx_clk, erx_clk, erxd, erx_dv, erx_er, erx_col, erx_crs,
|
311 |
|
|
etxd, etx_en, etx_er, emdc,
|
312 |
|
|
emddis, epwrdwn, ereset, esleep, epause, test);
|
313 |
|
|
|
314 |
|
|
end generate;
|
315 |
|
|
-- write strobes
|
316 |
|
|
|
317 |
|
|
rwen <= rwenx when bytewrite else (rwenx(0) & rwenx(0) & rwenx(0) & rwenx(0));
|
318 |
|
|
-- 8-bit rom
|
319 |
|
|
|
320 |
|
|
rom8d : if romwidth = 8 generate
|
321 |
|
|
|
322 |
|
|
pio(1 downto 0) <= "LL"; -- 8-bit data bus
|
323 |
|
|
|
324 |
|
|
|
325 |
|
|
rom0 : iram
|
326 |
|
|
generic map (index => 0, abits => romdepth, echk => 2, tacc => romtacc,
|
327 |
|
|
fname => romfile)
|
328 |
|
|
port map (A => address(romdepth-1 downto 0), D => data(31 downto 24),
|
329 |
|
|
CE1 => romsn(0), WE => VCC, OE => oen);
|
330 |
|
|
|
331 |
|
|
|
332 |
|
|
rom2 : process (address, romsn, writen)
|
333 |
|
|
begin
|
334 |
|
|
if (writen and not romsn(1)) = '1' then
|
335 |
|
|
case address(1 downto 0) is
|
336 |
|
|
when "00" => data(31 downto 24) <= "00000001";
|
337 |
|
|
when "01" => data(31 downto 24) <= "00100011";
|
338 |
|
|
when "10" => data(31 downto 24) <= "01000101";
|
339 |
|
|
when others => data(31 downto 24) <= "01100111";
|
340 |
|
|
end case;
|
341 |
|
|
else data(31 downto 24) <= (others => 'Z'); end if;
|
342 |
|
|
end process;
|
343 |
|
|
|
344 |
|
|
end generate;
|
345 |
|
|
|
346 |
|
|
-- 16-bit rom
|
347 |
|
|
|
348 |
|
|
rom16d : if romwidth = 16 generate
|
349 |
|
|
|
350 |
|
|
pio(1 downto 0) <= "LH"; -- 16-bit data bus
|
351 |
|
|
|
352 |
|
|
romarr : for i in 0 to 1 generate
|
353 |
|
|
rom0 : iram
|
354 |
|
|
generic map (index => i, abits => romdepth, echk => 4, tacc => romtacc,
|
355 |
|
|
fname => romfile)
|
356 |
|
|
port map (A => address(romdepth downto 1),
|
357 |
|
|
D => data((31 - i*8) downto (24-i*8)), CE1 => romsn(0),
|
358 |
|
|
WE => VCC, OE => oen);
|
359 |
|
|
end generate;
|
360 |
|
|
|
361 |
|
|
rom2 : process (address, romsn, writen)
|
362 |
|
|
begin
|
363 |
|
|
if (writen and not romsn(1)) = '1' then
|
364 |
|
|
case address(1 downto 0) is
|
365 |
|
|
when "00" => data(31 downto 16) <= "0000000100100011";
|
366 |
|
|
when others => data(31 downto 16) <= "0100010101100111";
|
367 |
|
|
end case;
|
368 |
|
|
else data(31 downto 16) <= (others => 'Z'); end if;
|
369 |
|
|
end process;
|
370 |
|
|
|
371 |
|
|
end generate;
|
372 |
|
|
|
373 |
|
|
-- 32-bit rom
|
374 |
|
|
|
375 |
|
|
rom32d : if romwidth = 32 generate
|
376 |
|
|
|
377 |
|
|
pio(1 downto 0) <= "HH"; -- 32-bit data bus
|
378 |
|
|
|
379 |
|
|
romarr : for i in 0 to 3 generate
|
380 |
|
|
rom0 : iram
|
381 |
|
|
generic map (index => i, abits => romdepth, echk => 0, tacc => romtacc,
|
382 |
|
|
fname => romfile)
|
383 |
|
|
port map (A => address(romdepth+1 downto 2),
|
384 |
|
|
D => data((31 - i*8) downto (24-i*8)), CE1 => romsn(0),
|
385 |
|
|
WE => VCC, OE => oen);
|
386 |
|
|
end generate;
|
387 |
|
|
|
388 |
|
|
|
389 |
|
|
data(31 downto 0) <= "00000001001000110100010101100111" when (romsn(1) or not writen) = '0'
|
390 |
|
|
else (others => 'Z');
|
391 |
|
|
end generate;
|
392 |
|
|
|
393 |
|
|
-- 8-bit ram
|
394 |
|
|
|
395 |
|
|
ram8d : if ramwidth = 8 generate
|
396 |
|
|
|
397 |
|
|
ram0 : iram
|
398 |
|
|
generic map (index => 0, abits => ramdepth, echk => 2, tacc => ramtacc,
|
399 |
|
|
fname => ramfile)
|
400 |
|
|
port map (A => address(ramdepth-1 downto 0), D => data(31 downto 24),
|
401 |
|
|
CE1 => ramsn(0), WE => rwen(0), OE => ramoen(0));
|
402 |
|
|
|
403 |
|
|
end generate;
|
404 |
|
|
|
405 |
|
|
|
406 |
|
|
-- 16-bit ram
|
407 |
|
|
|
408 |
|
|
ram16d : if ramwidth = 16 generate
|
409 |
|
|
rambnk : for i in 0 to rambanks-1 generate
|
410 |
|
|
ramarr : for j in 0 to 1 generate
|
411 |
|
|
ram0 : iram
|
412 |
|
|
generic map (index => j, abits => ramdepth, echk => 4,
|
413 |
|
|
tacc => ramtacc, fname => ramfile)
|
414 |
|
|
port map (A => address(ramdepth downto 1),
|
415 |
|
|
D => data((31 - j*8) downto (24-j*8)), CE1 => ramsn(i),
|
416 |
|
|
WE => rwen(j), OE => ramoen(i));
|
417 |
|
|
end generate;
|
418 |
|
|
end generate;
|
419 |
|
|
end generate;
|
420 |
|
|
|
421 |
|
|
-- 32-bit ram
|
422 |
|
|
|
423 |
|
|
ram32d : if ramwidth = 32 generate
|
424 |
|
|
rambnk : for i in 0 to rambanks-1 generate
|
425 |
|
|
ramarr : for j in 0 to 3 generate
|
426 |
|
|
ram0 : iram
|
427 |
|
|
generic map (index => j, abits => ramdepth, echk => 0,
|
428 |
|
|
tacc => ramtacc, fname => ramfile)
|
429 |
|
|
port map (A => address(ramdepth+1 downto 2),
|
430 |
|
|
D => data((31 - j*8) downto (24-j*8)), CE1 => ramsn(i),
|
431 |
|
|
WE => rwen(j), OE => ramoen(i));
|
432 |
|
|
end generate;
|
433 |
|
|
|
434 |
|
|
|
435 |
|
|
end generate;
|
436 |
|
|
|
437 |
|
|
|
438 |
|
|
end generate;
|
439 |
|
|
|
440 |
|
|
-- boot message
|
441 |
|
|
|
442 |
|
|
bootmsg : process(rst)
|
443 |
|
|
begin
|
444 |
|
|
if rst'event and (rst = '1') then --'
|
445 |
|
|
print("LEON-2 generic testbench (leon2-"& LEON_VERSION & ")");
|
446 |
|
|
print("Bug reports to Jiri Gaisler, jiri@gaisler.com");
|
447 |
|
|
print("");
|
448 |
|
|
print("Testbench configuration:");
|
449 |
|
|
print(msg1); print(msg2); print("");
|
450 |
|
|
end if;
|
451 |
|
|
end process;
|
452 |
|
|
|
453 |
|
|
-- optional sdram
|
454 |
|
|
|
455 |
|
|
sdram : if SDRAMEN generate
|
456 |
|
|
u0: mt48lc16m16a2 generic map (index => 0, fname => sdramfile)
|
457 |
|
|
PORT MAP(
|
458 |
|
|
Dq => data(31 downto 16), Addr => address(14 downto 2),
|
459 |
|
|
Ba => address(16 downto 15), Clk => sdclk, Cke => sdcke(0),
|
460 |
|
|
Cs_n => sdcsn(0), Ras_n => sdrasn, Cas_n => sdcasn, We_n => sdwen,
|
461 |
|
|
Dqm => sddqm(3 downto 2));
|
462 |
|
|
u1: mt48lc16m16a2 generic map (index => 16, fname => sdramfile)
|
463 |
|
|
PORT MAP(
|
464 |
|
|
Dq => data(15 downto 0), Addr => address(14 downto 2),
|
465 |
|
|
Ba => address(16 downto 15), Clk => sdclk, Cke => sdcke(0),
|
466 |
|
|
Cs_n => sdcsn(0), Ras_n => sdrasn, Cas_n => sdcasn, We_n => sdwen,
|
467 |
|
|
Dqm => sddqm(1 downto 0));
|
468 |
|
|
u2: mt48lc16m16a2 generic map (index => 0, fname => sdramfile)
|
469 |
|
|
PORT MAP(
|
470 |
|
|
Dq => data(31 downto 16), Addr => address(14 downto 2),
|
471 |
|
|
Ba => address(16 downto 15), Clk => sdclk, Cke => sdcke(0),
|
472 |
|
|
Cs_n => sdcsn(1), Ras_n => sdrasn, Cas_n => sdcasn, We_n => sdwen,
|
473 |
|
|
Dqm => sddqm(3 downto 2));
|
474 |
|
|
u3: mt48lc16m16a2 generic map (index => 16, fname => sdramfile)
|
475 |
|
|
PORT MAP(
|
476 |
|
|
Dq => data(15 downto 0), Addr => address(14 downto 2),
|
477 |
|
|
Ba => address(16 downto 15), Clk => sdclk, Cke => sdcke(0),
|
478 |
|
|
Cs_n => sdcsn(1), Ras_n => sdrasn, Cas_n => sdcasn, We_n => sdwen,
|
479 |
|
|
Dqm => sddqm(1 downto 0));
|
480 |
|
|
|
481 |
|
|
end generate;
|
482 |
|
|
|
483 |
|
|
-- test module
|
484 |
|
|
|
485 |
|
|
testmod0 : testmod port map (clk, dsutx, dsurx, error, iosn, oen, read,
|
486 |
|
|
writen, brdyn, bexcn, address(7 downto 0), data , pio);
|
487 |
|
|
test <= '1' when DISASS > 0 else '0';
|
488 |
|
|
|
489 |
|
|
-- cross-strap UARTs
|
490 |
|
|
|
491 |
|
|
pio(14) <= to_XLHZ(pio(11)); -- RX1 <- TX2
|
492 |
|
|
pio(10) <= to_XLHZ(pio(15)); -- RX2 <- TX1
|
493 |
|
|
pio(12) <= to_XLHZ(pio(9)); -- CTS1 <- RTS2
|
494 |
|
|
pio(8) <= to_XLHZ(pio(13)); -- CTS2 <- RTS1
|
495 |
|
|
|
496 |
|
|
pio(15) <= 'H';
|
497 |
|
|
pio(13) <= 'H';
|
498 |
|
|
pio(11) <= 'H';
|
499 |
|
|
pio(9) <= 'H';
|
500 |
|
|
|
501 |
|
|
pio(2) <= 'H' when not bytewrite else 'L';
|
502 |
|
|
|
503 |
|
|
pio(3) <= wdog when WDOGEN else 'H'; -- WDOG output on IO3
|
504 |
|
|
-- pio(3) <= clk2; -- clk/2 as uart clock
|
505 |
|
|
-- clk2 <= not clk2 when rising_edge(clk) else clk2;
|
506 |
|
|
wdog <= 'H'; -- WDOG pull-up
|
507 |
|
|
error <= 'H'; -- ERROR pull-up
|
508 |
|
|
data <= (others => 'H');
|
509 |
|
|
|
510 |
|
|
data <= buskeep(data) after 5 ns;
|
511 |
|
|
|
512 |
|
|
|
513 |
|
|
-- waitstates
|
514 |
|
|
|
515 |
|
|
wsgen : process
|
516 |
|
|
begin
|
517 |
|
|
if (romtacc < (2*clkperiod - 20)) then pio(5 downto 4) <= "LL";
|
518 |
|
|
elsif (romtacc < (3*clkperiod - 20)) then pio(5 downto 4) <= "LH";
|
519 |
|
|
elsif (romtacc < (4*clkperiod - 20)) then pio(5 downto 4) <= "HL";
|
520 |
|
|
else pio(5 downto 4) <= "HH"; end if;
|
521 |
|
|
if (ramtacc < (2*clkperiod - 20)) then pio(7 downto 6) <= "LL";
|
522 |
|
|
elsif (ramtacc < (3*clkperiod - 20)) then pio(7 downto 6) <= "LH";
|
523 |
|
|
elsif (ramtacc < (4*clkperiod - 20)) then pio(7 downto 6) <= "HL";
|
524 |
|
|
else pio(7 downto 6) <= "HH"; end if;
|
525 |
|
|
wait on rst;
|
526 |
|
|
end process;
|
527 |
|
|
|
528 |
|
|
end ;
|
529 |
|
|
|