43 use IEEE.STD_LOGIC_1164.
ALL;
44 use IEEE.NUMERIC_STD.
ALL;
48 library XIL_DEFAULTLIB;
49 use XIL_DEFAULTLIB.topFlash_pkg.
all;
75 constant cTREG : time := 1.
0 ns;
78 constant cEmifClkPeriod : time := 41.
67 ns;
79 constant cUsr0ClkPeriod : time := 6.
40 ns;
80 constant cUsr1ClkPeriod : time := 4.
00 ns;
81 constant c10GeClkPeriod : time := 6.
40 ns;
82 constant cMem0ClkPeriod : time := 3.
33 ns;
83 constant cMem1ClkPeriod : time := 3.
33 ns;
86 constant cEMIF_CFG_REG_BASE : integer := 16#00#;
87 constant cEMIF_PHY_REG_BASE : integer := 16#10#;
88 constant cEMIF_LY2_REG_BASE : integer := 16#20#;
89 constant cEMIF_LY3_REG_BASE : integer := 16#30#;
90 constant cEMIF_RES_REG_BASE : integer := 16#40#;
91 constant cEMIF_DIAG_REG_BASE : integer := 16#70#;
93 constant cEMIF_EXT_PAGE_BASE : integer := 16#80#;
94 constant cEMIF_EXT_PAGE_SIZE : integer := 16#04#;
102 signal sVirtBusClk : std_logic;
103 signal sVoid_n : std_logic;
106 signal sPSOC_Fcfg_Reset_n : std_logic;
109 signal sPSOC_Mmio_Clk : std_ulogic;
110 signal sPSOC_Mmio_Cs_n : std_ulogic;
111 signal sPSOC_Mmio_AdS_n : std_ulogic;
112 signal sPSOC_Mmio_We_n : std_ulogic;
113 signal sPSOC_Mmio_Oe_n : std_ulogic;
114 signal sPSOC_Mmio_Data : std_ulogic_vector(cFMKU60_MMIO_DataWidth-1 downto 0);
115 signal sPSOC_Mmio_Addr : std_ulogic_vector(cFMKU60_MMIO_AddrWidth-1 downto 0);
118 signal sTOP_Led_HeartBeat: std_ulogic;
121 signal sTbRunCtrl : std_ulogic;
124 signal sCLKT_Usr0Clk_n : std_ulogic;
125 signal sCLKT_Usr0Clk_p : std_ulogic;
126 signal sCLKT_Usr1Clk_n : std_ulogic;
127 signal sCLKT_Usr1Clk_p : std_ulogic;
128 signal sCLKT_Mem0Clk_n : std_ulogic;
129 signal sCLKT_Mem0Clk_p : std_ulogic;
130 signal sCLKT_Mem1Clk_n : std_ulogic;
131 signal sCLKT_Mem1Clk_p : std_ulogic;
132 signal sCLKT_10GeClk_n : std_ulogic;
133 signal sCLKT_10GeClk_p : std_ulogic;
138 procedure pdGenClocks (
139 constant cT :
in time;
140 signal sClock_n :
out std_ulogic;
141 signal sClock_p :
out std_ulogic;
142 signal sDoRun :
in std_ulogic)
is
147 while (sDoRun) = '1' loop
155 end procedure pdGenClocks;
163 TOP:
entity work.topFlash
166 gBitstreamUsage =>
"flash",
167 gSecurityPriviledges =>
"super",
169 gEmifAddrWidth => cFMKU60_MMIO_AddrWidth,
170 gEmifDataWidth => cFMKU60_MMIO_DataWidth
177 piPSOC_Fcfg_Rst_n => sPSOC_Fcfg_Reset_n,
182 piCLKT_Mem0Clk_n => sCLKT_Mem0Clk_n,
183 piCLKT_Mem0Clk_p => sCLKT_Mem0Clk_p,
184 piCLKT_Mem1Clk_n => sCLKT_Mem1Clk_n,
185 piCLKT_Mem1Clk_p => sCLKT_Mem1Clk_p,
190 piCLKT_10GeClk_n => sCLKT_10GeClk_n,
191 piCLKT_10GeClk_p => sCLKT_10GeClk_p,
196 piCLKT_Usr0Clk_n => sCLKT_Usr0Clk_n,
197 piCLKT_Usr0Clk_p => sCLKT_Usr0Clk_p,
198 piCLKT_Usr1Clk_n => sCLKT_Usr1Clk_n,
199 piCLKT_Usr1Clk_p => sCLKT_Usr1Clk_p,
204 piPSOC_Emif_Clk => sPSOC_Mmio_Clk,
205 piPSOC_Emif_Cs_n => sPSOC_Mmio_Cs_n,
206 piPSOC_Emif_We_n => sPSOC_Mmio_We_n,
207 piPSOC_Emif_Oe_n => sPSOC_Mmio_Oe_n,
208 piPSOC_Emif_AdS_n => sPSOC_Mmio_AdS_n,
209 piPSOC_Emif_Addr => sPSOC_Mmio_Addr,
210 pioPSOC_Emif_Data => sPSOC_Mmio_Data,
215 poTOP_Led_HeartBeat_n => sTOP_Led_HeartBeat,
220 pioDDR_Top_Mc0_DmDbi_n =>
open,
221 pioDDR_Top_Mc0_Dq =>
open,
222 pioDDR_Top_Mc0_Dqs_p =>
open,
223 pioDDR_Top_Mc0_Dqs_n =>
open,
224 poTOP_Ddr4_Mc0_Act_n =>
open,
225 poTOP_Ddr4_Mc0_Adr =>
open,
226 poTOP_Ddr4_Mc0_Ba =>
open,
227 poTOP_Ddr4_Mc0_Bg =>
open,
228 poTOP_Ddr4_Mc0_Cke =>
open,
229 poTOP_Ddr4_Mc0_Odt =>
open,
230 poTOP_Ddr4_Mc0_Cs_n =>
open,
231 poTOP_Ddr4_Mc0_Ck_p =>
open,
232 poTOP_Ddr4_Mc0_Ck_n =>
open,
233 poTOP_Ddr4_Mc0_Reset_n =>
open,
238 pioDDR_Top_Mc1_DmDbi_n =>
open,
239 pioDDR_Top_Mc1_Dq =>
open,
240 pioDDR_Top_Mc1_Dqs_p =>
open,
241 pioDDR_Top_Mc1_Dqs_n =>
open,
242 poTOP_Ddr4_Mc1_Act_n =>
open,
243 poTOP_Ddr4_Mc1_Adr =>
open,
244 poTOP_Ddr4_Mc1_Ba =>
open,
245 poTOP_Ddr4_Mc1_Bg =>
open,
246 poTOP_Ddr4_Mc1_Cke =>
open,
247 poTOP_Ddr4_Mc1_Odt =>
open,
248 poTOP_Ddr4_Mc1_Cs_n =>
open,
249 poTOP_Ddr4_Mc1_Ck_p =>
open,
250 poTOP_Ddr4_Mc1_Ck_n =>
open,
251 poTOP_Ddr4_Mc1_Reset_n =>
open,
256 piECON_Top_10Ge0_n => '0',
257 piECON_Top_10Ge0_p => '1',
258 poTOP_Econ_10Ge0_n =>
open,
259 poTOP_Econ_10Ge0_p =>
open
265 pGenEmifClockComb :
process is
267 pdGenClocks(cEmifClkPeriod, sVoid_n, sVirtBusClk, sTbRunCtrl);
268 end process pGenEmifClockComb;
273 pGenUsr0ClockComb :
process is
275 pdGenClocks(cUsr0ClkPeriod, sCLKT_Usr0Clk_n, sCLKT_Usr0Clk_p, sTbRunCtrl);
276 end process pGenUsr0ClockComb;
281 pGenUsr1ClockComb :
process is
283 pdGenClocks(cUsr1ClkPeriod, sCLKT_Usr1Clk_n, sCLKT_Usr1Clk_p, sTbRunCtrl);
284 end process pGenUsr1ClockComb;
289 pGen10GeClockComb :
process is
291 pdGenClocks(c10GeClkPeriod, sCLKT_10GeClk_n, sCLKT_10GeClk_p, sTbRunCtrl);
292 end process pGen10GeClockComb;
297 pGenMem0ClockComb :
process is
299 pdGenClocks(cMem0ClkPeriod, sCLKT_Mem0Clk_n, sCLKT_Mem0Clk_p, sTbRunCtrl);
300 end process pGenMem0ClockComb;
305 pGenMem1ClockComb :
process is
307 pdGenClocks(cMem1ClkPeriod, sCLKT_Mem1Clk_n, sCLKT_Mem1Clk_p, sTbRunCtrl);
308 end process pGenMem1ClockComb;
313 pMainSimComb :
process is
316 variable vTbErrors : integer;
321 --
procedure pdEmifWrite (
322 addr :
in integer range 0 to (2**cFMKU60_MMIO_AddrWidth
1);
323 data :
in integer range 0 to (2**cFMKU60_MMIO_DataWidth
1)
326 wait until rising_edge(sVirtBusClk);
328 sPSOC_Mmio_Addr <= std_ulogic_vector(to_unsigned(addr, cFMKU60_MMIO_AddrWidth));
329 wait until rising_edge(sVirtBusClk);
331 sPSOC_Mmio_Clk <= '0';
332 sPSOC_Mmio_Cs_n <= '0';
333 sPSOC_Mmio_AdS_n <= '0';
334 sPSOC_Mmio_We_n <= '0';
335 sPSOC_Mmio_Oe_n <= '1';
336 sPSOC_Mmio_Data <= std_ulogic_vector(to_unsigned(data, cFMKU60_MMIO_DataWidth));
337 wait until falling_edge(sVirtBusClk);
339 sPSOC_Mmio_Clk <= '1';
340 wait until rising_edge(sVirtBusClk);
342 sPSOC_Mmio_Clk <= '0';
343 sPSOC_Mmio_Cs_n <= '1';
344 sPSOC_Mmio_AdS_n <= '1';
345 sPSOC_Mmio_We_n <= '1';
346 sPSOC_Mmio_Oe_n <= '1';
347 sPSOC_Mmio_Data <= (others => 'Z');
348 end procedure pdEmifWrite;
353 -
procedure pdEmifRead (
354 addr :
in integer range 0 to (2**cFMKU60_MMIO_AddrWidth
1)
357 wait until rising_edge(sVirtBusClk);
359 sPSOC_Mmio_Clk <= '0';
360 sPSOC_Mmio_Addr <= std_ulogic_vector(to_unsigned(addr, cFMKU60_MMIO_AddrWidth));
361 sPSOC_Mmio_Cs_n <= '0';
362 sPSOC_Mmio_AdS_n <= '0';
363 sPSOC_Mmio_We_n <= '1';
364 sPSOC_Mmio_Oe_n <= '0';
365 wait until falling_edge(sVirtBusClk);
367 sPSOC_Mmio_Clk <= '1';
368 wait until rising_edge(sVirtBusClk);
370 sPSOC_Mmio_Clk <= '0';
371 sPSOC_Mmio_Cs_n <= '1';
372 sPSOC_Mmio_AdS_n <= '1';
373 sPSOC_Mmio_We_n <= '1';
374 sPSOC_Mmio_Oe_n <= '0';
375 wait until rising_edge(sVirtBusClk);
377 sPSOC_Mmio_Oe_n <= '1' after cTREG;
378 end procedure pdEmifRead;
383 -
procedure pdAssessEmifData (
384 expectedVal:
in integer range 0 to (2**cFMKU60_MMIO_DataWidth
1)
387 if (expectedVal /= to_integer(unsigned(sPSOC_Mmio_Data))) then
388 report "[TbSimError] Data-Bus-Read = " & integer'image(to_integer(unsigned(sPSOC_Mmio_Data))) & " (0x" & to_hex_string(sPSOC_Mmio_Data) & ")" & " - Expected-Value = " & integer'image(expectedVal) & " (0x" & to_hex_string(to_signed(expectedVal,8)) & ")" severity ERROR;
389 vTbErrors := vTbErrors + 1;
391 end pdAssessEmifData;
397 procedure pdReportErrors (
398 nbErrors :
in integer
400 variable myLine : line;
402 write(myLine, string'("*****************************************************************************"));
403 writeline(output, myLine);
404 if (nbErrors > 0) then
405 write(myLine, string'("** END of TESTBENCH - SIMULATION FAILED (KO): Total # error(s) = " ));
406 write(myLine, nbErrors);
407 elsif (nbErrors < 0) then
408 write(myLine, string'("** ABORTING TESTBENCH - FATAL ERROR (Please Check the Console)" ));
410 write(myLine, string'("** END of TESTBENCH - SIMULATION SUCCEEDED (OK): No Error."));
412 writeline(output, myLine);
413 write(myLine, string'("*****************************************************************************"));
414 writeline(output, myLine);
416 if (nbErrors < 0) then
417 assert FALSE Report "Aborting simulation" severity FAILURE;
419 assert FALSE Report "Successful end of simulation" severity FAILURE;
433 sPSOC_Fcfg_Reset_n <= '0';
437 sPSOC_Mmio_Clk <= '0';
438 sPSOC_Mmio_Cs_n <= '1';
439 sPSOC_Mmio_AdS_n <= '1';
440 sPSOC_Mmio_We_n <= '1';
441 sPSOC_Mmio_Oe_n <= '1';
442 sPSOC_Mmio_Data <= (others => 'Z');
443 sPSOC_Mmio_Addr <= (others => '0');
447 sPSOC_Fcfg_Reset_n <= '1';
461 pdEmifRead(cEMIF_CFG_REG_BASE+0);
462 pdAssessEmifData(16#3D#);
465 pdEmifRead(cEMIF_CFG_REG_BASE+1);
466 pdAssessEmifData(16#01#);
469 pdEmifRead(cEMIF_CFG_REG_BASE+2);
470 pdAssessEmifData(16#00#);
473 pdEmifRead(cEMIF_CFG_REG_BASE+3);
474 pdAssessEmifData(16#00#);
483 pdEmifWrite(cEMIF_DIAG_REG_BASE+i, i);
489 pdEmifRead(cEMIF_DIAG_REG_BASE+i);
496 pdEmifWrite(cEMIF_DIAG_REG_BASE+i, i+4);
502 pdEmifRead(cEMIF_DIAG_REG_BASE+i);
503 pdAssessEmifData(i+4);
509 pdEmifWrite(cEMIF_DIAG_REG_BASE+i, 255-i);
515 pdEmifRead(cEMIF_DIAG_REG_BASE+i);
516 pdAssessEmifData(255-i);
525 for i in 0 to cEMIF_EXT_PAGE_SIZE-1 loop
526 pdEmifWrite(cEMIF_EXT_PAGE_BASE+i, i);
531 for i in 0 to cEMIF_EXT_PAGE_SIZE-1 loop
532 pdEmifRead(cEMIF_EXT_PAGE_BASE+i);
538 for i in 0 to cEMIF_EXT_PAGE_SIZE-1 loop
539 pdEmifWrite(cEMIF_EXT_PAGE_BASE+i, cEMIF_EXT_PAGE_SIZE-1-i);
544 for i in 0 to cEMIF_EXT_PAGE_SIZE-1 loop
545 pdEmifRead(cEMIF_EXT_PAGE_BASE+i);
546 pdAssessEmifData(cEMIF_EXT_PAGE_SIZE-1-i);
554 pdEmifRead(cEMIF_CFG_REG_BASE+0);
555 pdAssessEmifData(16#3D#);
558 pdEmifRead(cEMIF_CFG_REG_BASE+1);
559 pdAssessEmifData(16#01#);
562 pdEmifRead(cEMIF_CFG_REG_BASE+2);
563 pdAssessEmifData(16#00#);
566 pdEmifRead(cEMIF_CFG_REG_BASE+3);
567 pdAssessEmifData(16#00#);
578 pdReportErrors(vTbErrors);
580 end process pMainSimComb;