1 |
2 |
tobil |
--------------------------------------------------------------
|
2 |
|
|
-- Simple testbench for AVR CM4 core running program_a.dec,
|
3 |
|
|
-- program_b.dec, program_c.dec and program_d.dec
|
4 |
|
|
--------------------------------------------------------------
|
5 |
|
|
LIBRARY IEEE;
|
6 |
|
|
USE IEEE.std_logic_1164.all;
|
7 |
|
|
USE IEEE.std_logic_arith.all;
|
8 |
|
|
USE IEEE.std_logic_textio.all;
|
9 |
|
|
USE std.textio.all;
|
10 |
|
|
USE WORK.all;
|
11 |
|
|
LIBRARY STD;
|
12 |
|
|
USE STD.TEXTIO.ALL;
|
13 |
|
|
|
14 |
|
|
entity avr_cm4_test is
|
15 |
|
|
end avr_cm4_test;
|
16 |
|
|
|
17 |
|
|
architecture behavioral of avr_cm4_test is
|
18 |
|
|
|
19 |
|
|
constant MAX_ROM_SIZE : positive := 512;
|
20 |
|
|
constant MAX_RAM_SIZE : positive := 65536;
|
21 |
|
|
file inFile_a : Text open read_mode is "program_a.dec";
|
22 |
|
|
file inFile_b : Text open read_mode is "program_b.dec";
|
23 |
|
|
file inFile_c : Text open read_mode is "program_c.dec";
|
24 |
|
|
file inFile_d : Text open read_mode is "program_d.dec";
|
25 |
|
|
|
26 |
|
|
signal system_clk : std_logic;
|
27 |
|
|
signal system_reset : Std_logic := '0';
|
28 |
|
|
signal cp2 : std_logic;
|
29 |
|
|
signal cp2_cml_1 : std_logic;
|
30 |
|
|
signal cp2_cml_2 : std_logic;
|
31 |
|
|
signal cp2_cml_3 : std_logic;
|
32 |
|
|
signal cmls : integer range 0 to 3 := 3;
|
33 |
|
|
signal cml0_clk : std_logic;
|
34 |
|
|
signal cml1_clk : std_logic;
|
35 |
|
|
signal cml2_clk : std_logic;
|
36 |
|
|
signal cml3_clk : std_logic;
|
37 |
|
|
signal cml0_reset : std_logic := '0';
|
38 |
|
|
signal cml1_reset : std_logic := '0';
|
39 |
|
|
signal cml2_reset : std_logic := '0';
|
40 |
|
|
signal cml3_reset : std_logic := '0';
|
41 |
|
|
signal disable_second : std_logic;
|
42 |
|
|
|
43 |
|
|
signal core_pc_0 : std_logic_vector (15 downto 0);
|
44 |
|
|
signal core_pc_1 : std_logic_vector (15 downto 0);
|
45 |
|
|
signal core_pc_2 : std_logic_vector (15 downto 0);
|
46 |
|
|
signal core_pc_3 : std_logic_vector (15 downto 0);
|
47 |
|
|
|
48 |
|
|
signal ireset : std_logic;
|
49 |
|
|
signal gnd : std_logic;
|
50 |
|
|
signal vcc : std_logic;
|
51 |
|
|
signal core_pc : std_logic_vector (15 downto 0);
|
52 |
|
|
signal core_inst : std_logic_vector (15 downto 0);
|
53 |
|
|
signal core_adr : std_logic_vector (5 downto 0);
|
54 |
|
|
signal core_iore : std_logic;
|
55 |
|
|
signal core_iowe : std_logic;
|
56 |
|
|
signal core_ramadr : std_logic_vector (15 downto 0);
|
57 |
|
|
signal core_ramadr_0 : std_logic_vector (15 downto 0);
|
58 |
|
|
signal core_ramadr_1 : std_logic_vector (15 downto 0);
|
59 |
|
|
signal core_ramadr_2 : std_logic_vector (15 downto 0);
|
60 |
|
|
signal core_ramadr_3 : std_logic_vector (15 downto 0);
|
61 |
|
|
signal core_ramre : std_logic;
|
62 |
|
|
signal core_ramre_0 : std_logic;
|
63 |
|
|
signal core_ramre_1 : std_logic;
|
64 |
|
|
signal core_ramre_2 : std_logic;
|
65 |
|
|
signal core_ramre_3 : std_logic;
|
66 |
|
|
signal core_ramwe : std_logic;
|
67 |
|
|
signal core_ramwe_0 : std_logic;
|
68 |
|
|
signal core_ramwe_1 : std_logic;
|
69 |
|
|
signal core_ramwe_2 : std_logic;
|
70 |
|
|
signal core_ramwe_3 : std_logic;
|
71 |
|
|
signal core_cpuwait : std_logic;
|
72 |
|
|
signal core_dbusin : std_logic_vector (7 downto 0);
|
73 |
|
|
signal core_dbusout : std_logic_vector (7 downto 0);
|
74 |
|
|
signal core_irqlines : std_logic_vector(22 downto 0);
|
75 |
|
|
signal core_irqack : std_logic;
|
76 |
|
|
signal core_irqackad : std_logic_vector(4 downto 0);
|
77 |
|
|
signal sleepi : std_logic;
|
78 |
|
|
signal irqok : std_logic;
|
79 |
|
|
signal globint : std_logic;
|
80 |
|
|
signal core_wdri : std_logic;
|
81 |
|
|
|
82 |
|
|
component AVR_Core is port(
|
83 |
|
|
--Clock and reset
|
84 |
|
|
cp2 : in std_logic;
|
85 |
|
|
cp2en : in std_logic;
|
86 |
|
|
ireset : in std_logic;
|
87 |
|
|
-- JTAG OCD support
|
88 |
|
|
valid_instr : out std_logic;
|
89 |
|
|
insert_nop : in std_logic;
|
90 |
|
|
block_irq : in std_logic;
|
91 |
|
|
change_flow : out std_logic;
|
92 |
|
|
-- Program Memory
|
93 |
|
|
pc : out std_logic_vector(15 downto 0);
|
94 |
|
|
inst : in std_logic_vector(15 downto 0);
|
95 |
|
|
-- I/O control
|
96 |
|
|
adr : out std_logic_vector(5 downto 0);
|
97 |
|
|
iore : out std_logic;
|
98 |
|
|
iowe : out std_logic;
|
99 |
|
|
-- Data memory control
|
100 |
|
|
ramadr : out std_logic_vector(15 downto 0);
|
101 |
|
|
ramre : out std_logic;
|
102 |
|
|
ramwe : out std_logic;
|
103 |
|
|
cpuwait : in std_logic;
|
104 |
|
|
-- Data paths
|
105 |
|
|
dbusin : in std_logic_vector(7 downto 0);
|
106 |
|
|
dbusout : out std_logic_vector(7 downto 0);
|
107 |
|
|
-- Interrupt
|
108 |
|
|
irqlines : in std_logic_vector(22 downto 0);
|
109 |
|
|
irqack : out std_logic;
|
110 |
|
|
irqackad : out std_logic_vector(4 downto 0);
|
111 |
|
|
--Sleep Control
|
112 |
|
|
sleepi : out std_logic;
|
113 |
|
|
irqok : out std_logic;
|
114 |
|
|
globint : out std_logic;
|
115 |
|
|
--Watchdog
|
116 |
|
|
wdri : out std_logic);
|
117 |
|
|
end component;
|
118 |
|
|
|
119 |
|
|
component AVR_Core_cm4 is port(
|
120 |
|
|
cp2_cml_1 : in std_logic;
|
121 |
|
|
cp2_cml_2 : in std_logic;
|
122 |
|
|
cp2_cml_3 : in std_logic;
|
123 |
|
|
--Clock and reset
|
124 |
|
|
cp2 : in std_logic;
|
125 |
|
|
cp2en : in std_logic;
|
126 |
|
|
ireset : in std_logic;
|
127 |
|
|
-- JTAG OCD support
|
128 |
|
|
valid_instr : out std_logic;
|
129 |
|
|
insert_nop : in std_logic;
|
130 |
|
|
block_irq : in std_logic;
|
131 |
|
|
change_flow : out std_logic;
|
132 |
|
|
-- Program Memory
|
133 |
|
|
pc : out std_logic_vector(15 downto 0);
|
134 |
|
|
inst : in std_logic_vector(15 downto 0);
|
135 |
|
|
-- I/O control
|
136 |
|
|
adr : out std_logic_vector(5 downto 0);
|
137 |
|
|
iore : out std_logic;
|
138 |
|
|
iowe : out std_logic;
|
139 |
|
|
-- Data memory control
|
140 |
|
|
ramadr : out std_logic_vector(15 downto 0);
|
141 |
|
|
ramre : out std_logic;
|
142 |
|
|
ramwe : out std_logic;
|
143 |
|
|
cpuwait : in std_logic;
|
144 |
|
|
-- Data paths
|
145 |
|
|
dbusin : in std_logic_vector(7 downto 0);
|
146 |
|
|
dbusout : out std_logic_vector(7 downto 0);
|
147 |
|
|
-- Interrupt
|
148 |
|
|
irqlines : in std_logic_vector(22 downto 0);
|
149 |
|
|
irqack : out std_logic;
|
150 |
|
|
irqackad : out std_logic_vector(4 downto 0);
|
151 |
|
|
--Sleep Control
|
152 |
|
|
sleepi : out std_logic;
|
153 |
|
|
irqok : out std_logic;
|
154 |
|
|
globint : out std_logic;
|
155 |
|
|
--Watchdog
|
156 |
|
|
wdri : out std_logic);
|
157 |
|
|
end component;
|
158 |
|
|
|
159 |
|
|
TYPE std_logic_array_rom IS ARRAY (INTEGER RANGE 0 to (4 * MAX_ROM_SIZE) - 1) of Std_logic_vector(15 downto 0);
|
160 |
|
|
SIGNAL rom_array :Std_logic_array_rom;
|
161 |
|
|
TYPE std_logic_array_ram IS ARRAY (INTEGER RANGE 0 to (4 * MAX_RAM_SIZE) - 1) of Std_logic_vector(7 downto 0);
|
162 |
|
|
SIGNAL ram_array :Std_logic_array_ram;
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
BEGIN
|
166 |
|
|
|
167 |
|
|
------------------------------------------------------------------------
|
168 |
|
|
-- CMLS indicates current pipe
|
169 |
|
|
-- clocks for AVR Core CM3
|
170 |
|
|
------------------------------------------------------------------------
|
171 |
|
|
cmls_gen : process (system_clk)
|
172 |
|
|
begin
|
173 |
|
|
if (system_clk'event and system_clk = '1') then
|
174 |
|
|
cp2 <= system_clk;
|
175 |
|
|
cp2_cml_1 <= system_clk;
|
176 |
|
|
cp2_cml_2 <= system_clk;
|
177 |
|
|
cp2_cml_3 <= system_clk;
|
178 |
|
|
if (cmls = 3) then
|
179 |
|
|
cmls <= 0;
|
180 |
|
|
else
|
181 |
|
|
cmls <= cmls + 1;
|
182 |
|
|
end if;
|
183 |
|
|
end if;
|
184 |
|
|
if (system_clk'event and system_clk = '0') then
|
185 |
|
|
cp2 <= '0';
|
186 |
|
|
cp2_cml_1 <= '0';
|
187 |
|
|
cp2_cml_2 <= '0';
|
188 |
|
|
cp2_cml_3 <= '0';
|
189 |
|
|
end if;
|
190 |
|
|
end process;
|
191 |
|
|
|
192 |
|
|
------------------------------------------------------------------------
|
193 |
|
|
-- stimuli
|
194 |
|
|
------------------------------------------------------------------------
|
195 |
|
|
vcc <= '1';
|
196 |
|
|
gnd <= '0';
|
197 |
|
|
core_cpuwait <= '0';
|
198 |
|
|
core_irqlines <= "00000000000000000000000";
|
199 |
|
|
|
200 |
|
|
------------------------------------------------------------------------
|
201 |
|
|
-- ROM
|
202 |
|
|
------------------------------------------------------------------------
|
203 |
|
|
rom_read_gen:PROCESS
|
204 |
|
|
variable thisInt : integer range 0 to 65535;
|
205 |
|
|
variable i: integer;
|
206 |
|
|
variable inLine: Line;
|
207 |
|
|
BEGIN
|
208 |
|
|
readline(inFile_a, inLine);
|
209 |
|
|
read(inLine, thisInt);
|
210 |
|
|
for i in 0 to thisInt - 1 loop
|
211 |
|
|
readline(inFile_a, inLine);
|
212 |
|
|
read(inLine, thisInt);
|
213 |
|
|
rom_array(i) <= conv_std_logic_vector(conv_unsigned(thisInt, 16), 16);
|
214 |
|
|
end loop;
|
215 |
|
|
readline(inFile_b, inLine);
|
216 |
|
|
read(inLine, thisInt);
|
217 |
|
|
for i in 0 to thisInt - 1 loop
|
218 |
|
|
readline(inFile_b, inLine);
|
219 |
|
|
read(inLine, thisInt);
|
220 |
|
|
rom_array(MAX_ROM_SIZE + i) <= conv_std_logic_vector(conv_unsigned(thisInt, 16), 16);
|
221 |
|
|
end loop;
|
222 |
|
|
readline(inFile_c, inLine);
|
223 |
|
|
read(inLine, thisInt);
|
224 |
|
|
for i in 0 to thisInt - 1 loop
|
225 |
|
|
readline(inFile_c, inLine);
|
226 |
|
|
read(inLine, thisInt);
|
227 |
|
|
rom_array((2 * MAX_ROM_SIZE) + i) <= conv_std_logic_vector(conv_unsigned(thisInt, 16), 16);
|
228 |
|
|
end loop;
|
229 |
|
|
readline(inFile_d, inLine);
|
230 |
|
|
read(inLine, thisInt);
|
231 |
|
|
for i in 0 to thisInt - 1 loop
|
232 |
|
|
readline(inFile_d, inLine);
|
233 |
|
|
read(inLine, thisInt);
|
234 |
|
|
rom_array((3 * MAX_ROM_SIZE) + i) <= conv_std_logic_vector(conv_unsigned(thisInt, 16), 16);
|
235 |
|
|
end loop;
|
236 |
|
|
WAIT FOR 8000 ms;
|
237 |
|
|
end process;
|
238 |
|
|
|
239 |
|
|
core_inst_gen : PROCESS(core_pc, cmls)
|
240 |
|
|
BEGIN
|
241 |
|
|
if (cmls = 3) then
|
242 |
|
|
core_inst <= rom_array(conv_integer(unsigned(core_pc)))(7 downto 0) &
|
243 |
|
|
rom_array(conv_integer(unsigned(core_pc)))(15 downto 8);
|
244 |
|
|
else
|
245 |
|
|
if (cmls = 0) then
|
246 |
|
|
core_inst <= rom_array(MAX_ROM_SIZE + conv_integer(unsigned(core_pc)))(7 downto 0) &
|
247 |
|
|
rom_array(MAX_ROM_SIZE + conv_integer(unsigned(core_pc)))(15 downto 8);
|
248 |
|
|
else
|
249 |
|
|
if (cmls = 1) then
|
250 |
|
|
core_inst <= rom_array((2 * MAX_ROM_SIZE) + conv_integer(unsigned(core_pc)))(7 downto 0) &
|
251 |
|
|
rom_array((2 * MAX_ROM_SIZE) + conv_integer(unsigned(core_pc)))(15 downto 8);
|
252 |
|
|
else
|
253 |
|
|
core_inst <= rom_array((3 * MAX_ROM_SIZE) + conv_integer(unsigned(core_pc)))(7 downto 0) &
|
254 |
|
|
rom_array((3 * MAX_ROM_SIZE) + conv_integer(unsigned(core_pc)))(15 downto 8);
|
255 |
|
|
end if;
|
256 |
|
|
end if;
|
257 |
|
|
end if;
|
258 |
|
|
end process;
|
259 |
|
|
|
260 |
|
|
------------------------------------------------------------------------
|
261 |
|
|
-- RAM
|
262 |
|
|
------------------------------------------------------------------------
|
263 |
|
|
ram_gen : PROCESS(system_clk, system_reset)
|
264 |
|
|
variable i: integer;
|
265 |
|
|
BEGIN
|
266 |
|
|
if (system_reset = '0') then
|
267 |
|
|
if (disable_second = '0') then
|
268 |
|
|
for i in 0 to ((4 * MAX_RAM_SIZE) - 1) loop
|
269 |
|
|
ram_array(i) <= conv_std_logic_vector(0, 8);
|
270 |
|
|
end loop;
|
271 |
|
|
end if;
|
272 |
|
|
else
|
273 |
|
|
if (system_clk'event and system_clk = '1') then
|
274 |
|
|
if (core_ramwe = '1') then
|
275 |
|
|
if (cmls = 0) then
|
276 |
|
|
ram_array(conv_integer(unsigned(core_ramadr))) <= core_dbusout;
|
277 |
|
|
else
|
278 |
|
|
if (cmls = 1) then
|
279 |
|
|
ram_array(MAX_RAM_SIZE + conv_integer(unsigned(core_ramadr))) <= core_dbusout;
|
280 |
|
|
else
|
281 |
|
|
if (cmls = 2) then
|
282 |
|
|
ram_array((2 * MAX_RAM_SIZE) + conv_integer(unsigned(core_ramadr))) <= core_dbusout;
|
283 |
|
|
else
|
284 |
|
|
ram_array((3 * MAX_RAM_SIZE) + conv_integer(unsigned(core_ramadr))) <= core_dbusout;
|
285 |
|
|
end if;
|
286 |
|
|
end if;
|
287 |
|
|
end if;
|
288 |
|
|
end if;
|
289 |
|
|
end if;
|
290 |
|
|
end if;
|
291 |
|
|
end process;
|
292 |
|
|
|
293 |
|
|
core_dbusin <= ram_array(conv_integer(unsigned(core_ramadr))) when (cmls = 0) else
|
294 |
|
|
ram_array(MAX_RAM_SIZE + conv_integer(unsigned(core_ramadr))) when (cmls = 1) else
|
295 |
|
|
ram_array((2 * MAX_RAM_SIZE) + conv_integer(unsigned(core_ramadr))) when (cmls = 2) else
|
296 |
|
|
ram_array((3 * MAX_RAM_SIZE) + conv_integer(unsigned(core_ramadr))) ;
|
297 |
|
|
|
298 |
|
|
|
299 |
|
|
|
300 |
|
|
------------------------------------------------------------------------
|
301 |
|
|
-- system_clk
|
302 |
|
|
------------------------------------------------------------------------
|
303 |
|
|
clk_gen:PROCESS
|
304 |
|
|
VARIABLE lin:line;
|
305 |
|
|
BEGIN
|
306 |
|
|
system_clk <= '1';
|
307 |
|
|
WAIT FOR 12 ns;
|
308 |
|
|
system_clk <= '0';
|
309 |
|
|
WAIT FOR 12 ns;
|
310 |
|
|
END PROCESS;
|
311 |
|
|
|
312 |
|
|
------------------------------------------------------------------------
|
313 |
|
|
-- system_reset and kill/restart second core
|
314 |
|
|
------------------------------------------------------------------------
|
315 |
|
|
reset_gen:PROCESS
|
316 |
|
|
BEGIN
|
317 |
|
|
system_reset <= '0';
|
318 |
|
|
disable_second <= '0';
|
319 |
|
|
WAIT FOR 65 ns;
|
320 |
|
|
system_reset <= '1' ;
|
321 |
|
|
WAIT FOR 100000 ns;
|
322 |
|
|
WAIT UNTIL (cmls = 0);
|
323 |
|
|
disable_second <= '1';
|
324 |
|
|
WAIT FOR 100000 ns;
|
325 |
|
|
WAIT UNTIL (cmls = 3);
|
326 |
|
|
WAIT UNTIL (system_clk = '1');
|
327 |
|
|
system_reset <= '0';
|
328 |
|
|
WAIT UNTIL (system_clk = '0');
|
329 |
|
|
WAIT FOR 2 ns;
|
330 |
|
|
system_reset <= '1' ;
|
331 |
|
|
WAIT FOR 2 ns;
|
332 |
|
|
disable_second <= '0';
|
333 |
|
|
WAIT FOR 100000 ns;
|
334 |
|
|
ASSERT false REPORT "test passed, done !!!" severity failure;
|
335 |
|
|
END PROCESS;
|
336 |
|
|
|
337 |
|
|
------------------------------------------------------------------------
|
338 |
|
|
-- AVR_Core CM4
|
339 |
|
|
------------------------------------------------------------------------
|
340 |
|
|
AVR_Core_Inst_cm4: AVR_Core_cm4 port map(
|
341 |
|
|
cp2_cml_1 => cp2_cml_1,
|
342 |
|
|
cp2_cml_2 => cp2_cml_2,
|
343 |
|
|
cp2_cml_3 => cp2_cml_3,
|
344 |
|
|
--Clock and reset
|
345 |
|
|
cp2 => cp2,
|
346 |
|
|
cp2en => vcc,
|
347 |
|
|
ireset => ireset,
|
348 |
|
|
-- JTAG OCD support
|
349 |
|
|
valid_instr => open,
|
350 |
|
|
insert_nop => gnd,
|
351 |
|
|
block_irq => gnd,
|
352 |
|
|
change_flow => open,
|
353 |
|
|
-- Program Memory
|
354 |
|
|
pc => core_pc,
|
355 |
|
|
inst => core_inst,
|
356 |
|
|
-- I/O control
|
357 |
|
|
adr => core_adr,
|
358 |
|
|
iore => core_iore,
|
359 |
|
|
iowe => core_iowe,
|
360 |
|
|
-- Data memory control
|
361 |
|
|
ramadr => core_ramadr,
|
362 |
|
|
ramre => core_ramre,
|
363 |
|
|
ramwe => core_ramwe,
|
364 |
|
|
cpuwait => core_cpuwait,
|
365 |
|
|
-- Data paths
|
366 |
|
|
dbusin => core_dbusin,
|
367 |
|
|
dbusout => core_dbusout,
|
368 |
|
|
-- Interrupts
|
369 |
|
|
irqlines => core_irqlines,
|
370 |
|
|
irqack => core_irqack,
|
371 |
|
|
irqackad => core_irqackad,
|
372 |
|
|
--Sleep Control
|
373 |
|
|
sleepi => sleepi,
|
374 |
|
|
irqok => irqok,
|
375 |
|
|
globint => globint,
|
376 |
|
|
--Watchdog
|
377 |
|
|
wdri => core_wdri);
|
378 |
|
|
|
379 |
|
|
|
380 |
|
|
------------------------------------------------------------------------
|
381 |
|
|
------------------------------------------------------------------------
|
382 |
|
|
------------------------------------------------------------------------
|
383 |
|
|
-- Insertion of 4 additional AVR cores for virtual debugging
|
384 |
|
|
------------------------------------------------------------------------
|
385 |
|
|
------------------------------------------------------------------------
|
386 |
|
|
------------------------------------------------------------------------
|
387 |
|
|
-- generate individual clocks for AVR 0, 1, 2 and 3
|
388 |
|
|
------------------------------------------------------------------------
|
389 |
|
|
subckl_gen : process (system_clk)
|
390 |
|
|
begin
|
391 |
|
|
if (cmls = 3) then
|
392 |
|
|
cml0_clk <= system_clk;
|
393 |
|
|
cml1_clk <= '0';
|
394 |
|
|
cml2_clk <= '0';
|
395 |
|
|
cml3_clk <= '0';
|
396 |
|
|
else
|
397 |
|
|
if (cmls = 0) then
|
398 |
|
|
cml0_clk <= '0';
|
399 |
|
|
if (disable_second = '0') then
|
400 |
|
|
cml1_clk <= system_clk;
|
401 |
|
|
end if;
|
402 |
|
|
cml2_clk <= '0';
|
403 |
|
|
cml3_clk <= '0';
|
404 |
|
|
else
|
405 |
|
|
if (cmls = 1) then
|
406 |
|
|
cml0_clk <= '0';
|
407 |
|
|
cml1_clk <= '0';
|
408 |
|
|
cml2_clk <= system_clk;
|
409 |
|
|
cml3_clk <= '0';
|
410 |
|
|
else
|
411 |
|
|
cml0_clk <= '0';
|
412 |
|
|
cml1_clk <= '0';
|
413 |
|
|
cml2_clk <= '0';
|
414 |
|
|
cml3_clk <= system_clk;
|
415 |
|
|
end if;
|
416 |
|
|
end if;
|
417 |
|
|
end if;
|
418 |
|
|
end process;
|
419 |
|
|
|
420 |
|
|
------------------------------------------------------------------------
|
421 |
|
|
-- generate individual resets for AVR 0, 1, 2 and 3
|
422 |
|
|
------------------------------------------------------------------------
|
423 |
|
|
system_reset_in_gen : PROCESS(system_clk, system_reset, disable_second)
|
424 |
|
|
BEGIN
|
425 |
|
|
if (disable_second = '0') then
|
426 |
|
|
if (system_clk'event and system_clk = '0') then
|
427 |
|
|
cml3_reset <= cml2_reset;
|
428 |
|
|
cml2_reset <= cml1_reset;
|
429 |
|
|
cml1_reset <= cml0_reset;
|
430 |
|
|
cml0_reset <= system_reset;
|
431 |
|
|
end if;
|
432 |
|
|
else
|
433 |
|
|
cml1_reset <= system_reset;
|
434 |
|
|
end if;
|
435 |
|
|
end process;
|
436 |
|
|
|
437 |
|
|
ireset <= cml3_reset AND system_reset;
|
438 |
|
|
--ireset <= system_reset;
|
439 |
|
|
|
440 |
|
|
------------------------------------------------------------------------
|
441 |
|
|
-- for processors a comparison of PC is enough
|
442 |
|
|
------------------------------------------------------------------------
|
443 |
|
|
check_gen : PROCESS(system_clk, system_reset)
|
444 |
|
|
BEGIN
|
445 |
|
|
if (ireset = '1') then
|
446 |
|
|
if (system_clk'event and system_clk = '0') then
|
447 |
|
|
if (cmls = 3) then
|
448 |
|
|
if NOT (core_pc = core_pc_0) then
|
449 |
|
|
ASSERT false REPORT "PC 0 mismatch" severity failure;
|
450 |
|
|
end if;
|
451 |
|
|
if NOT (core_ramadr = core_ramadr_0) then
|
452 |
|
|
ASSERT false REPORT "RAMADR 0 mismatch" severity failure;
|
453 |
|
|
end if;
|
454 |
|
|
if NOT (core_ramre = core_ramre_0) then
|
455 |
|
|
ASSERT false REPORT "RAMRE 0 mismatch" severity failure;
|
456 |
|
|
end if;
|
457 |
|
|
if NOT (core_ramwe = core_ramwe_0) then
|
458 |
|
|
ASSERT false REPORT "RAMWE 0 mismatch" severity failure;
|
459 |
|
|
end if;
|
460 |
|
|
else
|
461 |
|
|
if (cmls = 0) then
|
462 |
|
|
if (disable_second = '0') then
|
463 |
|
|
if NOT (core_pc = core_pc_1) then
|
464 |
|
|
ASSERT false REPORT "PC 1 mismatch" severity failure;
|
465 |
|
|
end if;
|
466 |
|
|
if NOT (core_ramadr = core_ramadr_1) then
|
467 |
|
|
ASSERT false REPORT "RAMADR 1 mismatch" severity failure;
|
468 |
|
|
end if;
|
469 |
|
|
if NOT (core_ramre = core_ramre_1) then
|
470 |
|
|
ASSERT false REPORT "RAMRE 1 mismatch" severity failure;
|
471 |
|
|
end if;
|
472 |
|
|
if NOT (core_ramwe = core_ramwe_1) then
|
473 |
|
|
ASSERT false REPORT "RAMWE 1 mismatch" severity failure;
|
474 |
|
|
end if;
|
475 |
|
|
end if;
|
476 |
|
|
else
|
477 |
|
|
if (cmls = 1) then
|
478 |
|
|
if NOT (core_pc = core_pc_2) then
|
479 |
|
|
ASSERT false REPORT "PC 2 mismatch" severity failure;
|
480 |
|
|
end if;
|
481 |
|
|
if NOT (core_ramadr = core_ramadr_2) then
|
482 |
|
|
ASSERT false REPORT "RAMADR 2 mismatch" severity failure;
|
483 |
|
|
end if;
|
484 |
|
|
if NOT (core_ramre = core_ramre_2) then
|
485 |
|
|
ASSERT false REPORT "RAMRE 2 mismatch" severity failure;
|
486 |
|
|
end if;
|
487 |
|
|
if NOT (core_ramwe = core_ramwe_2) then
|
488 |
|
|
ASSERT false REPORT "RAMWE 2 mismatch" severity failure;
|
489 |
|
|
end if;
|
490 |
|
|
else
|
491 |
|
|
if NOT (core_pc = core_pc_3) then
|
492 |
|
|
ASSERT false REPORT "PC 3 mismatch" severity failure;
|
493 |
|
|
end if;
|
494 |
|
|
if NOT (core_ramadr = core_ramadr_3) then
|
495 |
|
|
ASSERT false REPORT "RAMADR 3 mismatch" severity failure;
|
496 |
|
|
end if;
|
497 |
|
|
if NOT (core_ramre = core_ramre_3) then
|
498 |
|
|
ASSERT false REPORT "RAMRE 3 mismatch" severity failure;
|
499 |
|
|
end if;
|
500 |
|
|
if NOT (core_ramwe = core_ramwe_3) then
|
501 |
|
|
ASSERT false REPORT "RAMWE 3 mismatch" severity failure;
|
502 |
|
|
end if;
|
503 |
|
|
end if;
|
504 |
|
|
end if;
|
505 |
|
|
end if;
|
506 |
|
|
end if;
|
507 |
|
|
end if;
|
508 |
|
|
end process;
|
509 |
|
|
|
510 |
|
|
|
511 |
|
|
------------------------------------------------------------------------
|
512 |
|
|
-- AVR_Core virtual 0
|
513 |
|
|
------------------------------------------------------------------------
|
514 |
|
|
AVR_Core_Inst_0: AVR_Core port map(
|
515 |
|
|
--Clock and reset
|
516 |
|
|
cp2 => cml0_clk,
|
517 |
|
|
cp2en => vcc,
|
518 |
|
|
ireset => cml0_reset,
|
519 |
|
|
-- JTAG OCD support
|
520 |
|
|
valid_instr => open,
|
521 |
|
|
insert_nop => gnd,
|
522 |
|
|
block_irq => gnd,
|
523 |
|
|
change_flow => open,
|
524 |
|
|
-- Program Memory
|
525 |
|
|
pc => core_pc_0,
|
526 |
|
|
inst => core_inst,
|
527 |
|
|
-- I/O control
|
528 |
|
|
adr => open,
|
529 |
|
|
iore => open,
|
530 |
|
|
iowe => open,
|
531 |
|
|
-- Data memory control
|
532 |
|
|
ramadr => core_ramadr_0,
|
533 |
|
|
ramre => core_ramre_0,
|
534 |
|
|
ramwe => core_ramwe_0,
|
535 |
|
|
cpuwait => core_cpuwait,
|
536 |
|
|
-- Data paths
|
537 |
|
|
dbusin => core_dbusin,
|
538 |
|
|
dbusout => open,
|
539 |
|
|
-- Interrupts
|
540 |
|
|
irqlines => core_irqlines,
|
541 |
|
|
irqack => open,
|
542 |
|
|
irqackad => open,
|
543 |
|
|
--Sleep Control
|
544 |
|
|
sleepi => open,
|
545 |
|
|
irqok => open,
|
546 |
|
|
globint => open,
|
547 |
|
|
--Watchdog
|
548 |
|
|
wdri => open);
|
549 |
|
|
|
550 |
|
|
------------------------------------------------------------------------
|
551 |
|
|
-- AVR_Core virtual 1
|
552 |
|
|
------------------------------------------------------------------------
|
553 |
|
|
AVR_Core_Inst_1: AVR_Core port map(
|
554 |
|
|
--Clock and reset
|
555 |
|
|
cp2 => cml1_clk,
|
556 |
|
|
cp2en => vcc,
|
557 |
|
|
ireset => cml1_reset,
|
558 |
|
|
-- JTAG OCD support
|
559 |
|
|
valid_instr => open,
|
560 |
|
|
insert_nop => gnd,
|
561 |
|
|
block_irq => gnd,
|
562 |
|
|
change_flow => open,
|
563 |
|
|
-- Program Memory
|
564 |
|
|
pc => core_pc_1,
|
565 |
|
|
inst => core_inst,
|
566 |
|
|
-- I/O control
|
567 |
|
|
adr => open,
|
568 |
|
|
iore => open,
|
569 |
|
|
iowe => open,
|
570 |
|
|
-- Data memory control
|
571 |
|
|
ramadr => core_ramadr_1,
|
572 |
|
|
ramre => core_ramre_1,
|
573 |
|
|
ramwe => core_ramwe_1,
|
574 |
|
|
cpuwait => core_cpuwait,
|
575 |
|
|
-- Data paths
|
576 |
|
|
dbusin => core_dbusin,
|
577 |
|
|
dbusout => open,
|
578 |
|
|
-- Interrupts
|
579 |
|
|
irqlines => core_irqlines,
|
580 |
|
|
irqack => open,
|
581 |
|
|
irqackad => open,
|
582 |
|
|
--Sleep Control
|
583 |
|
|
sleepi => open,
|
584 |
|
|
irqok => open,
|
585 |
|
|
globint => open,
|
586 |
|
|
--Watchdog
|
587 |
|
|
wdri => open);
|
588 |
|
|
|
589 |
|
|
------------------------------------------------------------------------
|
590 |
|
|
-- AVR_Core virtual 2
|
591 |
|
|
------------------------------------------------------------------------
|
592 |
|
|
AVR_Core_Inst_2: AVR_Core port map(
|
593 |
|
|
--Clock and reset
|
594 |
|
|
cp2 => cml2_clk,
|
595 |
|
|
cp2en => vcc,
|
596 |
|
|
ireset => cml2_reset,
|
597 |
|
|
-- JTAG OCD support
|
598 |
|
|
valid_instr => open,
|
599 |
|
|
insert_nop => gnd,
|
600 |
|
|
block_irq => gnd,
|
601 |
|
|
change_flow => open,
|
602 |
|
|
-- Program Memory
|
603 |
|
|
pc => core_pc_2,
|
604 |
|
|
inst => core_inst,
|
605 |
|
|
-- I/O control
|
606 |
|
|
adr => open,
|
607 |
|
|
iore => open,
|
608 |
|
|
iowe => open,
|
609 |
|
|
-- Data memory control
|
610 |
|
|
ramadr => core_ramadr_2,
|
611 |
|
|
ramre => core_ramre_2,
|
612 |
|
|
ramwe => core_ramwe_2,
|
613 |
|
|
cpuwait => core_cpuwait,
|
614 |
|
|
-- Data paths
|
615 |
|
|
dbusin => core_dbusin,
|
616 |
|
|
dbusout => open,
|
617 |
|
|
-- Interrupts
|
618 |
|
|
irqlines => core_irqlines,
|
619 |
|
|
irqack => open,
|
620 |
|
|
irqackad => open,
|
621 |
|
|
--Sleep Control
|
622 |
|
|
sleepi => open,
|
623 |
|
|
irqok => open,
|
624 |
|
|
globint => open,
|
625 |
|
|
--Watchdog
|
626 |
|
|
wdri => open);
|
627 |
|
|
|
628 |
|
|
------------------------------------------------------------------------
|
629 |
|
|
-- AVR_Core virtual 3
|
630 |
|
|
------------------------------------------------------------------------
|
631 |
|
|
AVR_Core_Inst_3: AVR_Core port map(
|
632 |
|
|
--Clock and reset
|
633 |
|
|
cp2 => cml3_clk,
|
634 |
|
|
cp2en => vcc,
|
635 |
|
|
ireset => cml3_reset,
|
636 |
|
|
-- JTAG OCD support
|
637 |
|
|
valid_instr => open,
|
638 |
|
|
insert_nop => gnd,
|
639 |
|
|
block_irq => gnd,
|
640 |
|
|
change_flow => open,
|
641 |
|
|
-- Program Memory
|
642 |
|
|
pc => core_pc_3,
|
643 |
|
|
inst => core_inst,
|
644 |
|
|
-- I/O control
|
645 |
|
|
adr => open,
|
646 |
|
|
iore => open,
|
647 |
|
|
iowe => open,
|
648 |
|
|
-- Data memory control
|
649 |
|
|
ramadr => core_ramadr_3,
|
650 |
|
|
ramre => core_ramre_3,
|
651 |
|
|
ramwe => core_ramwe_3,
|
652 |
|
|
cpuwait => core_cpuwait,
|
653 |
|
|
-- Data paths
|
654 |
|
|
dbusin => core_dbusin,
|
655 |
|
|
dbusout => open,
|
656 |
|
|
-- Interrupts
|
657 |
|
|
irqlines => core_irqlines,
|
658 |
|
|
irqack => open,
|
659 |
|
|
irqackad => open,
|
660 |
|
|
--Sleep Control
|
661 |
|
|
sleepi => open,
|
662 |
|
|
irqok => open,
|
663 |
|
|
globint => open,
|
664 |
|
|
--Watchdog
|
665 |
|
|
wdri => open);
|
666 |
|
|
|
667 |
|
|
end behavioral;
|
668 |
|
|
|
669 |
|
|
|