cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
tb_RoleFlash_Echo.vhd
Go to the documentation of this file.
1 -- /*******************************************************************************
2 -- * Copyright 2016 -- 2021 IBM Corporation
3 -- *
4 -- * Licensed under the Apache License, Version 2.0 (the "License");
5 -- * you may not use this file except in compliance with the License.
6 -- * You may obtain a copy of the License at
7 -- *
8 -- * http://www.apache.org/licenses/LICENSE-2.0
9 -- *
10 -- * Unless required by applicable law or agreed to in writing, software
11 -- * distributed under the License is distributed on an "AS IS" BASIS,
12 -- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 -- * See the License for the specific language governing permissions and
14 -- * limitations under the License.
15 -- *******************************************************************************/
16 
17 
18  -- ******************************************************************************
19  -- *
20  -- * cloudFPGA
21  -- *
22  -- *-----------------------------------------------------------------------------
23  -- *
24  -- * Title : Testbench for the TCP and UDP echo pass-through applications.
25  -- * File : tb_RoleFlash_Echo.vhd
26  -- *
27  -- * Created : May 2018
28  -- * Authors : Francois Abel <fab@zurich.ibm.com>
29  -- *
30  -- * Devices : xcku060-ffva1156-2-i
31  -- * Tools : Vivado v2016.4 (64-bit)
32  -- * Depends : None
33  -- *
34  -- * Description : This testbench emulates the TCP and UDP AXI stream interfaces
35  -- * between the ROLE and the SHELL.
36  -- *
37  -- *-----------------------------------------------------------------------------
38  -- * Comments:
39  -- *
40  -- ******************************************************************************
41 
42  library IEEE;
43  use IEEE.STD_LOGIC_1164.ALL;
44  use IEEE.NUMERIC_STD.ALL;
45  library STD;
46  use STD.TEXTIO.ALL;
47 
48  library XIL_DEFAULTLIB;
49 
50  -- Uncomment the following library declaration if instantiating
51  -- any Xilinx leaf cells in this code.
52  --library UNISIM;
53  --use UNISIM.VComponents.all;
54 
55 
56  --*************************************************************************
57  --** ENTITY
58  --*************************************************************************
60  -- Empty
62 
63 
64  --****************************************************************************
65  --** ARCHITECTURE
66  --****************************************************************************
67  architecture Behavioral of tb_RoleFlash_Echo is
68 
69  --==========================================================================
70  -- CONSTANT DEFINITIONS
71  --==========================================================================
72 
73  -- Timing Constraints ------------------------------------------------------
74  constant cTREG : time := 1.0 ns;
75 
76  -- Clock Constraints -------------------------------------------------------
77  constant cShellClkPeriod : time := 6.40 ns; -- 156.25 MHz
78 
79  --==========================================================================
80  --== SIGNAL DECLARATIONS
81  --==========================================================================
82 
83  -- SHELL / Global Input Clock and Reset Interface
84  signal sSHL_156_25Clk : std_logic;
85  signal sSHL_156_25Rst : std_logic;
86  signal sVoid_n : std_logic;
87 
88  -- SHELL / Role / Nts0 / Udp Interface
89  ---- Input AXI-Write Stream Interface ----------
90  signal sSHL_Rol_Nts0_Udp_Axis_tdata : std_ulogic_vector( 63 downto 0);
91  signal sSHL_Rol_Nts0_Udp_Axis_tkeep : std_ulogic_vector( 7 downto 0);
92  signal sSHL_Rol_Nts0_Udp_Axis_tlast : std_ulogic;
93  signal sSHL_Rol_Nts0_Udp_Axis_tvalid : std_ulogic;
94  signal sROL_Shl_Nts0_Udp_Axis_tready : std_ulogic;
95  ---- Output AXI-Write Stream Interface ---------
96  signal sSHL_Rol_Nts0_Udp_Axis_tready : std_ulogic;
97  signal sROL_Shl_Nts0_Udp_Axis_tdata : std_ulogic_vector( 63 downto 0);
98  signal sROL_Shl_Nts0_Udp_Axis_tkeep : std_ulogic_vector( 7 downto 0);
99  signal sROL_Shl_Nts0_Udp_Axis_tlast : std_ulogic;
100  signal sROL_Shl_Nts0_Udp_Axis_tvalid : std_ulogic;
101 
102  -- SHELL / Role / Nts0 / Tcp Interface
103  ---- Input AXI-Write Stream Interface ----------
104  signal sSHL_Rol_Nts0_Tcp_Axis_tdata : std_ulogic_vector( 63 downto 0);
105  signal sSHL_Rol_Nts0_Tcp_Axis_tkeep : std_ulogic_vector( 7 downto 0);
106  signal sSHL_Rol_Nts0_Tcp_Axis_tlast : std_ulogic;
107  signal sSHL_Rol_Nts0_Tcp_Axis_tvalid : std_ulogic;
108  signal sROL_Shl_Nts0_Tcp_Axis_tready : std_ulogic;
109  ---- Output AXI-Write Stream Interface ---------
110  signal sSHL_Rol_Nts0_Tcp_Axis_tready : std_ulogic;
111  signal sROL_Shl_Nts0_Tcp_Axis_tdata : std_ulogic_vector( 63 downto 0);
112  signal sROL_Shl_Nts0_Tcp_Axis_tkeep : std_ulogic_vector( 7 downto 0);
113  signal sROL_Shl_Nts0_Tcp_Axis_tlast : std_ulogic;
114  signal sROL_Shl_Nts0_Tcp_Axis_tvalid : std_ulogic;
115 
116  -- SHELL / Role / Mmio / Flash Debug Interface
117  ---- MMIO / CTRL_2 Register ----------------
118  signal sSHL_Rol_Mmio_UdpEchoCtrl : std_ulogic_vector( 1 downto 0);
119  signal sSHL_Rol_Mmio_UdpPostPktEn : std_ulogic;
120  signal sSHL_Rol_Mmio_UdpCaptPktEn : std_ulogic;
121  signal sSHL_Rol_Mmio_TcpEchoCtrl : std_ulogic_vector( 1 downto 0);
122  signal sSHL_Rol_Mmio_TcpPostPktEn : std_ulogic;
123  signal sSHL_Rol_Mmio_TcpCaptPktEn : std_ulogic;
124 
125 
126  -- TOP : Secondary Clock (Asynchronous)
127  signal sTOP_250_00Clk : std_ulogic;
128 
129  -- A signal to control the testbench simulation ----------------------------
130  signal sTbRunCtrl : std_ulogic;
131 
132  -- Shared Variables to control the generation of the FC waveforms ----------
133  shared variable vUdpFcReq : boolean;
134  shared variable vTcpFcReq : boolean;
135  shared variable vUdpFcBegCyc, vUdpFcEndCyc: integer;
136  shared variable vTcpFcBegCyc, vTcpFcEndCyc: integer;
137 
138 
139  ------------------------------------------------------------------
140  -- Prcd: Generate Clock
141  ------------------------------------------------------------------
142  procedure pdGenClock (
143  constant cT : in time;
144  signal sClock_n : out std_ulogic;
145  signal sClock_p : out std_ulogic;
146  signal sDoRun : in std_ulogic) is
147  begin
148  sClock_p <= '0';
149  sClock_n <= '1';
150  wait for cT / 4;
151  while (sDoRun = '1') loop
152  sClock_p <= '0';
153  sClock_n <= '1';
154  wait for cT / 2;
155  sClock_p <= '1';
156  sClock_n <= '0';
157  wait for cT / 2;
158  end loop;
159  end procedure pdGenClock;
160 
161  -----------------------------------------------------------------------------
162  -- Prcd: Generate Flow Control for the 'SHL_Rol_Nts0_Udp' interface
163  -----------------------------------------------------------------------------
164  procedure pgGenShellUdpFc (
165  begCyc : integer;
166  endCyc : integer) is
167  begin
168  vUdpFcReq := True;
169  vUdpFcBegCyc := begCyc;
170  vUdpFcEndCyc := endCyc;
171  end procedure pgGenShellUdpFc;
172 
173  -----------------------------------------------------------------------------
174  -- Prcd: Generate Flow Control for the 'SHL_Rol_Nts0_Tcp' interface
175  -----------------------------------------------------------------------------
176  procedure pgGenShellTcpFc (
177  begCyc : integer;
178  endCyc : integer) is
179  begin
180  vTcpFcReq := True;
181  vTcpFcBegCyc := begCyc;
182  vTcpFcEndCyc := endCyc;
183  end procedure pgGenShellTcpFc;
184 
185 
186  --################################################################################
187  --# #
188  --# ##### #### #### # # #
189  --# # # # # # # # # #
190  --# # # # # # # ### #
191  --# ##### # # # # # #
192  --# # # # # # # # #
193  --# # # # # # # # #
194  --# ##### #### #### # #
195  --# #
196  --################################################################################
197 
198  begin -- of architecture
199 
200  ----------------------------------------------------------
201  -- INST: The toplevel to be tested
202  ----------------------------------------------------------
203  ROLE: entity work.Role_x1Udp_x1Tcp_x2Mp
204  port map (
205 
206  ------------------------------------------------------
207  -- SHELL / Global Input Clock and Reset Interface
208  ------------------------------------------------------
209  piSHL_156_25Clk => sSHL_156_25Clk,
210  piSHL_156_25Rst => sSHL_156_25Rst,
211 
212  --------------------------------------------------------
213  -- SHELL / Role / Nts0 / Udp Interface
214  --------------------------------------------------------
215  ---- Input AXI-Write Stream Interface ----------
216  piSHL_Rol_Nts0_Udp_Axis_tdata => sSHL_Rol_Nts0_Udp_Axis_tdata,
217  piSHL_Rol_Nts0_Udp_Axis_tkeep => sSHL_Rol_Nts0_Udp_Axis_tkeep,
218  piSHL_Rol_Nts0_Udp_Axis_tlast => sSHL_Rol_Nts0_Udp_Axis_tlast,
219  piSHL_Rol_Nts0_Udp_Axis_tvalid => sSHL_Rol_Nts0_Udp_Axis_tvalid,
220  poROL_Shl_Nts0_Udp_Axis_tready => sROL_Shl_Nts0_Udp_Axis_tready,
221  ---- Output AXI-Write Stream Interface ---------
222  piSHL_Rol_Nts0_Udp_Axis_tready => sSHL_Rol_Nts0_Udp_Axis_tready,
223  poROL_Shl_Nts0_Udp_Axis_tdata => sROL_Shl_Nts0_Udp_Axis_tdata,
224  poROL_Shl_Nts0_Udp_Axis_tkeep => sROL_Shl_Nts0_Udp_Axis_tkeep,
225  poROL_Shl_Nts0_Udp_Axis_tlast => sROL_Shl_Nts0_Udp_Axis_tlast,
226  poROL_Shl_Nts0_Udp_Axis_tvalid => sROL_Shl_Nts0_Udp_Axis_tvalid,
227 
228  --------------------------------------------------------
229  -- SHELL / Role / Nts0 / Tcp Interface
230  --------------------------------------------------------
231  ---- Input AXI-Write Stream Interface ----------
232  piSHL_Rol_Nts0_Tcp_Axis_tdata => sSHL_Rol_Nts0_Tcp_Axis_tdata,
233  piSHL_Rol_Nts0_Tcp_Axis_tkeep => sSHL_Rol_Nts0_Tcp_Axis_tkeep,
234  piSHL_Rol_Nts0_Tcp_Axis_tlast => sSHL_Rol_Nts0_Tcp_Axis_tlast,
235  piSHL_Rol_Nts0_Tcp_Axis_tvalid => sSHL_Rol_Nts0_Tcp_Axis_tvalid,
236  poROL_Shl_Nts0_Tcp_Axis_tready => sROL_Shl_Nts0_Tcp_Axis_tready,
237  ---- Output AXI-Write Stream Interface ---------
238  piSHL_Rol_Nts0_Tcp_Axis_tready => sSHL_Rol_Nts0_Tcp_Axis_tready,
239  poROL_Shl_Nts0_Tcp_Axis_tdata => sROL_Shl_Nts0_Tcp_Axis_tdata,
240  poROL_Shl_Nts0_Tcp_Axis_tkeep => sROL_Shl_Nts0_Tcp_Axis_tkeep,
241  poROL_Shl_Nts0_Tcp_Axis_tlast => sROL_Shl_Nts0_Tcp_Axis_tlast,
242  poROL_Shl_Nts0_Tcp_Axis_tvalid => sROL_Shl_Nts0_Tcp_Axis_tvalid,
243 
244  ------------------------------------------------
245  -- SHELL / Role / Mem / Mp0 Interface
246  ------------------------------------------------
247  ---- Memory Port #0 / S2MM-AXIS ------------------
248  ------ Stream Read Command -----------------
249  piSHL_Rol_Mem_Mp0_Axis_RdCmd_tready => '0',
250  poROL_Shl_Mem_Mp0_Axis_RdCmd_tdata => open,
251  poROL_Shl_Mem_Mp0_Axis_RdCmd_tvalid => open,
252  ------ Stream Read Status ------------------
253  piSHL_Rol_Mem_Mp0_Axis_RdSts_tdata => (others=>'0'),
254  piSHL_Rol_Mem_Mp0_Axis_RdSts_tvalid => '0',
255  poROL_Shl_Mem_Mp0_Axis_RdSts_tready => open,
256  ------ Stream Data Input Channel -----------
257  piSHL_Rol_Mem_Mp0_Axis_Read_tdata => (others=>'0'),
258  piSHL_Rol_Mem_Mp0_Axis_Read_tkeep => (others=>'0'),
259  piSHL_Rol_Mem_Mp0_Axis_Read_tlast => '0',
260  piSHL_Rol_Mem_Mp0_Axis_Read_tvalid => '0',
261  poROL_Shl_Mem_Mp0_Axis_Read_tready => open,
262  ------ Stream Write Command ----------------
263  piSHL_Rol_Mem_Mp0_Axis_WrCmd_tready => '0',
264  poROL_Shl_Mem_Mp0_Axis_WrCmd_tdata => open,
265  poROL_Shl_Mem_Mp0_Axis_WrCmd_tvalid => open,
266  ------ Stream Write Status -----------------
267  piSHL_Rol_Mem_Mp0_Axis_WrSts_tdata => (others=>'0'),
268  piSHL_Rol_Mem_Mp0_Axis_WrSts_tvalid => '0',
269  poROL_Shl_Mem_Mp0_Axis_WrSts_tready => open,
270  ------ Stream Data Output Channel ----------
271  piSHL_Rol_Mem_Mp0_Axis_Write_tready => '0',
272  poROL_Shl_Mem_Mp0_Axis_Write_tdata => open,
273  poROL_Shl_Mem_Mp0_Axis_Write_tkeep => open,
274  poROL_Shl_Mem_Mp0_Axis_Write_tlast => open,
275  poROL_Shl_Mem_Mp0_Axis_Write_tvalid => open,
276 
277  ------------------------------------------------
278  -- SHELL / Role / Mem / Mp1 Interface
279  ------------------------------------------------
280  ---- Memory Port #1 / S2MM-AXIS ------------------
281  ------ Stream Read Command -----------------
282  piSHL_Rol_Mem_Mp1_Axis_RdCmd_tready => '0',
283  poROL_Shl_Mem_Mp1_Axis_RdCmd_tdata => open,
284  poROL_Shl_Mem_Mp1_Axis_RdCmd_tvalid => open,
285  ------ Stream Read Status ------------------
286  piSHL_Rol_Mem_Mp1_Axis_RdSts_tdata => (others=>'0'),
287  piSHL_Rol_Mem_Mp1_Axis_RdSts_tvalid => '0',
288  poROL_Shl_Mem_Mp1_Axis_RdSts_tready => open,
289  ------ Stream Data Input Channel -----------
290  piSHL_Rol_Mem_Mp1_Axis_Read_tdata => (others=>'0'),
291  piSHL_Rol_Mem_Mp1_Axis_Read_tkeep => (others=>'0'),
292  piSHL_Rol_Mem_Mp1_Axis_Read_tlast => '0',
293  piSHL_Rol_Mem_Mp1_Axis_Read_tvalid => '0',
294  poROL_Shl_Mem_Mp1_Axis_Read_tready => open,
295  ------ Stream Write Command ----------------
296  piSHL_Rol_Mem_Mp1_Axis_WrCmd_tready => '0',
297  poROL_Shl_Mem_Mp1_Axis_WrCmd_tdata => open,
298  poROL_Shl_Mem_Mp1_Axis_WrCmd_tvalid => open,
299  ------ Stream Write Status -----------------
300  piSHL_Rol_Mem_Mp1_Axis_WrSts_tdata => (others=>'0'),
301  piSHL_Rol_Mem_Mp1_Axis_WrSts_tvalid => '0',
302  poROL_Shl_Mem_Mp1_Axis_WrSts_tready => open,
303  ------ Stream Data Output Channel ----------
304  piSHL_Rol_Mem_Mp1_Axis_Write_tready => '0',
305  poROL_Shl_Mem_Mp1_Axis_Write_tdata => open,
306  poROL_Shl_Mem_Mp1_Axis_Write_tkeep => open,
307  poROL_Shl_Mem_Mp1_Axis_Write_tlast => open,
308  poROL_Shl_Mem_Mp1_Axis_Write_tvalid => open,
309 
310  --------------------------------------------------------
311  -- SHELL / Role / Mmio / Flash Debug Interface
312  --------------------------------------------------------
313  -- MMIO / CTRL_2 Register ----------------
314  piSHL_Rol_Mmio_UdpEchoCtrl => sSHL_Rol_Mmio_UdpEchoCtrl,
315  piSHL_Rol_Mmio_UdpPostPktEn => sSHL_Rol_Mmio_UdpPostPktEn,
316  piSHL_Rol_Mmio_UdpCaptPktEn => sSHL_Rol_Mmio_UdpCaptPktEn,
317  piSHL_Rol_Mmio_TcpEchoCtrl => sSHL_Rol_Mmio_TcpEchoCtrl,
318  piSHL_Rol_Mmio_TcpPostPktEn => sSHL_Rol_Mmio_TcpPostPktEn,
319  piSHL_Rol_Mmio_TcpCaptPktEn => sSHL_Rol_Mmio_TcpCaptPktEn,
320 
321  -------------------------------------------------------
322  -- ROLE EMIF Registers
323  -------------------------------------------------------
324  poROL_SHL_EMIF_2B_Reg => open,
325  piSHL_ROL_EMIF_2B_Reg => (others=>'0'),
326 
327  ------------------------------------------------
328  ---- TOP => Secondary Clock (Asynchronous)
329  ------------------------------------------------
330  piTOP_250_00Clk => sTOP_250_00Clk, -- Freerunning
331 
332  poVoid => open
333 
334  );
335 
336 
337  ----------------------------------------------------------
338  -- PROC: Generate the SHELL Clock
339  ----------------------------------------------------------
340  pGenShellClock : process is
341  begin
342  pdGenClock(cShellClkPeriod, sVoid_n, sSHL_156_25Clk, sTbRunCtrl);
343  end process pGenShellClock;
344 
345 
346  -----------------------------------------------------------------------------
347  -- PROC: Generate a Flow Control Cycle on the 'SHL_Rol_Nts0_Udp' interface
348  -- Description
349  -- This process generates a waveform based on the shared variables set
350  -- during the main simulation process.
351  -- Shared Variables:
352  -- vUdpFcReq : request for a new waveform generation
353  -- vUdpFcBegCyc : beginning of the FC activation w/ respect to the request clock cycle
354  -- vUdpFcEndCyc : end of the the FC activation w/ respect to the request clock cycle
355  -----------------------------------------------------------------------------
356  pGenShellUdpFc : process (sSHL_156_25Clk)
357  variable vNow : integer;
358  begin
359  if rising_edge(sSHL_156_25Clk) then
360  if (sSHL_156_25Rst = '1') then
361  sSHL_Rol_Nts0_Udp_Axis_tready <= '1';
362  vNow := -1;
363  else
364  -- Trigger the generation of new waveform
365  if (vUdpFcReq = True) then
366  if (vNoW < 0) then
367  vNow := 0;
368  end if;
369  -- Start of backpreassure
370  if (vNow >= vUdpFcBegCyc) then
371  sSHL_Rol_Nts0_Udp_Axis_tready <= '0';
372  end if;
373  -- End of backpreasssure
374  if (vNow >= vUdpFcEndCyc) then
375  vUdpFcReq := False;
376  sSHL_Rol_Nts0_Udp_Axis_tready <= '1';
377  end if;
378  vNow := vNow + 1;
379  else
380  vNow := -1;
381  end if;
382  end if;
383  end if;
384  end process pGenShellUdpFc;
385 
386 
387  -----------------------------------------------------------------------------
388  -- PROC: Generate a Flow Control Cycle on the 'SHL_Rol_Nts0_Tcp' interface
389  -- Description
390  -- This process generates a waveform based on the shared variables set
391  -- during the main simulation process.
392  -- Shared Variables:
393  -- vTcpFcReq : request for a new waveform generation
394  -- vTcpFcBegCyc : beginning of the FC activation w/ respect to the request clock cycle
395  -- vTcpFcEndCyc : end of the the FC activation w/ respect to the request clock cycle
396  -----------------------------------------------------------------------------
397  pGenShellTcpFc : process (sSHL_156_25Clk)
398  variable vNow : integer;
399  begin
400  if rising_edge(sSHL_156_25Clk) then
401  if (sSHL_156_25Rst = '1') then
402  sSHL_Rol_Nts0_Tcp_Axis_tready <= '1';
403  vNow := -1;
404  else
405  -- Trigger the generation of new waveform
406  if (vTcpFcReq = True) then
407  if (vNoW < 0) then
408  vNow := 0;
409  end if;
410  -- Start of backpreassure
411  if (vNow >= vTcpFcBegCyc) then
412  sSHL_Rol_Nts0_Tcp_Axis_tready <= '0';
413  end if;
414  -- End of backpreasssure
415  if (vNow >= vTcpFcEndCyc) then
416  vTcpFcReq := False;
417  sSHL_Rol_Nts0_Tcp_Axis_tready <= '1';
418  end if;
419  vNow := vNow + 1;
420  else
421  vNow := -1;
422  end if;
423  end if;
424  end if;
425  end process pGenShellTcpFc;
426 
427 
428  ----------------------------------------------------------
429  -- PROC: Main Simulation Process
430  ----------------------------------------------------------
431  pMainSimProc : process is
432 
433  -- Variables
434  variable vTbErrors : integer;
435 
436  -------------------------------------------------------------
437  -- Prdc: Report the number of errors
438  -------------------------------------------------------------
439  procedure pdReportErrors (
440  nbErrors : in integer
441  ) is
442  variable myLine : line;
443  begin
444  write(myLine, string'("*****************************************************************************"));
445  writeline(output, myLine);
446  if (nbErrors > 0) then
447  write(myLine, string'("** END of TESTBENCH - SIMULATION FAILED (KO): Total # error(s) = " ));
448  write(myLine, nbErrors);
449  elsif (nbErrors < 0) then
450  write(myLine, string'("** ABORTING TESTBENCH - FATAL ERROR (Please Check the Console)" ));
451  else
452  write(myLine, string'("** END of TESTBENCH - SIMULATION SUCCEEDED (OK): No Error."));
453  end if;
454  writeline(output, myLine);
455  write(myLine, string'("*****************************************************************************"));
456  writeline(output, myLine);
457 
458  if (nbErrors < 0) then
459  assert FALSE Report "Aborting simulation" severity FAILURE;
460  else
461  assert FALSE Report "Successful end of simulation" severity FAILURE;
462  end if;
463  end pdReportErrors;
464 
465 
466  -----------------------------------------------------------------------------
467  -- Prcd: Generate an Axis Write Cycle on the 'SHL_Rol_Nts0_Udp' interface
468  -----------------------------------------------------------------------------
469  procedure pdAxisWrite_SHL_Rol_Nts0_Udp (
470  bitStr : std_ulogic_vector
471  ) is
472  variable vVec : std_ulogic_vector(bitStr'length - 1 downto 0);
473  variable vLen : integer;
474  variable vI : integer;
475  variable myLine : line;
476  variable vErr : integer;
477  begin
478  -- Assess that the 'input paranmeter is a multiple of 8 bits
479  vVec := bitStr;
480  vLen := vVec'length;
481  vErr := 0;
482 
483  if (vLen mod 8 /= 0) then
484  vTbErrors := -1;
485  pdReportErrors(vTbErrors);
486  report "[FATAL-ERROR] pdAxisWrite_SHELL_Role_Nts0_Udp() - Input parameter must be a multiple of 8 bits. ";
487  end if;
488 
489  vI := vLen;
490  while (vI >= 0) loop
491 
492  wait until rising_edge(sSHL_156_25Clk);
493 
494  if (sROL_Shl_Nts0_Udp_Axis_tready = '1') then
495  if (vI > 8*8) then
496  -- Start and continue with chunks of 64-bits
497  sSHL_Rol_Nts0_Udp_Axis_tdata <= vVec(vI-1 downto vI-64);
498  sSHL_Rol_Nts0_Udp_Axis_tvalid <= '1';
499  sSHL_Rol_Nts0_Udp_Axis_tlast <= '0';
500  sSHL_Rol_Nts0_Udp_Axis_tkeep <= X"FF";
501  vI := vI - 64;
502  elsif (vI /= 0) then
503  -- Last chunk to be transfered
504  sSHL_Rol_Nts0_Udp_Axis_tdata(63 downto 64-vI) <= vVec(vI-1 downto 0);
505  sSHL_Rol_Nts0_Udp_Axis_tvalid <= '1';
506  sSHL_Rol_Nts0_Udp_Axis_tlast <= '1';
507  case (vI) is
508  when 1*8 => sSHL_Rol_Nts0_Udp_Axis_tkeep <= X"80";
509  when 2*8 => sSHL_Rol_Nts0_Udp_Axis_tkeep <= X"C0";
510  when 3*8 => sSHL_Rol_Nts0_Udp_Axis_tkeep <= X"E0";
511  when 4*8 => sSHL_Rol_Nts0_Udp_Axis_tkeep <= X"F0";
512  when 5*8 => sSHL_Rol_Nts0_Udp_Axis_tkeep <= X"F8";
513  when 6*8 => sSHL_Rol_Nts0_Udp_Axis_tkeep <= X"FC";
514  when 7*8 => sSHL_Rol_Nts0_Udp_Axis_tkeep <= X"FE";
515  when 8*8 => sSHL_Rol_Nts0_Udp_Axis_tkeep <= X"FF";
516  end case;
517  vI := 0;
518  else
519  -- End of the Axis Write transfer
520  sSHL_Rol_Nts0_Udp_Axis_tdata <= (others=>'X');
521  sSHL_Rol_Nts0_Udp_Axis_tkeep <= (others=>'X');
522  sSHL_Rol_Nts0_Udp_Axis_tlast <= '0';
523  sSHL_Rol_Nts0_Udp_Axis_tvalid <= '0';
524  return;
525  end if;
526  else
527  write(myLine, string'("[INFO] Cannot write to ROLE/UDP/Axis (sROL_Shl_Nts0_Udp_Axis_tready =0"));
528  writeline(output, myLine);
529  vErr := VErr + 1;
530  end if;
531 
532  end loop;
533 
534  end procedure pdAxisWrite_SHL_Rol_Nts0_Udp;
535 
536 
537  -----------------------------------------------------------------------------
538  -- Prcd: Generate an Axis Write Cycle on the 'SHL_Rol_Nts0_Tcp' interface
539  -----------------------------------------------------------------------------
540  procedure pdAxisWrite_SHL_Rol_Nts0_Tcp (
541  bitStr : std_ulogic_vector
542  ) is
543  variable vVec : std_ulogic_vector(bitStr'length - 1 downto 0);
544  variable vLen : integer;
545  variable vI : integer;
546  begin
547  -- Assess that the 'input paranmeter is a multiple of 8 bits
548  vVec := bitStr;
549  vLen := vVec'length;
550  if (vLen mod 8 /= 0) then
551  vTbErrors := -1;
552  pdReportErrors(vTbErrors);
553  report "[FATAL-ERROR] pdAxisWrite_SHELL_Role_Nts0_Tcp() - Input parameter must be a multiple of 8 bits. ";
554  assert FALSE Report "Aborting simulation" severity FAILURE;
555  end if;
556 
557  vI := vLen;
558  while (vI >= 0) loop
559 
560  wait until rising_edge(sSHL_156_25Clk);
561 
562  if (sSHL_Rol_Nts0_Tcp_Axis_tready = '1') then
563 
564  if (vI > 8*8) then
565  -- Start and continue with chunks of 64-bits
566  sSHL_Rol_Nts0_Tcp_Axis_tdata <= vVec(vI-1 downto vI-64);
567  sSHL_Rol_Nts0_Tcp_Axis_tkeep <= X"FF";
568  sSHL_Rol_Nts0_Tcp_Axis_tlast <= '0';
569  sSHL_Rol_Nts0_Tcp_Axis_tvalid <= '1';
570  if (sROL_Shl_Nts0_Tcp_Axis_tready = '1') then
571  vI := vI - 64;
572  end if;
573  else
574  if (vI /= 0) then
575  -- Last chunk to be transfered
576  sSHL_Rol_Nts0_Tcp_Axis_tdata(63 downto 64-vI) <= vVec(vI-1 downto 0);
577  sSHL_Rol_Nts0_Tcp_Axis_tlast <= '1';
578  sSHL_Rol_Nts0_Tcp_Axis_tvalid <= '1';
579  case (vI) is
580  when 1*8 => sSHL_Rol_Nts0_Tcp_Axis_tkeep <= X"80";
581  when 2*8 => sSHL_Rol_Nts0_Tcp_Axis_tkeep <= X"C0";
582  when 3*8 => sSHL_Rol_Nts0_Tcp_Axis_tkeep <= X"E0";
583  when 4*8 => sSHL_Rol_Nts0_Tcp_Axis_tkeep <= X"F0";
584  when 5*8 => sSHL_Rol_Nts0_Tcp_Axis_tkeep <= X"F8";
585  when 6*8 => sSHL_Rol_Nts0_Tcp_Axis_tkeep <= X"FC";
586  when 7*8 => sSHL_Rol_Nts0_Tcp_Axis_tkeep <= X"FE";
587  when 8*8 => sSHL_Rol_Nts0_Tcp_Axis_tkeep <= X"FF";
588  end case;
589  if (sROL_Shl_Nts0_Tcp_Axis_tready = '1') then
590  vI := 0;
591  end if;
592  else
593  -- End of the Axis Write transfer
594  sSHL_Rol_Nts0_Tcp_Axis_tdata <= (others=>'X');
595  sSHL_Rol_Nts0_Tcp_Axis_tkeep <= (others=>'X');
596  sSHL_Rol_Nts0_Tcp_Axis_tlast <= '0';
597  sSHL_Rol_Nts0_Tcp_Axis_tvalid <= '0';
598  return;
599  end if;
600  end if;
601  end if;
602  end loop;
603  end procedure pdAxisWrite_SHL_Rol_Nts0_Tcp;
604 
605 
606  -------------------------------------------------------------
607  -- Prdc: [TODO - Check the data receveived from the ROLE]
608  -------------------------------------------------------------
609  --procedure pdAssessAxisWrite_ROL_Shl_Nts0_Udp (
610  -- expectedVal: in std_ulogic_vector
611  --) is
612  --begin
613  -- if (False) then
614  -- report "[TbSimError] AxisWrite_ROL_Shl_Nts0_UDp.tdata = " & integer'image(to_integer(unsigned(TODO))) & " - Expected-Value = " & integer'image(expectedVal) severity ERROR;
615  -- vTbErrors := vTbErrors + 1;
616  -- end if;
617  --end pdAssessAxisWrite_ROL_Shl_Nts0_Udp;
618 
619 
620  begin
621 
622 
623  --========================================================================
624  --== STEP-1: INITIALISATION PHASE
625  --========================================================================
626 
627  -- Initialise the error counter
628  vTbErrors := 0;
629 
630  -- Start with SHL_156_25Rst asserted and sTbRunCtrl disabled
631  sSHL_156_25Rst <= '1';
632  sTbRunCtrl <= '0';
633  wait for 25 ns;
634  sTbRunCtrl <= '1';
635 
636  -- Set default signal levels
637  ---- SHELL / Role / Nts0 / Udp Interface
638  sSHL_Rol_Nts0_Udp_Axis_tdata <= (others => '0');
639  sSHL_Rol_Nts0_Udp_Axis_tkeep <= (others => '0');
640  sSHL_Rol_Nts0_Udp_Axis_tlast <= '0';
641  sSHL_Rol_Nts0_Udp_Axis_tvalid <= '0';
642  -- [INFO] The 'tready' signal is initialized by the process 'pGenShellUdpFc'
643  ---- SHELL / Role / Nts0 / Tcp Interface
644  sSHL_Rol_Nts0_Tcp_Axis_tdata <= (others => '0');
645  sSHL_Rol_Nts0_Tcp_Axis_tkeep <= (others => '0');
646  sSHL_Rol_Nts0_Tcp_Axis_tlast <= '0';
647  sSHL_Rol_Nts0_Tcp_Axis_tvalid <= '0';
648  -- [INFO] The 'tready' signal is initialized by the process 'pGenShellTcpFc'
649 
650  wait for 25 ns;
651 
652  -- SHELL / Role / Mmio / Flash Debug Interface
653  ---- MMIO / CTRL_2 Register ----------------
654  sSHL_Rol_Mmio_UdpEchoCtrl <= "00";
655  sSHL_Rol_Mmio_UdpPostPktEn <= '0';
656  sSHL_Rol_Mmio_UdpCaptPktEn <= '0';
657  sSHL_Rol_Mmio_TcpEchoCtrl <= "00";
658  sSHL_Rol_Mmio_TcpPostPktEn <= '0';
659  sSHL_Rol_Mmio_TcpCaptPktEn <= '0';
660 
661  wait for 25 ns;
662 
663  -- Release the reset
664  sSHL_156_25Rst <= '0';
665  wait for 25 ns;
666 
667  wait until rising_edge(sSHL_156_25Clk);
668 
669  --========================================================================
670  --== STEP-2: Write SHELL_Role_Nts0_Udp_Axis
671  --========================================================================
672 
673  pdAxisWrite_SHL_Rol_Nts0_Udp(X"0000000000000000_1111111111111111_2222222222222222_3333333333333333_4444444444444444_5555555555555555_6666666666666666_7777777777777777");
674 
675  pdAxisWrite_SHL_Rol_Nts0_Udp(X"8888888888888888_9999999999999999_CAFEFADE");
676 
677  pdAxisWrite_SHL_Rol_Nts0_Udp(X"AAAAAAAAAAAAAAAA_BEEF");
678 
679  --========================================================================
680  --== STEP-3: Write SHELL_Role_Nts0_Tcp_Axis
681  --========================================================================
682 
683  pdAxisWrite_SHL_Rol_Nts0_Tcp(X"0000000000000000_1111111111111111_2222222222222222_3333333333333333_4444444444444444_5555555555555555_6666666666666666_7777777777777777");
684 
685  pdAxisWrite_SHL_Rol_Nts0_Tcp(X"8888888888888888_9999999999999999_CAFEFADE");
686 
687  pdAxisWrite_SHL_Rol_Nts0_Tcp(X"AAAAAAAAAAAAAAAA_BEEF");
688 
689  --========================================================================
690  --== STEP-4: Write SHELL_Role_Nts0_Udp_Axis while Activating Flow Control
691  --========================================================================
692 
693  pgGenShellUdpFc(2, 4);
694  pdAxisWrite_SHL_Rol_Nts0_Udp(X"0000000000000000_1010101010101010_2020202020202020_3030303030303030_4040404040404040_5050505050505050_6060606060606060_7070707070707070");
695 
696  --========================================================================
697  --== STEP-5: Write SHELL_Role_Nts0_Tcp_Axis while Activating Flow Control
698  --========================================================================
699 
700  pgGenShellTcpFc(1, 5);
701  pdAxisWrite_SHL_Rol_Nts0_Tcp(X"0000000000000000_1010101010101010_2020202020202020_3030303030303030_4040404040404040_5050505050505050_6060606060606060_7070707070707070");
702 
703  --========================================================================
704  --== STEP-6: Enable the Posting of UDP Packets
705  --========================================================================
706  sSHL_Rol_Mmio_UdpEchoCtrl <= "10";
707  sSHL_Rol_Mmio_UdpPostPktEn <= '1';
708  wait for 200 ns;
709 
710  --========================================================================
711  --== END OF TESTBENCH
712  --========================================================================
713 
714  wait for 50 ns;
715  sTbRunCtrl <= '0';
716  wait for 50 ns;
717 
718  -- End of tb --> Report errors
719  pdReportErrors(vTbErrors);
720 
721  end process pMainSimProc;
722 
723  end Behavioral;