OpenCores
URL https://opencores.org/ocsvn/rio/rio/trunk

Subversion Repositories rio

[/] [rio/] [branches/] [parallelSymbols/] [bench/] [vhdl/] [TestRioSerial.vhd] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 magro732
-------------------------------------------------------------------------------
2
-- 
3
-- RapidIO IP Library Core
4
-- 
5
-- This file is part of the RapidIO IP library project
6
-- http://www.opencores.org/cores/rio/
7
-- 
8
-- Description
9
-- Contains automatic simulation test code to verify a RioSerial implementation.
10
-- 
11
-- To Do:
12
-- -
13
-- 
14
-- Author(s): 
15
-- - Magnus Rosenius, magro732@opencores.org 
16
-- 
17
-------------------------------------------------------------------------------
18
-- 
19
-- Copyright (C) 2013 Authors and OPENCORES.ORG 
20
-- 
21
-- This source file may be used and distributed without 
22
-- restriction provided that this copyright statement is not 
23
-- removed from the file and that any derivative work contains 
24
-- the original copyright notice and the associated disclaimer. 
25
-- 
26
-- This source file is free software; you can redistribute it 
27
-- and/or modify it under the terms of the GNU Lesser General 
28
-- Public License as published by the Free Software Foundation; 
29
-- either version 2.1 of the License, or (at your option) any 
30
-- later version. 
31
-- 
32
-- This source is distributed in the hope that it will be 
33
-- useful, but WITHOUT ANY WARRANTY; without even the implied 
34
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
35
-- PURPOSE. See the GNU Lesser General Public License for more 
36
-- details. 
37
-- 
38
-- You should have received a copy of the GNU Lesser General 
39
-- Public License along with this source; if not, download it 
40
-- from http://www.opencores.org/lgpl.shtml 
41
-- 
42
-------------------------------------------------------------------------------
43
 
44
 
45
-------------------------------------------------------------------------------
46
-- TestRioSerial.
47
-------------------------------------------------------------------------------
48
 
49
library ieee;
50
use ieee.std_logic_1164.all;
51
use ieee.numeric_std.all;
52
library std;
53
use std.textio.all;
54
use work.rio_common.all;
55
 
56
 
57
-------------------------------------------------------------------------------
58
-- Entity for TestRioSerial.
59
-------------------------------------------------------------------------------
60
entity TestRioSerial is
61
end entity;
62
 
63
 
64
-------------------------------------------------------------------------------
65
-- Architecture for TestUart.
66
-------------------------------------------------------------------------------
67
architecture TestRioSerialImpl of TestRioSerial is
68
 
69
  component TestSwitchPort is
70 12 magro732
    generic(
71 26 magro732
      NUMBER_WORDS : natural range 1 to 4 := 1);
72 4 magro732
    port(
73
      clk : in std_logic;
74
      areset_n : in std_logic;
75
 
76
      frameValid_i : in std_logic_vector(0 to 63);
77
      frameWrite_i : in RioFrameArray(0 to 63);
78 15 magro732
      frameComplete_o : out std_logic_vector(0 to 63);
79 4 magro732
 
80
      frameExpected_i : in std_logic;
81
      frameRead_i : in RioFrame;
82
      frameReceived_o : out std_logic;
83
 
84
      readFrameEmpty_o : out std_logic;
85
      readFrame_i : in std_logic;
86
      readFrameRestart_i : in std_logic;
87
      readFrameAborted_o : out std_logic;
88
 
89
      readWindowEmpty_o : out std_logic;
90
      readWindowReset_i : in std_logic;
91
      readWindowNext_i : in std_logic;
92
 
93
      readContentEmpty_o : out std_logic;
94
      readContent_i : in std_logic;
95
      readContentEnd_o : out std_logic;
96 26 magro732
      readContentData_o : out std_logic_vector(2+(32*NUMBER_WORDS-1) downto 0);
97 4 magro732
 
98
      writeFrameFull_o : out std_logic;
99
      writeFrame_i : in std_logic;
100
      writeFrameAbort_i : in std_logic;
101
      writeContent_i : in std_logic;
102 26 magro732
      writeContentData_i : in std_logic_vector(2+(32*NUMBER_WORDS-1) downto 0));
103 4 magro732
  end component;
104
 
105
  component RioSerial is
106
    generic(
107 26 magro732
      TIMEOUT_WIDTH : natural := 20;
108
      NUMBER_WORDS : natural range 1 to 4 := 1);
109 4 magro732
    port(
110
      clk : in std_logic;
111
      areset_n : in std_logic;
112
 
113
      portLinkTimeout_i : in std_logic_vector(TIMEOUT_WIDTH-1 downto 0);
114
      linkInitialized_o : out std_logic;
115
      inputPortEnable_i : in std_logic;
116
      outputPortEnable_i : in std_logic;
117
 
118
      localAckIdWrite_i : in std_logic;
119
      clrOutstandingAckId_i : in std_logic;
120
      inboundAckId_i : in std_logic_vector(4 downto 0);
121
      outstandingAckId_i : in std_logic_vector(4 downto 0);
122
      outboundAckId_i : in std_logic_vector(4 downto 0);
123
      inboundAckId_o : out std_logic_vector(4 downto 0);
124
      outstandingAckId_o : out std_logic_vector(4 downto 0);
125
      outboundAckId_o : out std_logic_vector(4 downto 0);
126
 
127
      readFrameEmpty_i : in std_logic;
128
      readFrame_o : out std_logic;
129
      readFrameRestart_o : out std_logic;
130
      readFrameAborted_i : in std_logic;
131
      readWindowEmpty_i : in std_logic;
132
      readWindowReset_o : out std_logic;
133
      readWindowNext_o : out std_logic;
134
      readContentEmpty_i : in std_logic;
135
      readContent_o : out std_logic;
136
      readContentEnd_i : in std_logic;
137 26 magro732
      readContentData_i : in std_logic_vector(2+(32*NUMBER_WORDS-1) downto 0);
138 4 magro732
 
139
      writeFrameFull_i : in std_logic;
140
      writeFrame_o : out std_logic;
141
      writeFrameAbort_o : out std_logic;
142
      writeContent_o : out std_logic;
143 26 magro732
      writeContentData_o : out std_logic_vector(2+(32*NUMBER_WORDS-1) downto 0);
144 4 magro732
 
145
      portInitialized_i : in std_logic;
146 16 magro732
      outboundSymbolFull_i : in std_logic;
147
      outboundSymbolWrite_o : out std_logic;
148 26 magro732
      outboundSymbolType_o : out std_logic_vector(2*NUMBER_WORDS-1 downto 0);
149
      outboundSymbol_o : out std_logic_vector(32*NUMBER_WORDS-1 downto 0);
150 16 magro732
      inboundSymbolEmpty_i : in std_logic;
151
      inboundSymbolRead_o : out std_logic;
152 26 magro732
      inboundSymbolType_i : in std_logic_vector(2*NUMBER_WORDS-1 downto 0);
153
      inboundSymbol_i : in std_logic_vector(32*NUMBER_WORDS-1 downto 0));
154 4 magro732
  end component;
155
 
156 26 magro732
  constant NUMBER_WORDS : natural range 1 to 4 := 2;
157 12 magro732
 
158 4 magro732
  signal clk : std_logic;
159
  signal areset_n : std_logic;
160
 
161
  signal portLinkTimeout : std_logic_vector(10 downto 0);
162
  signal linkInitialized : std_logic;
163
  signal inputPortEnable : std_logic;
164
  signal outputPortEnable : std_logic;
165
 
166
  signal localAckIdWrite : std_logic;
167
  signal clrOutstandingAckId : std_logic;
168
  signal inboundAckIdWrite : std_logic_vector(4 downto 0);
169
  signal outstandingAckIdWrite : std_logic_vector(4 downto 0);
170
  signal outboundAckIdWrite : std_logic_vector(4 downto 0);
171
  signal inboundAckIdRead : std_logic_vector(4 downto 0);
172
  signal outstandingAckIdRead : std_logic_vector(4 downto 0);
173
  signal outboundAckIdRead : std_logic_vector(4 downto 0);
174
 
175
  signal portInitialized : std_logic;
176 16 magro732
  signal outboundSymbolFull : std_logic;
177
  signal outboundSymbolWrite : std_logic;
178 26 magro732
  signal outboundSymbolType : std_logic_vector(2*NUMBER_WORDS-1 downto 0);
179
  signal outboundSymbol : std_logic_vector(32*NUMBER_WORDS-1 downto 0);
180 16 magro732
  signal inboundSymbolEmpty : std_logic;
181
  signal inboundSymbolRead : std_logic;
182 26 magro732
  signal inboundSymbolType : std_logic_vector(2*NUMBER_WORDS-1 downto 0);
183
  signal inboundSymbol : std_logic_vector(32*NUMBER_WORDS-1 downto 0);
184 4 magro732
 
185
  signal readFrameEmpty : std_logic;
186
  signal readFrame : std_logic;
187
  signal readFrameRestart : std_logic;
188
  signal readFrameAborted : std_logic;
189
  signal readWindowEmpty : std_logic;
190
  signal readWindowReset : std_logic;
191
  signal readWindowNext : std_logic;
192
  signal readContentEmpty : std_logic;
193
  signal readContent : std_logic;
194
  signal readContentEnd : std_logic;
195 26 magro732
  signal readContentData : std_logic_vector(2+(32*NUMBER_WORDS-1) downto 0);
196 4 magro732
 
197
  signal writeFrameFull : std_logic;
198
  signal writeFrame : std_logic;
199
  signal writeFrameAbort : std_logic;
200
  signal writeContent : std_logic;
201 26 magro732
  signal writeContentData : std_logic_vector(2+(32*NUMBER_WORDS-1) downto 0);
202 4 magro732
 
203
  signal frameValid : std_logic_vector(0 to 63);
204
  signal frameWrite : RioFrameArray(0 to 63);
205 15 magro732
  signal frameComplete : std_logic_vector(0 to 63);
206 4 magro732
  signal frameExpected : std_logic;
207
  signal frameRead : RioFrame;
208
  signal frameReceived : std_logic;
209
 
210
begin
211
 
212
  -----------------------------------------------------------------------------
213
  -- Clock generation.
214
  -----------------------------------------------------------------------------
215
  ClockGenerator: process
216
  begin
217
    clk <= '0';
218
    wait for 20 ns;
219
    clk <= '1';
220
    wait for 20 ns;
221
  end process;
222
 
223
 
224
  -----------------------------------------------------------------------------
225
  -- Serial protocol test driver.
226
  -----------------------------------------------------------------------------
227
  TestDriver: process
228
 
229 26 magro732
    variable inboundSymbolIndex : natural := 0;
230
    variable outboundSymbolIndex : natural := 0;
231
 
232 4 magro732
    ---------------------------------------------------------------------------
233
    -- Procedure to receive a symbol.
234
    ---------------------------------------------------------------------------
235
    procedure ReceiveSymbol(
236
      constant symbolType : in std_logic_vector(1 downto 0);
237 18 magro732
      constant symbolContent : in std_logic_vector(31 downto 0) := x"00000000";
238
      constant acceptIdle : in boolean := true) is
239 4 magro732
    begin
240 16 magro732
      outboundSymbolFull <= '0';
241 4 magro732
 
242 26 magro732
      if (outboundSymbolIndex = NUMBER_WORDS) then
243
        outboundSymbolIndex := 0;
244
        wait until clk'event and clk = '1' and outboundSymbolWrite = '1';
245
      end if;
246
 
247 18 magro732
      if (acceptIdle) then
248 26 magro732
        while ((outboundSymbolType(2*(outboundSymbolIndex+1)-1 downto 2*(outboundSymbolIndex)) = SYMBOL_IDLE) and
249 18 magro732
               (symbolType /= SYMBOL_IDLE)) loop
250 26 magro732
          outboundSymbolIndex := outboundSymbolIndex + 1;
251
          if (outboundSymbolIndex = NUMBER_WORDS) then
252
            outboundSymbolIndex := 0;
253
            wait until clk'event and clk = '1' and outboundSymbolWrite = '1';
254
          end if;
255 18 magro732
        end loop;
256
      end if;
257 12 magro732
 
258 26 magro732
      assert symbolType = outboundSymbolType(2*(outboundSymbolIndex+1)-1 downto 2*(outboundSymbolIndex))
259 4 magro732
        report "Missmatching symbol type:expected=" &
260
        integer'image(to_integer(unsigned(symbolType))) &
261
        " got=" &
262 26 magro732
        integer'image(to_integer(unsigned(outboundSymbolType(2*(outboundSymbolIndex+1)-1 downto 2*(outboundSymbolIndex)))))
263 4 magro732
        severity error;
264
 
265 26 magro732
      if (outboundSymbolType(2*(outboundSymbolIndex+1)-1 downto 2*(outboundSymbolIndex)) = SYMBOL_CONTROL) then
266
        assert symbolContent(31 downto 8) = outboundSymbol(32*(outboundSymbolIndex+1)-1 downto 32*outboundSymbolIndex+8)
267 4 magro732
          report "Missmatching symbol content:expected=" &
268
          integer'image(to_integer(unsigned(symbolContent(31 downto 8)))) &
269
          " got=" &
270 26 magro732
          integer'image(to_integer(unsigned(outboundSymbol(32*(outboundSymbolIndex+1)-1 downto 32*outboundSymbolIndex+8))))
271 4 magro732
          severity error;
272 26 magro732
      elsif (outboundSymbolType(2*(outboundSymbolIndex+1)-1 downto 2*(outboundSymbolIndex)) = SYMBOL_DATA) then
273
        assert symbolContent(31 downto 0) = outboundSymbol(32*(outboundSymbolIndex+1)-1 downto 32*outboundSymbolIndex)
274 4 magro732
          report "Missmatching symbol content:expected=" &
275 12 magro732
          integer'image(to_integer(unsigned(symbolContent(31 downto 0)))) &
276 4 magro732
          " got=" &
277 26 magro732
          integer'image(to_integer(unsigned(outboundSymbol(32*(outboundSymbolIndex+1)-1 downto 32*outboundSymbolIndex))))
278 4 magro732
          severity error;
279
      end if;
280
 
281 26 magro732
      outboundSymbolIndex := outboundSymbolIndex + 1;
282 16 magro732
      outboundSymbolFull <= '1';
283 4 magro732
    end procedure;
284
 
285
    ---------------------------------------------------------------------------
286
    -- Procedure to send a symbol.
287
    ---------------------------------------------------------------------------
288
    procedure SendSymbol(
289
      constant symbolType : in std_logic_vector(1 downto 0);
290 26 magro732
      constant symbolContent : in std_logic_vector(31 downto 0) := x"00000000";
291
      constant flush : in boolean := false) is
292 4 magro732
    begin
293 16 magro732
      inboundSymbolEmpty <= '0';
294 26 magro732
      inboundSymbolType(2*(inboundSymbolIndex+1)-1 downto 2*inboundSymbolIndex) <= symbolType;
295
      inboundSymbol(32*(inboundSymbolIndex+1)-1 downto 32*inboundSymbolIndex) <= symbolContent;
296 4 magro732
 
297 26 magro732
      inboundSymbolIndex := inboundSymbolIndex + 1;
298
      if (flush or (inboundSymbolIndex = NUMBER_WORDS)) then
299
        wait until clk'event and clk = '1' and inboundSymbolRead = '1';
300
        inboundSymbolIndex := 0;
301
        inboundSymbolType <= (others=>'0');
302
        inboundSymbol <= (others=>'0');
303
      end if;
304
 
305 16 magro732
      inboundSymbolEmpty <= '1';
306 4 magro732
    end procedure;
307
 
308
    ---------------------------------------------------------------------------
309
    -- Process variables.
310
    ---------------------------------------------------------------------------
311
    variable seed1 : positive := 1;
312
    variable seed2 : positive := 1;
313
    variable payload : RioPayload;
314
 
315
    variable frame : RioFrame;
316
 
317
  begin
318
    ---------------------------------------------------------------------------
319
    -- Test case initialization.
320
    ---------------------------------------------------------------------------
321
 
322
    frameValid <= (others=>'0');
323
    frameExpected <= '0';
324
 
325
    portLinkTimeout <= (others=>'1');
326
    inputPortEnable <= '1';
327
    outputPortEnable <= '1';
328
 
329
    portInitialized <= '0';
330 16 magro732
    outboundSymbolFull <= '1';
331
    inboundSymbolEmpty <= '1';
332 26 magro732
    inboundSymbolType <= (others=>'0');
333 4 magro732
    inboundSymbol <= (others => '0');
334
 
335
    localAckIdWrite <= '0';
336
    clrOutstandingAckId <= '0';
337
    inboundAckIdWrite <= (others=>'0');
338
    outstandingAckIdWrite <= (others=>'0');
339
    outboundAckIdWrite <= (others=>'0');
340
 
341
    -- Generate a startup reset pulse.
342
    areset_n <= '0';
343
    wait until clk'event and clk = '1';
344
    wait until clk'event and clk = '1';
345
    areset_n <= '1';
346
    wait until clk'event and clk = '1';
347
    wait until clk'event and clk = '1';
348
 
349
    ---------------------------------------------------------------------------
350
    PrintS("-----------------------------------------------------------------");
351
    PrintS("TG_RioSerial");
352
    PrintS("-----------------------------------------------------------------");
353
    PrintS("TG_RioSerial-TC1");
354
    PrintS("Description: Test idle-sequence transmission at startup.");
355
    PrintS("Requirement: XXXXX");
356
    PrintS("-----------------------------------------------------------------");
357
    PrintS("Step 1:");
358
    PrintS("Action: Read transmission port.");
359
    PrintS("Result: Idle sequence symbols should be read.");
360
    ---------------------------------------------------------------------------
361
    PrintR("TG_RioSerial-TC1-Step1");
362
    ---------------------------------------------------------------------------
363
 
364
    -- Make sure only idle-sequences are transmitted at startup.
365
    for i in 0 to 1024 loop
366
      ReceiveSymbol(SYMBOL_IDLE);
367
    end loop;
368
 
369
    ---------------------------------------------------------------------------
370
    PrintS("-----------------------------------------------------------------");
371
    PrintS("TG_RioSerial-TC2");
372
    PrintS("Description: Test idle-sequence and status symbol transmission");
373
    PrintS("             when the port has been initialized.");
374
    PrintS("Requirement: XXXXX");
375
    PrintS("-----------------------------------------------------------------");
376
    PrintS("Step 1:");
377
    PrintS("Action: Set port initialized and read transmission port.");
378
    PrintS("Result: Idle sequence and status symbols should be read.");
379
    ---------------------------------------------------------------------------
380
    PrintR("TG_RioSerial-TC2-Step1");
381
    ---------------------------------------------------------------------------
382
 
383
    -- Initialize the port to trigger a change of state.
384
    portInitialized <= '1';
385
 
386
    -- The transmitter should send idle sequences at startup and a status once
387
    -- in a while.
388 26 magro732
    -- REMARK: Find out why 4 additional idle are sent...
389
    for i in 0 to 259 loop
390 18 magro732
      ReceiveSymbol(SYMBOL_IDLE);
391
    end loop;
392
    ReceiveSymbol(SYMBOL_CONTROL,
393
                  RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
394
                                         STYPE1_NOP, "000"),
395
                  false);
396 4 magro732
    for i in 0 to 254 loop
397
      ReceiveSymbol(SYMBOL_IDLE);
398
    end loop;
399
    ReceiveSymbol(SYMBOL_CONTROL,
400
                  RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
401 18 magro732
                                         STYPE1_NOP, "000"),
402
                  false);
403 4 magro732
    for i in 0 to 254 loop
404
      ReceiveSymbol(SYMBOL_IDLE);
405
    end loop;
406
    ReceiveSymbol(SYMBOL_CONTROL,
407
                  RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
408 18 magro732
                                         STYPE1_NOP, "000"),
409
                  false);
410 4 magro732
 
411
    ---------------------------------------------------------------------------
412
    PrintS("-----------------------------------------------------------------");
413
    PrintS("Step 2:");
414
    PrintS("Action: Toggle port initialized pin and check that no status ");
415
    PrintS("        symbols are transmitted when uninitialized.");
416
    PrintS("Result: Only idle sequences should be read when uninitialized.");
417
    ---------------------------------------------------------------------------
418
    PrintR("TG_RioSerial-TC2-Step2");
419
    ---------------------------------------------------------------------------
420
 
421
    -- Deassert the port initialized flag.
422
    portInitialized <= '0';
423
 
424
    -- Make sure only idle-sequences are transmitted at startup.
425
    for i in 0 to 1024 loop
426
      ReceiveSymbol(SYMBOL_IDLE);
427
    end loop;
428
 
429
    -- Initialize the port to trigger a change of state.
430
    portInitialized <= '1';
431
 
432
    -- The transmitter should send idle sequences at startup and a status once
433
    -- in a while.
434 26 magro732
    for i in 0 to 259 loop
435 18 magro732
      ReceiveSymbol(SYMBOL_IDLE);
436
    end loop;
437
    ReceiveSymbol(SYMBOL_CONTROL,
438
                  RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
439
                                         STYPE1_NOP, "000"),
440
                  false);
441 4 magro732
    for i in 0 to 254 loop
442
      ReceiveSymbol(SYMBOL_IDLE);
443
    end loop;
444
    ReceiveSymbol(SYMBOL_CONTROL,
445
                  RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
446 18 magro732
                                         STYPE1_NOP, "000"),
447
                  false);
448 4 magro732
    for i in 0 to 254 loop
449
      ReceiveSymbol(SYMBOL_IDLE);
450
    end loop;
451
    ReceiveSymbol(SYMBOL_CONTROL,
452
                  RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
453 18 magro732
                                         STYPE1_NOP, "000"),
454
                  false);
455 4 magro732
 
456
    ---------------------------------------------------------------------------
457
    PrintS("-----------------------------------------------------------------");
458
    PrintS("Step 3:");
459
    PrintS("Action: Send one error free status symbol to trigger the ");
460
    PrintS("        transmission of status symbols with a higher frequency.");
461
    PrintS("Result: Idle sequence and status symbols should be read but ");
462
    PrintS("        status symbols should be recived more often.");
463
    ---------------------------------------------------------------------------
464
    PrintR("TG_RioSerial-TC2-Step3");
465
    ---------------------------------------------------------------------------
466
 
467
    -- A received error-free status triggers transmission of status symbols in
468 26 magro732
    -- a more rapid pace.
469 4 magro732
    SendSymbol(SYMBOL_CONTROL,
470
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
471 26 magro732
                                      STYPE1_NOP, "000"),
472
               true);
473 4 magro732
 
474
    -- The transmitter should send at least 15 additional statuses after
475
    -- receiving an error free status.
476
    for j in 0 to 15 loop
477
      for i in 0 to 15 loop
478
        ReceiveSymbol(SYMBOL_IDLE);
479
      end loop;
480
 
481
      ReceiveSymbol(SYMBOL_CONTROL,
482
                    RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
483 18 magro732
                                           STYPE1_NOP, "000"),
484
                    false);
485 4 magro732
    end loop;
486
 
487
    ---------------------------------------------------------------------------
488
    PrintS("-----------------------------------------------------------------");
489
    PrintS("Step 4:");
490
    PrintS("Action: Send one errornous status symbol to restart the status ");
491
    PrintS("        counting.");
492
    PrintS("Result: Idle sequence and status symbols should be read but ");
493
    PrintS("        status symbols should still be received more often.");
494
    ---------------------------------------------------------------------------
495
    PrintR("TG_RioSerial-TC2-Step4");
496
    ---------------------------------------------------------------------------
497
 
498
    -- REMARK: Add this...
499
    PrintR("Not implemented.");
500
 
501
    ---------------------------------------------------------------------------
502
    PrintS("-----------------------------------------------------------------");
503
    PrintS("Step 5:");
504
    PrintS("Action: Send one errornous status symbol to restart the status ");
505
    PrintS("        counting.");
506
    PrintS("Result: Idle sequence and status symbols should be read but ");
507
    PrintS("        status symbols should still be received more often.");
508
    ---------------------------------------------------------------------------
509
    PrintR("TG_RioSerial-TC2-Step5");
510
    ---------------------------------------------------------------------------
511
 
512
    -- Make the link fully initialized by sending 7 additional statuses.
513 26 magro732
    for i in 0 to 5 loop
514 4 magro732
      SendSymbol(SYMBOL_CONTROL,
515
                 RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
516
                                        STYPE1_NOP, "000"));
517
    end loop;
518 26 magro732
    SendSymbol(SYMBOL_CONTROL,
519
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
520
                                      STYPE1_NOP, "000"),
521
               true);
522 4 magro732
 
523 18 magro732
    -- Tick the transmitter by reading it and check that the link is initialized.
524 13 magro732
    ReceiveSymbol(SYMBOL_IDLE);
525
    ReceiveSymbol(SYMBOL_IDLE);
526 16 magro732
    ReceiveSymbol(SYMBOL_IDLE);
527 4 magro732
    wait until linkInitialized = '1';
528
 
529
    ---------------------------------------------------------------------------
530
    PrintS("-----------------------------------------------------------------");
531
    PrintS("TG_RioSerial-TC3");
532
    PrintS("Description: Test port reception.");
533
    PrintS("Requirement: XXXXX");
534
    PrintS("-----------------------------------------------------------------");
535
    PrintS("Step 1:");
536
    PrintS("Action: Send an inbound frame with pad after the CRC.");
537
    PrintS("Result: The frame should end up in a frame buffer.");
538
    ---------------------------------------------------------------------------
539
    PrintR("TG_RioSerial-TC3-Step1");
540
    ---------------------------------------------------------------------------
541
 
542
    -- Create the frame.
543
    CreateRandomPayload(payload.data, seed1, seed2);
544
    payload.length := 1;
545
    frame := RioFrameCreate(ackId=>"00000", vc=>'0', crf=>'0', prio=>"00",
546
                            tt=>"01", ftype=>"0000",
547
                            sourceId=>x"0000", destId=>x"0000",
548
                            payload=>payload);
549
    frameExpected <= '1';
550
    frameRead <= frame;
551
 
552
    -- Start the reception of a frame.
553
    SendSymbol(SYMBOL_CONTROL,
554
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
555
                                      STYPE1_START_OF_PACKET, "000"));
556
 
557
    -- Send the data symbols of the frame.
558
    for i in 0 to frame.length-1 loop
559
      SendSymbol(SYMBOL_DATA, frame.payload(i));
560
    end loop;
561
 
562
    -- End the reception of the frame.
563
    SendSymbol(SYMBOL_CONTROL,
564
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
565
                                      STYPE1_END_OF_PACKET, "000"));
566
 
567
    -- Check that the frame has been received in the frame buffer.
568
    wait until frameReceived = '1';
569
    frameExpected <= '0';
570
 
571
    -- Receive acknowledge for the transmitted frame.
572
    ReceiveSymbol(SYMBOL_CONTROL,
573
                  RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00000", "11111",
574
                                         STYPE1_NOP, "000"));
575
 
576
 
577
    ---------------------------------------------------------------------------
578
    PrintS("-----------------------------------------------------------------");
579
    PrintS("Step 2:");
580
    PrintS("Action: Send an inbound frame without a pad after the CRC.");
581
    PrintS("Result: The frame should end up in a frame buffer.");
582
    ---------------------------------------------------------------------------
583
    PrintR("TG_RioSerial-TC3-Step2");
584
    ---------------------------------------------------------------------------
585
 
586
    -- Create the frame.
587
    CreateRandomPayload(payload.data, seed1, seed2);
588
    payload.length := 2;
589
    frame := RioFrameCreate(ackId=>"00001", vc=>'0', crf=>'0', prio=>"00",
590
                            tt=>"01", ftype=>"0000",
591
                            sourceId=>x"0000", destId=>x"0000",
592
                            payload=>payload);
593
    frameExpected <= '1';
594
    frameRead <= frame;
595
 
596
    -- Start the reception of a frame.
597
    SendSymbol(SYMBOL_CONTROL,
598
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
599
                                      STYPE1_START_OF_PACKET, "000"));
600
 
601
    -- Send the data symbols of the frame.
602
    for i in 0 to frame.length-1 loop
603
      SendSymbol(SYMBOL_DATA, frame.payload(i));
604
    end loop;
605
 
606
    -- End the reception of the frame.
607
    SendSymbol(SYMBOL_CONTROL,
608
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
609
                                      STYPE1_END_OF_PACKET, "000"));
610
 
611
    -- Check that the frame has been received in the frame buffer.
612
    wait until frameReceived = '1';
613
    frameExpected <= '0';
614
 
615
    -- Receive an idle symbol left in the FIFO before the ack was generated.
616
    ReceiveSymbol(SYMBOL_IDLE);
617
 
618
    -- Receive acknowledge for the transmited frame.
619
    ReceiveSymbol(SYMBOL_CONTROL,
620
                  RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00001", "11111",
621
                                         STYPE1_NOP, "000"));
622
 
623
    ---------------------------------------------------------------------------
624
    PrintS("-----------------------------------------------------------------");
625
    PrintS("Step 3:");
626
    PrintS("Action: Send an inbound frame with maximum size.");
627
    PrintS("Result: The frame should end up in a frame buffer.");
628
    ---------------------------------------------------------------------------
629
    PrintR("TG_RioSerial-TC3-Step3");
630
    ---------------------------------------------------------------------------
631
 
632
    -- Create the frame.
633
    CreateRandomPayload(payload.data, seed1, seed2);
634
    payload.length := 133;
635
    frame := RioFrameCreate(ackId=>"00010", vc=>'0', crf=>'0', prio=>"00",
636
                            tt=>"01", ftype=>"0000",
637
                            sourceId=>x"0000", destId=>x"0000",
638
                            payload=>payload);
639
    frameExpected <= '1';
640
    frameRead <= frame;
641
 
642
    -- Start the reception of a frame.
643
    SendSymbol(SYMBOL_CONTROL,
644
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
645
                                      STYPE1_START_OF_PACKET, "000"));
646
 
647
    -- Send the data symbols of the frame.
648
    for i in 0 to frame.length-1 loop
649
      SendSymbol(SYMBOL_DATA, frame.payload(i));
650
    end loop;
651
 
652
    -- End the reception of the frame.
653
    SendSymbol(SYMBOL_CONTROL,
654
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
655
                                      STYPE1_END_OF_PACKET, "000"));
656
 
657
    -- Check that the frame has been received in the frame buffer.
658
    wait until frameReceived = '1';
659
    frameExpected <= '0';
660
 
661
    -- Receive an idle symbol left in the FIFO before the ack was generated.
662
    ReceiveSymbol(SYMBOL_IDLE);
663
 
664
    -- Receive acknowledge for the transmitted frame.
665
    ReceiveSymbol(SYMBOL_CONTROL,
666
                  RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00010", "11111",
667
                                         STYPE1_NOP, "000"));
668
 
669
 
670
    ---------------------------------------------------------------------------
671
    PrintS("-----------------------------------------------------------------");
672
    PrintS("Step 4:");
673
    PrintS("Action: Send two packets without end-of-packet in between.");
674
    PrintS("Result: Both packets should be accepted.");
675
    ---------------------------------------------------------------------------
676
    PrintR("TG_RioSerial-TC3-Step4");
677
    ---------------------------------------------------------------------------
678
 
679
    -- Create the first frame.
680
    CreateRandomPayload(payload.data, seed1, seed2);
681
    payload.length := 10;
682
    frame := RioFrameCreate(ackId=>"00011", vc=>'0', crf=>'0', prio=>"00",
683
                            tt=>"01", ftype=>"0000",
684
                            sourceId=>x"0000", destId=>x"0000",
685
                            payload=>payload);
686
    frameExpected <= '1';
687
    frameRead <= frame;
688
 
689
    -- Start the reception of a frame.
690
    SendSymbol(SYMBOL_CONTROL,
691
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
692
                                      STYPE1_START_OF_PACKET, "000"));
693
 
694
    -- Send the data symbols of the frame.
695
    for i in 0 to frame.length-1 loop
696
      SendSymbol(SYMBOL_DATA, frame.payload(i));
697
    end loop;
698
 
699
    -- Start the reception of a frame, implicitly ending the previous.
700
    SendSymbol(SYMBOL_CONTROL,
701
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
702
                                      STYPE1_START_OF_PACKET, "000"));
703
 
704
    -- Check that the frame has been received in the frame buffer.
705
    wait until frameReceived = '1';
706
    frameExpected <= '0';
707
    wait until clk'event and clk = '1';
708
 
709
    -- Receive an idle symbol left in the FIFO before the ack was generated.
710
    ReceiveSymbol(SYMBOL_IDLE);
711
 
712
    -- Receive acknowledge for the transmitted frame.
713
    ReceiveSymbol(SYMBOL_CONTROL,
714
                  RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00011", "11111",
715
                                         STYPE1_NOP, "000"));
716
 
717
    -- Create the second frame.
718
    CreateRandomPayload(payload.data, seed1, seed2);
719
    payload.length := 13;
720
    frame := RioFrameCreate(ackId=>"00100", vc=>'0', crf=>'0', prio=>"00",
721
                            tt=>"01", ftype=>"0000",
722
                            sourceId=>x"0000", destId=>x"0000",
723
                            payload=>payload);
724
    frameExpected <= '1';
725
    frameRead <= frame;
726
 
727
    -- Send the data symbols of the frame.
728
    for i in 0 to frame.length-1 loop
729
      SendSymbol(SYMBOL_DATA, frame.payload(i));
730
    end loop;
731
 
732
    -- End the reception of the frame.
733
    SendSymbol(SYMBOL_CONTROL,
734
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
735
                                      STYPE1_END_OF_PACKET, "000"));
736
 
737
    -- Check that the frame has been received in the frame buffer.
738
    wait until frameReceived = '1';
739
    frameExpected <= '0';
740
 
741
    -- Receive an idle symbol left in the FIFO before the ack was generated.
742
    ReceiveSymbol(SYMBOL_IDLE);
743
 
744
    -- Receive acknowledge for the transmitted frame.
745
    ReceiveSymbol(SYMBOL_CONTROL,
746
                  RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00100", "11111",
747
                                         STYPE1_NOP, "000"));
748
 
749
    ---------------------------------------------------------------------------
750
    PrintS("-----------------------------------------------------------------");
751
    PrintS("Step 5:");
752
    PrintS("Action: Start to send a packet. Abort it with stomp. Then send ");
753
    PrintS("        another packet.");
754
    PrintS("Result: The first packet should be discarded and the second should");
755
    PrintS("        be accepted. The retried packet should be acknowledged.");
756
    ---------------------------------------------------------------------------
757
    PrintR("TG_RioSerial-TC3-Step5");
758
    ---------------------------------------------------------------------------
759
 
760
    -- Create the frame.
761
    CreateRandomPayload(payload.data, seed1, seed2);
762
    payload.length := 7;
763
    frame := RioFrameCreate(ackId=>"00101", vc=>'0', crf=>'0', prio=>"00",
764
                            tt=>"01", ftype=>"0000",
765
                            sourceId=>x"0000", destId=>x"0000",
766
                            payload=>payload);
767
    frameExpected <= '1';
768
    frameRead <= frame;
769
 
770
    -- Start the reception of a frame.
771
    SendSymbol(SYMBOL_CONTROL,
772
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
773
                                      STYPE1_START_OF_PACKET, "000"));
774
 
775
    -- Send the data symbols of the frame.
776
    for i in 0 to frame.length-1 loop
777
      SendSymbol(SYMBOL_DATA, frame.payload(i));
778
    end loop;
779
 
780
    -- Abort the reception of the frame.
781
    SendSymbol(SYMBOL_CONTROL,
782
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
783
                                      STYPE1_STOMP, "000"));
784
 
785
    -- Dont expect the aborted frame anymore.
786
    frameExpected <= '0';
787
 
788
    -- Receive an idle symbol left in the FIFO before the retry was generated.
789
    ReceiveSymbol(SYMBOL_IDLE);
790
 
791
    -- Receive acknowledge for the transmitted frame.
792
    ReceiveSymbol(SYMBOL_CONTROL,
793
                  RioControlSymbolCreate(STYPE0_PACKET_RETRY, "00101", "11111",
794
                                         STYPE1_NOP, "000"));
795
 
796
    -- Acknowledge the canceled packet.
797
    SendSymbol(SYMBOL_CONTROL,
798
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
799
                                      STYPE1_RESTART_FROM_RETRY, "000"));
800
 
801
    -- Create a new frame.
802
    CreateRandomPayload(payload.data, seed1, seed2);
803
    payload.length := 8;
804
    frame := RioFrameCreate(ackId=>"00101", vc=>'0', crf=>'0', prio=>"00",
805
                            tt=>"01", ftype=>"0000",
806
                            sourceId=>x"0000", destId=>x"0000",
807
                            payload=>payload);
808
    frameExpected <= '1';
809
    frameRead <= frame;
810
 
811
    -- Start the reception of a frame.
812
    SendSymbol(SYMBOL_CONTROL,
813
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
814
                                      STYPE1_START_OF_PACKET, "000"));
815
 
816
    -- Send the data symbols of the frame.
817
    for i in 0 to frame.length-1 loop
818
      SendSymbol(SYMBOL_DATA, frame.payload(i));
819
    end loop;
820
 
821
    -- Abort the reception of the frame.
822
    SendSymbol(SYMBOL_CONTROL,
823
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
824
                                      STYPE1_END_OF_PACKET, "000"));
825
 
826
    -- Check that the frame has been received in the frame buffer.
827
    wait until frameReceived = '1';
828
    frameExpected <= '0';
829
 
830
    -- Receive an idle symbol left in the FIFO before the ack was generated.
831
    ReceiveSymbol(SYMBOL_IDLE);
832
 
833
    -- Receive acknowledge for the transmitted frame.
834
    ReceiveSymbol(SYMBOL_CONTROL,
835
                  RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00101", "11111",
836
                                         STYPE1_NOP, "000"));
837
 
838
    ---------------------------------------------------------------------------
839
    PrintS("-----------------------------------------------------------------");
840
    PrintS("Step 6:");
841
    PrintS("Action: Start to send a packet but dont send any payload. Abort it");
842
    PrintS("        with stomp. Then send another packet.");
843
    PrintS("Result: The first packet should be discarded and the second should");
844
    PrintS("        be accepted. The retried packet should be acknowledged.");
845
    ---------------------------------------------------------------------------
846
    PrintR("TG_RioSerial-TC3-Step6");
847
    ---------------------------------------------------------------------------
848
 
849
    -- Start the reception of a frame.
850
    SendSymbol(SYMBOL_CONTROL,
851
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
852
                                      STYPE1_START_OF_PACKET, "000"));
853
 
854
    -- Abort the reception of the frame.
855
    SendSymbol(SYMBOL_CONTROL,
856
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
857
                                      STYPE1_STOMP, "000"));
858
 
859
    -- Receive an idle symbol left in the FIFO before the retry was generated.
860
    ReceiveSymbol(SYMBOL_IDLE);
861
 
862
    -- Receive acknowledge for the transmitted frame.
863
    ReceiveSymbol(SYMBOL_CONTROL,
864
                  RioControlSymbolCreate(STYPE0_PACKET_RETRY, "00110", "11111",
865
                                         STYPE1_NOP, "000"));
866
 
867
    -- Acknowledge the canceled packet.
868
    SendSymbol(SYMBOL_CONTROL,
869
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
870
                                      STYPE1_RESTART_FROM_RETRY, "000"));
871
 
872
    -- Create a new frame.
873
    CreateRandomPayload(payload.data, seed1, seed2);
874
    payload.length := 8;
875
    frame := RioFrameCreate(ackId=>"00110", vc=>'0', crf=>'0', prio=>"00",
876
                            tt=>"01", ftype=>"0000",
877
                            sourceId=>x"0000", destId=>x"0000",
878
                            payload=>payload);
879
    frameExpected <= '1';
880
    frameRead <= frame;
881
 
882
    -- Start the reception of a frame.
883
    SendSymbol(SYMBOL_CONTROL,
884
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
885
                                      STYPE1_START_OF_PACKET, "000"));
886
 
887
    -- Send the data symbols of the frame.
888
    for i in 0 to frame.length-1 loop
889
      SendSymbol(SYMBOL_DATA, frame.payload(i));
890
    end loop;
891
 
892
    -- Abort the reception of the frame.
893
    SendSymbol(SYMBOL_CONTROL,
894
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
895
                                      STYPE1_END_OF_PACKET, "000"));
896
 
897
    -- Check that the frame has been received in the frame buffer.
898
    wait until frameReceived = '1';
899
    frameExpected <= '0';
900
 
901
    -- Receive an idle symbol left in the FIFO before the ack was generated.
902
    ReceiveSymbol(SYMBOL_IDLE);
903
 
904
    -- Receive acknowledge for the transmitted frame.
905
    ReceiveSymbol(SYMBOL_CONTROL,
906
                  RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00110", "11111",
907
                                         STYPE1_NOP, "000"));
908
 
909
    ---------------------------------------------------------------------------
910
    PrintS("-----------------------------------------------------------------");
911
    PrintS("Step 7:");
912
    PrintS("Action: Start to send a packet with payload, then send a ");
913
    PrintS("        link-request. Then send another packet.");
914
    PrintS("Result: The first packet should be canceled without any ");
915
    PrintS("        confirmation and a link-response should be returned. The");
916
    PrintS("        second packet should be accepted.");
917
    ---------------------------------------------------------------------------
918
    PrintR("TG_RioSerial-TC3-Step7");
919
    ---------------------------------------------------------------------------
920
 
921
    -- Create a new frame.
922
    CreateRandomPayload(payload.data, seed1, seed2);
923
    payload.length := 9;
924
    frame := RioFrameCreate(ackId=>"00111", vc=>'0', crf=>'0', prio=>"00",
925
                            tt=>"01", ftype=>"0000",
926
                            sourceId=>x"0000", destId=>x"0000",
927
                            payload=>payload);
928
    frameExpected <= '1';
929
    frameRead <= frame;
930
 
931
    -- Start the reception of a frame.
932
    SendSymbol(SYMBOL_CONTROL,
933
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
934
                                      STYPE1_START_OF_PACKET, "000"));
935
 
936
    -- Send the data symbols of the frame.
937
    for i in 0 to frame.length-1 loop
938
      SendSymbol(SYMBOL_DATA, frame.payload(i));
939
    end loop;
940
 
941
    -- Send a link-request/input-status to abort the current packet.
942
    SendSymbol(SYMBOL_CONTROL,
943
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
944
                                      STYPE1_LINK_REQUEST, "100"));
945
 
946
    -- Receive an idle symbol left in the FIFO before the ack was generated.
947
    ReceiveSymbol(SYMBOL_IDLE);
948
 
949
    -- The frame should be canceled by the link-request, dont expect it anymore.
950
    frameExpected <= '0';
951
 
952
    -- Receive link-response indicating normal operation and expected ackId.
953
    ReceiveSymbol(SYMBOL_CONTROL,
954
                  RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "00111", "10000",
955
                                         STYPE1_NOP, "000"));
956
 
957
    -- Create a new frame.
958
    CreateRandomPayload(payload.data, seed1, seed2);
959
    payload.length := 10;
960
    frame := RioFrameCreate(ackId=>"00111", vc=>'0', crf=>'0', prio=>"00",
961
                            tt=>"01", ftype=>"0000",
962
                            sourceId=>x"0000", destId=>x"0000",
963
                            payload=>payload);
964
    frameExpected <= '1';
965
    frameRead <= frame;
966
 
967
    -- Start the reception of a frame.
968
    SendSymbol(SYMBOL_CONTROL,
969
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
970
                                      STYPE1_START_OF_PACKET, "000"));
971
 
972
    -- Send the data symbols of the frame.
973
    for i in 0 to frame.length-1 loop
974
      SendSymbol(SYMBOL_DATA, frame.payload(i));
975
    end loop;
976
 
977
    -- Abort the reception of the frame.
978
    SendSymbol(SYMBOL_CONTROL,
979
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
980
                                      STYPE1_END_OF_PACKET, "000"));
981
 
982
    -- Check that the frame has been received in the frame buffer.
983
    wait until frameReceived = '1';
984
    frameExpected <= '0';
985
 
986
    -- Receive an idle symbol left in the FIFO before the ack was generated.
987
    ReceiveSymbol(SYMBOL_IDLE);
988
 
989
    -- Receive acknowledge for the transmitted frame.
990
    ReceiveSymbol(SYMBOL_CONTROL,
991
                  RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00111", "11111",
992
                                         STYPE1_NOP, "000"));
993
 
994
    ---------------------------------------------------------------------------
995
    PrintS("-----------------------------------------------------------------");
996
    PrintS("Step 8:");
997
    PrintS("Action: Start to send a packet, no payload, then send a ");
998
    PrintS("        link-request. Then send another packet.");
999
    PrintS("Result: The first packet should be canceled without any ");
1000
    PrintS("        confirmation and a link-response should be returned. The");
1001
    PrintS("        second packet should be accepted.");
1002
    ---------------------------------------------------------------------------
1003
    PrintR("TG_RioSerial-TC3-Step8");
1004
    ---------------------------------------------------------------------------
1005
 
1006
    -- Expect an empty packet to be aborted.
1007
    frameExpected <= '1';
1008
 
1009
    -- Start the reception of a frame.
1010
    SendSymbol(SYMBOL_CONTROL,
1011
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1012
                                      STYPE1_START_OF_PACKET, "000"));
1013
 
1014
    -- Send a link-request/input-status to abort the current packet.
1015
    SendSymbol(SYMBOL_CONTROL,
1016
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1017
                                      STYPE1_LINK_REQUEST, "100"));
1018
 
1019
    -- Receive an idle symbol left in the FIFO before the ack was generated.
1020
    ReceiveSymbol(SYMBOL_IDLE);
1021
 
1022
    -- Dont expect any frames anymore.
1023
    frameExpected <= '0';
1024
 
1025
    -- Receive link-response indicating normal operation and expected ackId.
1026
    ReceiveSymbol(SYMBOL_CONTROL,
1027
                  RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01000", "10000",
1028
                                         STYPE1_NOP, "000"));
1029
 
1030
    -- Create a new frame.
1031
    CreateRandomPayload(payload.data, seed1, seed2);
1032
    payload.length := 11;
1033
    frame := RioFrameCreate(ackId=>"01000", vc=>'0', crf=>'0', prio=>"00",
1034
                            tt=>"01", ftype=>"0000",
1035
                            sourceId=>x"0000", destId=>x"0000",
1036
                            payload=>payload);
1037
    frameExpected <= '1';
1038
    frameRead <= frame;
1039
 
1040
    -- Start the reception of a frame.
1041
    SendSymbol(SYMBOL_CONTROL,
1042
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1043
                                      STYPE1_START_OF_PACKET, "000"));
1044
 
1045
    -- Send the data symbols of the frame.
1046
    for i in 0 to frame.length-1 loop
1047
      SendSymbol(SYMBOL_DATA, frame.payload(i));
1048
    end loop;
1049
 
1050
    -- Abort the reception of the frame.
1051
    SendSymbol(SYMBOL_CONTROL,
1052
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1053
                                      STYPE1_END_OF_PACKET, "000"));
1054
 
1055
    -- Check that the frame has been received in the frame buffer.
1056
    wait until frameReceived = '1';
1057
    frameExpected <= '0';
1058
 
1059
    -- Receive an idle symbol left in the FIFO before the ack was generated.
1060
    ReceiveSymbol(SYMBOL_IDLE);
1061
 
1062
    -- Receive acknowledge for the transmitted frame.
1063
    ReceiveSymbol(SYMBOL_CONTROL,
1064
                  RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01000", "11111",
1065
                                         STYPE1_NOP, "000"));
1066
 
1067
    ---------------------------------------------------------------------------
1068
    PrintS("-----------------------------------------------------------------");
1069
    PrintS("Step 9:");
1070
    PrintS("Action: Send a packet when no buffers is available. Reset receiver");
1071
    PrintS("        with link-request.");
1072
    PrintS("Result: A packet-retry should be transmitted and receiver should");
1073
    PrintS("        enter input-retry-stopped.");
1074
    ---------------------------------------------------------------------------
1075
    PrintR("TG_RioSerial-TC3-Step9");
1076
    ---------------------------------------------------------------------------
1077
 
1078
    -- Create a new frame.
1079
    CreateRandomPayload(payload.data, seed1, seed2);
1080
    payload.length := 11;
1081
    frame := RioFrameCreate(ackId=>"01001", vc=>'0', crf=>'0', prio=>"00",
1082
                            tt=>"01", ftype=>"0000",
1083
                            sourceId=>x"0000", destId=>x"0000",
1084
                            payload=>payload);
1085
 
1086
    -- Start the reception of a frame.
1087
    SendSymbol(SYMBOL_CONTROL,
1088
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1089
                                      STYPE1_START_OF_PACKET, "000"));
1090
    SendSymbol(SYMBOL_DATA, frame.payload(0));
1091
 
1092
    -- Receive notification about that the packet needs to be retried.
1093
    ReceiveSymbol(SYMBOL_IDLE);
1094
    ReceiveSymbol(SYMBOL_CONTROL,
1095
                  RioControlSymbolCreate(STYPE0_PACKET_RETRY, "01001", "11111",
1096
                                         STYPE1_NOP, "000"));
1097
 
1098
    -- Check the status of the input port and verify the input-retry-stopped state.
1099
    -- This should also set the receiver into normal operation.
1100
    SendSymbol(SYMBOL_CONTROL,
1101
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1102
                                      STYPE1_LINK_REQUEST, "100"));
1103
    ReceiveSymbol(SYMBOL_IDLE);
1104
    ReceiveSymbol(SYMBOL_CONTROL,
1105
                  RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01001", "00100",
1106
                                         STYPE1_NOP, "000"));
1107
 
1108
    -- Check the status of the input port and verify the input-retry-stopped state.
1109
    SendSymbol(SYMBOL_CONTROL,
1110
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1111
                                      STYPE1_LINK_REQUEST, "100"));
1112
    ReceiveSymbol(SYMBOL_IDLE);
1113
    ReceiveSymbol(SYMBOL_CONTROL,
1114
                  RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01001", "10000",
1115
                                         STYPE1_NOP, "000"));
1116
 
1117
    ---------------------------------------------------------------------------
1118
    PrintS("-----------------------------------------------------------------");
1119
    PrintS("Step 10:");
1120
    PrintS("Action: Send a packet when no buffers is available. Reset receiver");
1121
    PrintS("        with restart-from-retry.");
1122
    PrintS("Result: A packet-retry should be transmitted and receiver should");
1123
    PrintS("        enter input-retry-stopped.");
1124
    ---------------------------------------------------------------------------
1125
    PrintR("TG_RioSerial-TC3-Step10");
1126
    ---------------------------------------------------------------------------
1127
 
1128
    -- Create a new frame.
1129
    CreateRandomPayload(payload.data, seed1, seed2);
1130
    payload.length := 11;
1131
    frame := RioFrameCreate(ackId=>"01001", vc=>'0', crf=>'0', prio=>"00",
1132
                            tt=>"01", ftype=>"0000",
1133
                            sourceId=>x"0000", destId=>x"0000",
1134
                            payload=>payload);
1135
 
1136
    -- Start the reception of a frame.
1137
    SendSymbol(SYMBOL_CONTROL,
1138
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1139
                                      STYPE1_START_OF_PACKET, "000"));
1140
    SendSymbol(SYMBOL_DATA, frame.payload(0));
1141
 
1142
    -- Receive notification about that the packet needs to be retried.
1143
    ReceiveSymbol(SYMBOL_IDLE);
1144
    ReceiveSymbol(SYMBOL_CONTROL,
1145
                  RioControlSymbolCreate(STYPE0_PACKET_RETRY, "01001", "11111",
1146
                                         STYPE1_NOP, "000"));
1147
 
1148
    -- Acknowledge the retried packet.
1149
    SendSymbol(SYMBOL_CONTROL,
1150
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1151
                                      STYPE1_RESTART_FROM_RETRY, "000"));
1152
 
1153
    -- Check the status of the input port and verify the input-retry-stopped state.
1154
    SendSymbol(SYMBOL_CONTROL,
1155
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1156
                                      STYPE1_LINK_REQUEST, "100"));
1157
    ReceiveSymbol(SYMBOL_IDLE);
1158
    ReceiveSymbol(SYMBOL_CONTROL,
1159
                  RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01001", "10000",
1160
                                         STYPE1_NOP, "000"));
1161
 
1162
    -- Always receive a status after a link response when leaving input-error-stopped.
1163
--    ReceiveSymbol(SYMBOL_CONTROL,
1164
--                  RioControlSymbolCreate(STYPE0_STATUS, "01001", "11111",
1165
--                                         STYPE1_NOP, "000"));    
1166
 
1167
    ---------------------------------------------------------------------------
1168
    PrintS("-----------------------------------------------------------------");
1169
    PrintS("Step 11:");
1170
    PrintS("Action: Start a new packet when in input-retry-stopped state.");
1171
    PrintS("Result: The packet should be discarded.");
1172
    ---------------------------------------------------------------------------
1173
    PrintR("TG_RioSerial-TC3-Step11");
1174
    ---------------------------------------------------------------------------
1175
 
1176
    -- Create a new frame.
1177
    CreateRandomPayload(payload.data, seed1, seed2);
1178
    payload.length := 11;
1179
    frame := RioFrameCreate(ackId=>"01001", vc=>'0', crf=>'0', prio=>"00",
1180
                            tt=>"01", ftype=>"0000",
1181
                            sourceId=>x"0000", destId=>x"0000",
1182
                            payload=>payload);
1183
 
1184
    -- Start the reception of a frame.
1185
    SendSymbol(SYMBOL_CONTROL,
1186
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1187
                                      STYPE1_START_OF_PACKET, "000"));
1188
    SendSymbol(SYMBOL_DATA, frame.payload(0));
1189
 
1190
    -- Receive notification about that the packet needs to be retried.
1191
    ReceiveSymbol(SYMBOL_IDLE);
1192
    ReceiveSymbol(SYMBOL_CONTROL,
1193
                  RioControlSymbolCreate(STYPE0_PACKET_RETRY, "01001", "11111",
1194
                                         STYPE1_NOP, "000"));
1195
 
1196
    -- Create a packet and send it. It should be discarded.
1197
    CreateRandomPayload(payload.data, seed1, seed2);
1198
    payload.length := 12;
1199
    frame := RioFrameCreate(ackId=>"01001", vc=>'0', crf=>'0', prio=>"00",
1200
                            tt=>"01", ftype=>"0000",
1201
                            sourceId=>x"0000", destId=>x"0000",
1202
                            payload=>payload);
1203
    SendSymbol(SYMBOL_CONTROL,
1204
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1205
                                      STYPE1_START_OF_PACKET, "000"));
1206
    for i in 0 to frame.length-1 loop
1207
      SendSymbol(SYMBOL_DATA, frame.payload(i));
1208
    end loop;
1209
    SendSymbol(SYMBOL_CONTROL,
1210
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1211
                                      STYPE1_END_OF_PACKET, "000"));
1212
 
1213
    -- Acknowledge the retried packet.
1214
    SendSymbol(SYMBOL_CONTROL,
1215
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1216
                                      STYPE1_RESTART_FROM_RETRY, "000"));
1217
 
1218
    -- Create a packet and send it.
1219
    CreateRandomPayload(payload.data, seed1, seed2);
1220
    payload.length := 13;
1221
    frame := RioFrameCreate(ackId=>"01001", vc=>'0', crf=>'0', prio=>"00",
1222
                            tt=>"01", ftype=>"0000",
1223
                            sourceId=>x"0000", destId=>x"0000",
1224
                            payload=>payload);
1225
    frameExpected <= '1';
1226
    frameRead <= frame;
1227
    SendSymbol(SYMBOL_CONTROL,
1228
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1229
                                      STYPE1_START_OF_PACKET, "000"));
1230
    for i in 0 to frame.length-1 loop
1231
      SendSymbol(SYMBOL_DATA, frame.payload(i));
1232
    end loop;
1233
    SendSymbol(SYMBOL_CONTROL,
1234
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1235
                                      STYPE1_END_OF_PACKET, "000"));
1236
    wait until frameReceived = '1';
1237
    frameExpected <= '0';
1238
 
1239
    -- Receive acknowledge for the transmitted frame.
1240
    ReceiveSymbol(SYMBOL_IDLE);
1241
    ReceiveSymbol(SYMBOL_CONTROL,
1242
                  RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01001", "11111",
1243
                                         STYPE1_NOP, "000"));
1244
 
1245
    ---------------------------------------------------------------------------
1246
    PrintS("-----------------------------------------------------------------");
1247
    PrintS("Step 12:");
1248
    PrintS("Action: Send an erronous control-symbol. Then restore with");
1249
    PrintS("        link-request.");
1250
    PrintS("Result: Receiver should enter input-error-stopped and return to");
1251
    PrintS("        normal operation after the link-request was receiver.");
1252
    ---------------------------------------------------------------------------
1253
    PrintR("TG_RioSerial-TC3-Step12");
1254
    ---------------------------------------------------------------------------
1255
 
1256
    -- Create, corrupt and send a control symbol.
1257
    SendSymbol(SYMBOL_CONTROL,
1258
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1259
                                      STYPE1_START_OF_PACKET, "000") xor x"00100000");
1260
 
1261
    -- Receive a packet-not-accepted indicating error in control-symbol crc.
1262
    ReceiveSymbol(SYMBOL_IDLE);
1263
    ReceiveSymbol(SYMBOL_CONTROL,
1264
                  RioControlSymbolCreate(STYPE0_PACKET_NOT_ACCEPTED, "00000", "00010",
1265
                                         STYPE1_NOP, "000"));
1266
 
1267
    -- Create a packet and send it. It should be discarded.
1268
    CreateRandomPayload(payload.data, seed1, seed2);
1269
    payload.length := 14;
1270
    frame := RioFrameCreate(ackId=>"01010", vc=>'0', crf=>'0', prio=>"00",
1271
                            tt=>"01", ftype=>"0000",
1272
                            sourceId=>x"0000", destId=>x"0000",
1273
                            payload=>payload);
1274
    SendSymbol(SYMBOL_CONTROL,
1275
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1276
                                      STYPE1_START_OF_PACKET, "000"));
1277
    for i in 0 to frame.length-1 loop
1278
      SendSymbol(SYMBOL_DATA, frame.payload(i));
1279
    end loop;
1280
    SendSymbol(SYMBOL_CONTROL,
1281
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1282
                                      STYPE1_END_OF_PACKET, "000"));
1283
 
1284
    -- Make the receiver go back to normal operation by sending a link-request.
1285
    SendSymbol(SYMBOL_CONTROL,
1286
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1287
                                      STYPE1_LINK_REQUEST, "100"));
1288
 
1289
    ReceiveSymbol(SYMBOL_IDLE);
1290
    ReceiveSymbol(SYMBOL_CONTROL,
1291
                  RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01010", "00101",
1292
                                         STYPE1_NOP, "000"));
1293
 
1294
    -- Always receive a status after a link response when leaving input-error-stopped.
1295
--    ReceiveSymbol(SYMBOL_CONTROL,
1296
--                  RioControlSymbolCreate(STYPE0_STATUS, "01010", "11111",
1297
--                                         STYPE1_NOP, "000"));
1298
 
1299
    -- Create a packet and send it.
1300
    CreateRandomPayload(payload.data, seed1, seed2);
1301
    payload.length := 15;
1302
    frame := RioFrameCreate(ackId=>"01010", vc=>'0', crf=>'0', prio=>"00",
1303
                            tt=>"01", ftype=>"0000",
1304
                            sourceId=>x"0000", destId=>x"0000",
1305
                            payload=>payload);
1306
    frameExpected <= '1';
1307
    frameRead <= frame;
1308
    SendSymbol(SYMBOL_CONTROL,
1309
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1310
                                      STYPE1_START_OF_PACKET, "000"));
1311
    for i in 0 to frame.length-1 loop
1312
      SendSymbol(SYMBOL_DATA, frame.payload(i));
1313
    end loop;
1314
    SendSymbol(SYMBOL_CONTROL,
1315
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1316
                                      STYPE1_END_OF_PACKET, "000"));
1317
    wait until frameReceived = '1';
1318
    frameExpected <= '0';
1319
 
1320
    -- Receive acknowledge for the transmitted frame.
1321
    ReceiveSymbol(SYMBOL_IDLE);
1322
    ReceiveSymbol(SYMBOL_CONTROL,
1323
                  RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01010", "11111",
1324
                                         STYPE1_NOP, "000"));
1325
 
1326
    ---------------------------------------------------------------------------
1327
    PrintS("-----------------------------------------------------------------");
1328
    PrintS("Step 13:");
1329
    PrintS("Action: Send an erronous packet. Then restore with link-request.");
1330
    PrintS("Result: Receiver should enter input-error-stopped and return to");
1331
    PrintS("        normal operation after the link-request was receiver.");
1332
    ---------------------------------------------------------------------------
1333
    PrintR("TG_RioSerial-TC3-Step13");
1334
    ---------------------------------------------------------------------------
1335
 
1336
    -- Create a packet and send it with a bit error. It should be discarded.
1337
    CreateRandomPayload(payload.data, seed1, seed2);
1338
    payload.length := 15;
1339
    frame := RioFrameCreate(ackId=>"01011", vc=>'0', crf=>'0', prio=>"00",
1340
                            tt=>"01", ftype=>"0000",
1341
                            sourceId=>x"0000", destId=>x"0000",
1342
                            payload=>payload);
1343
    frame.payload(0) := frame.payload(0) xor x"00000010";
1344
    frameExpected <= '1';
1345
    frameRead <= frame;
1346
    SendSymbol(SYMBOL_CONTROL,
1347
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1348
                                      STYPE1_START_OF_PACKET, "000"));
1349
    for i in 0 to frame.length-1 loop
1350
      SendSymbol(SYMBOL_DATA, frame.payload(i));
1351
    end loop;
1352
    SendSymbol(SYMBOL_CONTROL,
1353
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1354
                                      STYPE1_END_OF_PACKET, "000"));
1355
 
1356
    -- Receive a packet-not-accepted indicating error in control-symbol crc.
1357
    ReceiveSymbol(SYMBOL_IDLE);
1358
    ReceiveSymbol(SYMBOL_CONTROL,
1359
                  RioControlSymbolCreate(STYPE0_PACKET_NOT_ACCEPTED, "00000", "00100",
1360
                                         STYPE1_NOP, "000"));
1361
 
1362
    -- Dont expect any frame anymore.
1363
    frameExpected <= '0';
1364
 
1365
    -- Make the receiver go back to normal operation by sending a link-request.
1366
    SendSymbol(SYMBOL_CONTROL,
1367
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1368
                                      STYPE1_LINK_REQUEST, "100"));
1369
 
1370
    ReceiveSymbol(SYMBOL_IDLE);
1371
    ReceiveSymbol(SYMBOL_CONTROL,
1372
                  RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01011", "00101",
1373
                                         STYPE1_NOP, "000"));
1374
 
1375
    -- Send a new frame without error.
1376
    CreateRandomPayload(payload.data, seed1, seed2);
1377
    payload.length := 16;
1378
    frame := RioFrameCreate(ackId=>"01011", vc=>'0', crf=>'0', prio=>"00",
1379
                            tt=>"01", ftype=>"0000",
1380
                            sourceId=>x"0000", destId=>x"0000",
1381
                            payload=>payload);
1382
    frameExpected <= '1';
1383
    frameRead <= frame;
1384
    SendSymbol(SYMBOL_CONTROL,
1385
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1386
                                      STYPE1_START_OF_PACKET, "000"));
1387
    for i in 0 to frame.length-1 loop
1388
      SendSymbol(SYMBOL_DATA, frame.payload(i));
1389
    end loop;
1390
    SendSymbol(SYMBOL_CONTROL,
1391
               RioControlSymbolCreate(STYPE0_STATUS, "00000", "11111",
1392
                                      STYPE1_END_OF_PACKET, "000"));
1393
    wait until frameReceived = '1';
1394
    frameExpected <= '0';
1395
 
1396
    -- Receive acknowledge for the transmitted frame.
1397
    ReceiveSymbol(SYMBOL_IDLE);
1398
    ReceiveSymbol(SYMBOL_CONTROL,
1399
                  RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01011", "11111",
1400
                                         STYPE1_NOP, "000"));
1401
 
1402
    -- REMARK: Complete with some more error situations: invalid ackId, too
1403
    -- short packet, too long packet, etc...
1404
 
1405
    ---------------------------------------------------------------------------
1406
    PrintS("-----------------------------------------------------------------");
1407
    PrintS("TG_RioSerial-TC4");
1408
    PrintS("Description: Test port transmission.");
1409
    PrintS("Requirement: XXXXX");
1410
    PrintS("-----------------------------------------------------------------");
1411
    PrintS("Step 1:");
1412
    PrintS("Action: Send an outbound frame.");
1413
    PrintS("Result: The frame should be read from the frame buffer and ");
1414
    PrintS("        received as symbols.");
1415
    ---------------------------------------------------------------------------
1416
    PrintR("TG_RioSerial-TC4-Step1");
1417
    ---------------------------------------------------------------------------
1418
 
1419
    -- Create the frame.
1420
    CreateRandomPayload(payload.data, seed1, seed2);
1421
    payload.length := 3;
1422
    frame := RioFrameCreate(ackId=>"00000", vc=>'0', crf=>'0', prio=>"00",
1423
                            tt=>"01", ftype=>"0000",
1424
                            sourceId=>x"0000", destId=>x"0000",
1425
                            payload=>payload);
1426
    frameValid(0) <= '1';
1427
    frameWrite(0) <= frame;
1428
 
1429
    -- Make sure the transmitter fills in the correct ackId and dont use the
1430
    -- one in the input packet.
1431
    frameWrite(0).payload(0)(31 downto 27) <= "UUUUU";
1432
 
1433
    -- Receive an idle symbol left in the FIFO before the start of the frame was
1434
    -- generated.
1435
    ReceiveSymbol(SYMBOL_IDLE);
1436
 
1437
    -- Receive the start of the frame.
1438
    ReceiveSymbol(SYMBOL_CONTROL,
1439
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1440
                                         STYPE1_START_OF_PACKET, "000"));
1441
 
1442
    -- Receive the data symbols of the frame.
1443
    for i in 0 to frame.length-1 loop
1444
      ReceiveSymbol(SYMBOL_DATA, frame.payload(i));
1445
    end loop;
1446
 
1447
    -- Wait for the frame to complete.
1448 15 magro732
    wait until frameComplete(0) = '1' and clk'event and clk = '1';
1449 4 magro732
    frameValid(0) <= '0';
1450
 
1451
    -- Receive the end of the frame.
1452
    ReceiveSymbol(SYMBOL_CONTROL,
1453
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1454
                                         STYPE1_END_OF_PACKET, "000"));
1455
 
1456
    -- Send acknowledge that the frame was received.
1457
    SendSymbol(SYMBOL_CONTROL,
1458
               RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00000", "11111",
1459
                                      STYPE1_NOP, "000"));
1460
 
1461
    ---------------------------------------------------------------------------
1462
    PrintS("-----------------------------------------------------------------");
1463
    PrintS("Step 2:");
1464
    PrintS("Action: Send an outbound packet with maximum length.");
1465
    PrintS("Result: The packet should be fragmented and received in symbols.");
1466
    ---------------------------------------------------------------------------
1467
    PrintR("TG_RioSerial-TC4-Step2");
1468
    ---------------------------------------------------------------------------
1469
 
1470
    -- Create the frame.
1471
    CreateRandomPayload(payload.data, seed1, seed2);
1472
    payload.length := 133;
1473
    frame := RioFrameCreate(ackId=>"00001", vc=>'0', crf=>'0', prio=>"00",
1474
                            tt=>"01", ftype=>"0000",
1475
                            sourceId=>x"0000", destId=>x"0000",
1476
                            payload=>payload);
1477
    frameValid(1) <= '1';
1478
    frameWrite(1) <= frame;
1479
 
1480
    -- Receive an idle symbol left in the FIFO before the start of the frame was
1481
    -- generated.
1482
    ReceiveSymbol(SYMBOL_IDLE);
1483
 
1484
    -- Receive the start of the frame.
1485
    ReceiveSymbol(SYMBOL_CONTROL,
1486
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1487
                                         STYPE1_START_OF_PACKET, "000"));
1488
 
1489
    -- Receive the data symbols of the frame.
1490
    for i in 0 to frame.length-1 loop
1491
      ReceiveSymbol(SYMBOL_DATA, frame.payload(i));
1492
    end loop;
1493
 
1494
    -- Wait for the frame to complete.
1495 15 magro732
    wait until frameComplete(1) = '1' and clk'event and clk = '1';
1496 4 magro732
    frameValid(1) <= '0';
1497
 
1498
    -- Receive the end of the frame.
1499
    ReceiveSymbol(SYMBOL_CONTROL,
1500
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1501
                                         STYPE1_END_OF_PACKET, "000"));
1502
 
1503
    -- Send acknowledge that the frame was received.
1504
    SendSymbol(SYMBOL_CONTROL,
1505
               RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00001", "11111",
1506
                                      STYPE1_NOP, "000"));
1507
 
1508
     ---------------------------------------------------------------------------
1509
    PrintS("-----------------------------------------------------------------");
1510
    PrintS("Step 3:");
1511
    PrintS("Action: Send a packet and confirm it with packet-retry.");
1512
    PrintS("Result: A restart-from-retry should be transmitted and the packet");
1513
    PrintS("        should be retransmitted.");
1514
    ---------------------------------------------------------------------------
1515
    PrintR("TG_RioSerial-TC4-Step3");
1516
    ---------------------------------------------------------------------------
1517
 
1518
    -- Create the frame.
1519
    CreateRandomPayload(payload.data, seed1, seed2);
1520
    payload.length := 4;
1521
    frame := RioFrameCreate(ackId=>"00010", vc=>'0', crf=>'0', prio=>"00",
1522
                            tt=>"01", ftype=>"0000",
1523
                            sourceId=>x"0000", destId=>x"0000",
1524
                            payload=>payload);
1525
    frameValid(2) <= '1';
1526
    frameWrite(2) <= frame;
1527
 
1528
    -- Receive an idle symbol left in the FIFO before the start of the frame was
1529
    -- generated.
1530
    ReceiveSymbol(SYMBOL_IDLE);
1531
 
1532
    -- Receive the start of the frame.
1533
    ReceiveSymbol(SYMBOL_CONTROL,
1534
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1535
                                         STYPE1_START_OF_PACKET, "000"));
1536
 
1537
    -- Receive the data symbols of the frame.
1538
    for i in 0 to frame.length-1 loop
1539
      ReceiveSymbol(SYMBOL_DATA, frame.payload(i));
1540
    end loop;
1541
 
1542
    -- Receive the end of the frame.
1543
    ReceiveSymbol(SYMBOL_CONTROL,
1544
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1545
                                         STYPE1_END_OF_PACKET, "000"));
1546
 
1547
    -- Send packet-retry that the frame should be retransmitted.
1548
    SendSymbol(SYMBOL_CONTROL,
1549
               RioControlSymbolCreate(STYPE0_PACKET_RETRY, "00010", "11111",
1550
                                      STYPE1_NOP, "000"));
1551
 
1552
    -- Receive the acknowledgement for the retransmission.
1553
    ReceiveSymbol(SYMBOL_IDLE);
1554
    ReceiveSymbol(SYMBOL_CONTROL,
1555
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1556
                                         STYPE1_RESTART_FROM_RETRY, "000"));
1557
 
1558
    -- Receive the start of the retransmitted frame.
1559
    ReceiveSymbol(SYMBOL_CONTROL,
1560
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1561
                                         STYPE1_START_OF_PACKET, "000"));
1562
 
1563
    -- Receive the data symbols of the retransmitted frame.
1564
    for i in 0 to frame.length-1 loop
1565
      ReceiveSymbol(SYMBOL_DATA, frame.payload(i));
1566
    end loop;
1567
 
1568
    -- Wait for the frame to complete.
1569 15 magro732
    wait until frameComplete(2) = '1' and clk'event and clk = '1';
1570 4 magro732
    frameValid(2) <= '0';
1571
 
1572
    -- Receive the end of the retransmitted frame.
1573
    ReceiveSymbol(SYMBOL_CONTROL,
1574
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1575
                                         STYPE1_END_OF_PACKET, "000"));
1576
 
1577
    -- Send acknowledge that the frame was received.
1578
    SendSymbol(SYMBOL_CONTROL,
1579
               RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00010", "11111",
1580
                                      STYPE1_NOP, "000"));
1581
 
1582
    ---------------------------------------------------------------------------
1583
    PrintS("-----------------------------------------------------------------");
1584
    PrintS("Step 4:");
1585
    PrintS("Action: Send a packet and confirm it with packet-not-accepted. ");
1586
    PrintS("Result: A link-request should be transmitted and the packet should");
1587
    PrintS("        be retransmitted.");
1588
    ---------------------------------------------------------------------------
1589
    PrintR("TG_RioSerial-TC4-Step4");
1590
    ---------------------------------------------------------------------------
1591
 
1592
    -- Create the frame.
1593
    CreateRandomPayload(payload.data, seed1, seed2);
1594
    payload.length := 5;
1595
    frame := RioFrameCreate(ackId=>"00011", vc=>'0', crf=>'0', prio=>"00",
1596
                            tt=>"01", ftype=>"0000",
1597
                            sourceId=>x"0000", destId=>x"0000",
1598
                            payload=>payload);
1599
    frameValid(3) <= '1';
1600
    frameWrite(3) <= frame;
1601
 
1602
    -- Receive the start of the frame.
1603
    ReceiveSymbol(SYMBOL_IDLE);
1604
    ReceiveSymbol(SYMBOL_CONTROL,
1605
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1606
                                         STYPE1_START_OF_PACKET, "000"));
1607
 
1608
    -- Receive the data symbols of the frame.
1609
    for i in 0 to frame.length-1 loop
1610
      ReceiveSymbol(SYMBOL_DATA, frame.payload(i));
1611
    end loop;
1612
 
1613
    -- Receive the end of the frame.
1614
    ReceiveSymbol(SYMBOL_CONTROL,
1615
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1616
                                         STYPE1_END_OF_PACKET, "000"));
1617
 
1618
    -- Send packet-retry that the frame should be retransmitted.
1619
    SendSymbol(SYMBOL_CONTROL,
1620
               RioControlSymbolCreate(STYPE0_PACKET_NOT_ACCEPTED, "00000", "11111",
1621
                                      STYPE1_NOP, "000"));
1622
 
1623
    -- Receive the acknowledgement for the retransmission.
1624
    ReceiveSymbol(SYMBOL_IDLE);
1625
    ReceiveSymbol(SYMBOL_CONTROL,
1626
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1627
                                         STYPE1_LINK_REQUEST, "100"));
1628
    SendSymbol(SYMBOL_CONTROL,
1629
               RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "00011", "11111",
1630
                                      STYPE1_NOP, "000"));
1631
 
1632
    -- Receive the start of the retransmitted frame.
1633
    ReceiveSymbol(SYMBOL_IDLE);
1634
    ReceiveSymbol(SYMBOL_CONTROL,
1635
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1636
                                         STYPE1_START_OF_PACKET, "000"));
1637
 
1638
    -- Receive the data symbols of the retransmitted frame.
1639
    for i in 0 to frame.length-1 loop
1640
      ReceiveSymbol(SYMBOL_DATA, frame.payload(i));
1641
    end loop;
1642
 
1643
    -- Wait for the frame to complete.
1644 15 magro732
    wait until frameComplete(3) = '1' and clk'event and clk = '1';
1645 4 magro732
    frameValid(3) <= '0';
1646
 
1647
    -- Receive the end of the retransmitted frame.
1648
    ReceiveSymbol(SYMBOL_CONTROL,
1649
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1650
                                         STYPE1_END_OF_PACKET, "000"));
1651
 
1652
    -- Send acknowledge that the frame was received.
1653
    SendSymbol(SYMBOL_CONTROL,
1654
               RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00011", "11111",
1655
                                      STYPE1_NOP, "000"));
1656
 
1657
    ---------------------------------------------------------------------------
1658
    PrintS("-----------------------------------------------------------------");
1659
    PrintS("Step 5:");
1660
    PrintS("Action: Let a packet timeout expire. Then answer with link-response.");
1661
    PrintS("Result: A link-request should be transmitted and the packet should");
1662
    PrintS("        be retransmitted.");
1663
    ---------------------------------------------------------------------------
1664
    PrintR("TG_RioSerial-TC4-Step5");
1665
    ---------------------------------------------------------------------------
1666
 
1667
    -- Create the frame.
1668
    CreateRandomPayload(payload.data, seed1, seed2);
1669
    payload.length := 5;
1670
    frame := RioFrameCreate(ackId=>"00100", vc=>'0', crf=>'0', prio=>"00",
1671
                            tt=>"01", ftype=>"0000",
1672
                            sourceId=>x"0000", destId=>x"0000",
1673
                            payload=>payload);
1674
    frameValid(4) <= '1';
1675
    frameWrite(4) <= frame;
1676
 
1677
    -- Receive the frame.
1678
    ReceiveSymbol(SYMBOL_IDLE);
1679
    ReceiveSymbol(SYMBOL_CONTROL,
1680
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1681
                                         STYPE1_START_OF_PACKET, "000"));
1682
    for i in 0 to frame.length-1 loop
1683
      ReceiveSymbol(SYMBOL_DATA, frame.payload(i));
1684
    end loop;
1685
    ReceiveSymbol(SYMBOL_CONTROL,
1686
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1687
                                         STYPE1_END_OF_PACKET, "000"));
1688
 
1689
    -- Wait a while to let the timer expire and receive the link-request.
1690
    for i in 0 to 2048 loop
1691
      wait until clk'event and clk = '1';
1692
    end loop;
1693
    ReceiveSymbol(SYMBOL_IDLE);
1694
    ReceiveSymbol(SYMBOL_CONTROL,
1695
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1696
                                         STYPE1_LINK_REQUEST, "100"));
1697
 
1698
    -- Send a link-response to make the transmitter to back to normal mode.
1699
    SendSymbol(SYMBOL_CONTROL,
1700
               RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "00100", "11111",
1701
                                      STYPE1_NOP, "000"));
1702
 
1703
    -- Receive the retransmitted frame.
1704
    ReceiveSymbol(SYMBOL_IDLE);
1705
    ReceiveSymbol(SYMBOL_CONTROL,
1706
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1707
                                         STYPE1_START_OF_PACKET, "000"));
1708
 
1709
    for i in 0 to frame.length-1 loop
1710
      ReceiveSymbol(SYMBOL_DATA, frame.payload(i));
1711
    end loop;
1712
 
1713
    -- Wait for the frame to complete.
1714 15 magro732
    wait until frameComplete(4) = '1' and clk'event and clk = '1';
1715 4 magro732
    frameValid(4) <= '0';
1716
 
1717
    ReceiveSymbol(SYMBOL_CONTROL,
1718
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1719
                                         STYPE1_END_OF_PACKET, "000"));
1720
 
1721
    -- Send acknowledge that the frame was received.
1722
    SendSymbol(SYMBOL_CONTROL,
1723
               RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00100", "11111",
1724
                                      STYPE1_NOP, "000"));
1725
 
1726
    ---------------------------------------------------------------------------
1727
    PrintS("-----------------------------------------------------------------");
1728
    PrintS("Step 6:");
1729
    PrintS("Action: Let a packet timeout expire. Then answer with link-response");
1730
    Prints("        that indicates that the packet was received.");
1731
    PrintS("Result: A link-request should be transmitted and the packet should");
1732
    PrintS("        not be retransmitted.");
1733
    ---------------------------------------------------------------------------
1734
    PrintR("TG_RioSerial-TC4-Step6");
1735
    ---------------------------------------------------------------------------
1736
 
1737
    -- Create the frame.
1738
    CreateRandomPayload(payload.data, seed1, seed2);
1739
    payload.length := 6;
1740
    frame := RioFrameCreate(ackId=>"00101", vc=>'0', crf=>'0', prio=>"00",
1741
                            tt=>"01", ftype=>"0000",
1742
                            sourceId=>x"0000", destId=>x"0000",
1743
                            payload=>payload);
1744
    frameValid(5) <= '1';
1745
    frameWrite(5) <= frame;
1746
 
1747
    -- Receive the frame.
1748
    ReceiveSymbol(SYMBOL_IDLE);
1749
    ReceiveSymbol(SYMBOL_CONTROL,
1750
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1751
                                         STYPE1_START_OF_PACKET, "000"));
1752
    for i in 0 to frame.length-1 loop
1753
      ReceiveSymbol(SYMBOL_DATA, frame.payload(i));
1754
    end loop;
1755
 
1756 15 magro732
    wait until frameComplete(5) = '1' and clk'event and clk = '1';
1757 4 magro732
    frameValid(5) <= '0';
1758
 
1759
    ReceiveSymbol(SYMBOL_CONTROL,
1760
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1761
                                         STYPE1_END_OF_PACKET, "000"));
1762
 
1763
    -- Wait a while to let the timer expire and receive the link-request.
1764
    for i in 0 to 2048 loop
1765
      wait until clk'event and clk = '1';
1766
    end loop;
1767
    ReceiveSymbol(SYMBOL_IDLE);
1768
    ReceiveSymbol(SYMBOL_CONTROL,
1769
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1770
                                         STYPE1_LINK_REQUEST, "100"));
1771
 
1772
    -- Send a link-response that indicates that the frame was received to make
1773
    -- the transmitter to back to normal mode.
1774
    SendSymbol(SYMBOL_CONTROL,
1775
               RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "00110", "11111",
1776
                                      STYPE1_NOP, "000"));
1777
 
1778
    ---------------------------------------------------------------------------
1779
    PrintS("-----------------------------------------------------------------");
1780
    PrintS("Step 7:");
1781
    PrintS("Action: Let a packet timeout expire. No more replies.");
1782
    PrintS("Result: Three link-requests should be transmitted. When the third");
1783
    PrintS("        times out the link will be restarted.");
1784
    ---------------------------------------------------------------------------
1785
    PrintR("TG_RioSerial-TC4-Step7");
1786
    ---------------------------------------------------------------------------
1787
 
1788
    -- Create the frame.
1789
    CreateRandomPayload(payload.data, seed1, seed2);
1790
    payload.length := 7;
1791
    frame := RioFrameCreate(ackId=>"00110", vc=>'0', crf=>'0', prio=>"00",
1792
                            tt=>"01", ftype=>"0000",
1793
                            sourceId=>x"0000", destId=>x"0000",
1794
                            payload=>payload);
1795
    frameValid(6) <= '1';
1796
    frameWrite(6) <= frame;
1797
 
1798
    -- Receive the frame.
1799
    ReceiveSymbol(SYMBOL_IDLE);
1800
    ReceiveSymbol(SYMBOL_CONTROL,
1801
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1802
                                         STYPE1_START_OF_PACKET, "000"));
1803
    for i in 0 to frame.length-1 loop
1804
      ReceiveSymbol(SYMBOL_DATA, frame.payload(i));
1805
    end loop;
1806
    ReceiveSymbol(SYMBOL_CONTROL,
1807
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1808
                                         STYPE1_END_OF_PACKET, "000"));
1809
 
1810
    -- Wait a while to let the timer expire and receive the link-request.
1811
    for i in 0 to 2048 loop
1812
      wait until clk'event and clk = '1';
1813
    end loop;
1814
    ReceiveSymbol(SYMBOL_IDLE);
1815
    ReceiveSymbol(SYMBOL_CONTROL,
1816
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1817
                                         STYPE1_LINK_REQUEST, "100"));
1818
 
1819
    -- Wait a while to let the timer expire and receive the link-request.
1820
    for i in 0 to 2048 loop
1821
      wait until clk'event and clk = '1';
1822
    end loop;
1823
    ReceiveSymbol(SYMBOL_IDLE);
1824
    ReceiveSymbol(SYMBOL_CONTROL,
1825
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1826
                                         STYPE1_LINK_REQUEST, "100"));
1827
 
1828
    -- Wait a while to let the timer expire and receive the link-request.
1829
    for i in 0 to 2048 loop
1830
      wait until clk'event and clk = '1';
1831
    end loop;
1832
    ReceiveSymbol(SYMBOL_IDLE);
1833
    ReceiveSymbol(SYMBOL_CONTROL,
1834
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1835
                                         STYPE1_LINK_REQUEST, "100"));
1836
 
1837
    -- Wait a while to let the timer expire and receive the link-request.
1838
    for i in 0 to 2048 loop
1839
      wait until clk'event and clk = '1';
1840
    end loop;
1841
 
1842
    -- Reinitialize the transmitter.
1843
    for i in 0 to 255 loop
1844
      ReceiveSymbol(SYMBOL_IDLE);
1845
    end loop;
1846
    ReceiveSymbol(SYMBOL_CONTROL,
1847
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1848
                                         STYPE1_NOP, "000"));
1849
    SendSymbol(SYMBOL_CONTROL,
1850
               RioControlSymbolCreate(STYPE0_STATUS, "00110", "11111",
1851
                                      STYPE1_NOP, "000"));
1852
    for j in 0 to 14 loop
1853
      for i in 0 to 15 loop
1854
        ReceiveSymbol(SYMBOL_IDLE);
1855
      end loop;
1856
      ReceiveSymbol(SYMBOL_CONTROL,
1857
                    RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1858
                                           STYPE1_NOP, "000"));
1859
    end loop;
1860
 
1861
    -- Receive the frame.
1862
    ReceiveSymbol(SYMBOL_CONTROL,
1863
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1864
                                         STYPE1_START_OF_PACKET, "000"));
1865
    for i in 0 to frame.length-1 loop
1866
      ReceiveSymbol(SYMBOL_DATA, frame.payload(i));
1867
    end loop;
1868
 
1869 15 magro732
    wait until frameComplete(6) = '1' and clk'event and clk = '1';
1870 4 magro732
    frameValid(6) <= '0';
1871
 
1872
    ReceiveSymbol(SYMBOL_CONTROL,
1873
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1874
                                         STYPE1_END_OF_PACKET, "000"));
1875
    SendSymbol(SYMBOL_CONTROL,
1876
               RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00110", "11111",
1877
                                      STYPE1_NOP, "000"));
1878
 
1879
    ---------------------------------------------------------------------------
1880
    PrintS("-----------------------------------------------------------------");
1881
    PrintS("Step 8:");
1882
    PrintS("Action: Let a packet timeout expire. Then answer with totally ");
1883
    PrintS("        unexpected ackId.");
1884
    PrintS("Result: A link request should be transmitted and the link should ");
1885
    PrintS("        be restarted.");
1886
    ---------------------------------------------------------------------------
1887
    PrintR("TG_RioSerial-TC4-Step8");
1888
    ---------------------------------------------------------------------------
1889
 
1890
    -- Create the frame.
1891
    CreateRandomPayload(payload.data, seed1, seed2);
1892
    payload.length := 8;
1893
    frame := RioFrameCreate(ackId=>"00111", vc=>'0', crf=>'0', prio=>"00",
1894
                            tt=>"01", ftype=>"0000",
1895
                            sourceId=>x"0000", destId=>x"0000",
1896
                            payload=>payload);
1897
    frameValid(7) <= '1';
1898
    frameWrite(7) <= frame;
1899
 
1900
    -- Receive the frame.
1901
    ReceiveSymbol(SYMBOL_IDLE);
1902
    ReceiveSymbol(SYMBOL_CONTROL,
1903
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1904
                                         STYPE1_START_OF_PACKET, "000"));
1905
    for i in 0 to frame.length-1 loop
1906
      ReceiveSymbol(SYMBOL_DATA, frame.payload(i));
1907
    end loop;
1908
    ReceiveSymbol(SYMBOL_CONTROL,
1909
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1910
                                         STYPE1_END_OF_PACKET, "000"));
1911
 
1912
    -- Wait a while to let the timer expire and receive the link-request.
1913
    for i in 0 to 2048 loop
1914
      wait until clk'event and clk = '1';
1915
    end loop;
1916
    ReceiveSymbol(SYMBOL_IDLE);
1917
    ReceiveSymbol(SYMBOL_CONTROL,
1918
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1919
                                         STYPE1_LINK_REQUEST, "100"));
1920
 
1921
    -- Send a link-response with unexpected ackId.
1922
    SendSymbol(SYMBOL_CONTROL,
1923
               RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "10000", "11111",
1924
                                      STYPE1_NOP, "000"));
1925
 
1926
    -- Reinitialize the transmitter.
1927
    for i in 0 to 255 loop
1928
      ReceiveSymbol(SYMBOL_IDLE);
1929
    end loop;
1930
    ReceiveSymbol(SYMBOL_CONTROL,
1931
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1932
                                         STYPE1_NOP, "000"));
1933
    SendSymbol(SYMBOL_CONTROL,
1934
               RioControlSymbolCreate(STYPE0_STATUS, "00111", "11111",
1935
                                      STYPE1_NOP, "000"));
1936
    for j in 0 to 14 loop
1937
      for i in 0 to 15 loop
1938
        ReceiveSymbol(SYMBOL_IDLE);
1939
      end loop;
1940
      ReceiveSymbol(SYMBOL_CONTROL,
1941
                    RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1942
                                           STYPE1_NOP, "000"));
1943
    end loop;
1944
 
1945
    -- Receive the frame.
1946
    ReceiveSymbol(SYMBOL_CONTROL,
1947
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1948
                                         STYPE1_START_OF_PACKET, "000"));
1949
    for i in 0 to frame.length-1 loop
1950
      ReceiveSymbol(SYMBOL_DATA, frame.payload(i));
1951
    end loop;
1952
 
1953 15 magro732
    wait until frameComplete(7) = '1' and clk'event and clk = '1';
1954 4 magro732
    frameValid(7) <= '0';
1955
 
1956
    ReceiveSymbol(SYMBOL_CONTROL,
1957
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1958
                                         STYPE1_END_OF_PACKET, "000"));
1959
    SendSymbol(SYMBOL_CONTROL,
1960
               RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "00111", "11111",
1961
                                      STYPE1_NOP, "000"));
1962
 
1963
    ---------------------------------------------------------------------------
1964
    PrintS("-----------------------------------------------------------------");
1965
    PrintS("Step 9:");
1966
    PrintS("Action: Send status with unexpected ackId in normal operation.");
1967
    PrintS("Result: The transmitter should disregard the error.");
1968
    ---------------------------------------------------------------------------
1969
    PrintR("TG_RioSerial-TC4-Step9");
1970
    ---------------------------------------------------------------------------
1971
 
1972
    -- Send a status with unexpected ackId.
1973
    SendSymbol(SYMBOL_CONTROL,
1974
               RioControlSymbolCreate(STYPE0_STATUS, "10000", "11111",
1975
                                      STYPE1_NOP, "000"));
1976
 
1977
    -- Receive no change.
1978
    ReceiveSymbol(SYMBOL_IDLE);
1979
    ReceiveSymbol(SYMBOL_IDLE);
1980
 
1981
    ---------------------------------------------------------------------------
1982
    PrintS("-----------------------------------------------------------------");
1983
    PrintS("Step 10:");
1984
    PrintS("Action: Send packet-retry with unexpected ackId in normal operation.");
1985
    PrintS("Result: The transmitter should enter output-error-stopped.");
1986
    ---------------------------------------------------------------------------
1987
    PrintR("TG_RioSerial-TC4-Step10");
1988
    ---------------------------------------------------------------------------
1989
 
1990
    -- Send a packet-retry with unexpected ackId.
1991
    SendSymbol(SYMBOL_CONTROL,
1992
               RioControlSymbolCreate(STYPE0_PACKET_RETRY, "10000", "11111",
1993
                                      STYPE1_NOP, "000"));
1994
 
1995
    -- Receive link-request.
1996
    ReceiveSymbol(SYMBOL_IDLE);
1997
    ReceiveSymbol(SYMBOL_CONTROL,
1998
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
1999
                                         STYPE1_LINK_REQUEST, "100"));
2000
 
2001
    -- Send a link-response with unexpected ackId.
2002
    SendSymbol(SYMBOL_CONTROL,
2003
               RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01000", "11111",
2004
                                      STYPE1_NOP, "000"));
2005
 
2006
    -- Create the frame.
2007
    CreateRandomPayload(payload.data, seed1, seed2);
2008
    payload.length := 10;
2009
    frame := RioFrameCreate(ackId=>"01000", vc=>'0', crf=>'0', prio=>"00",
2010
                            tt=>"01", ftype=>"0000",
2011
                            sourceId=>x"0000", destId=>x"0000",
2012
                            payload=>payload);
2013
    frameValid(8) <= '1';
2014
    frameWrite(8) <= frame;
2015
 
2016
    -- Receive the frame.
2017
    ReceiveSymbol(SYMBOL_IDLE);
2018
    ReceiveSymbol(SYMBOL_CONTROL,
2019
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
2020
                                         STYPE1_START_OF_PACKET, "000"));
2021
    for i in 0 to frame.length-1 loop
2022
      ReceiveSymbol(SYMBOL_DATA, frame.payload(i));
2023
    end loop;
2024
 
2025 15 magro732
    wait until frameComplete(8) = '1' and clk'event and clk = '1';
2026 4 magro732
    frameValid(8) <= '0';
2027
 
2028
    ReceiveSymbol(SYMBOL_CONTROL,
2029
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
2030
                                         STYPE1_END_OF_PACKET, "000"));
2031
    SendSymbol(SYMBOL_CONTROL,
2032
               RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01000", "11111",
2033
                                      STYPE1_NOP, "000"));
2034
 
2035
    ---------------------------------------------------------------------------
2036
    PrintS("-----------------------------------------------------------------");
2037
    PrintS("Step 11:");
2038
    PrintS("Action: Send packet-accepted with unexpected ackId in normal ");
2039
    PrintS("        operation.");
2040
    PrintS("Result: The transmitter should enter output-error-stopped.");
2041
    ---------------------------------------------------------------------------
2042
    PrintR("TG_RioSerial-TC4-Step11");
2043
    ---------------------------------------------------------------------------
2044 14 magro732
 
2045 4 magro732
    -- Send a packet-accepted with unexpected ackId.
2046
    SendSymbol(SYMBOL_CONTROL,
2047
               RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "10000", "11111",
2048
                                      STYPE1_NOP, "000"));
2049
 
2050
    -- Receive link-request.
2051
    ReceiveSymbol(SYMBOL_IDLE);
2052
    ReceiveSymbol(SYMBOL_CONTROL,
2053
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
2054
                                         STYPE1_LINK_REQUEST, "100"));
2055
 
2056
    -- Send a link-response with unexpected ackId.
2057
    SendSymbol(SYMBOL_CONTROL,
2058
               RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01001", "11111",
2059
                                      STYPE1_NOP, "000"));
2060
 
2061
    -- Create the frame.
2062
    CreateRandomPayload(payload.data, seed1, seed2);
2063
    payload.length := 11;
2064
    frame := RioFrameCreate(ackId=>"01001", vc=>'0', crf=>'0', prio=>"00",
2065
                            tt=>"01", ftype=>"0000",
2066
                            sourceId=>x"0000", destId=>x"0000",
2067
                            payload=>payload);
2068
    frameValid(9) <= '1';
2069
    frameWrite(9) <= frame;
2070
 
2071
    -- Receive the frame.
2072
    ReceiveSymbol(SYMBOL_IDLE);
2073
    ReceiveSymbol(SYMBOL_CONTROL,
2074
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
2075
                                         STYPE1_START_OF_PACKET, "000"));
2076
    for i in 0 to frame.length-1 loop
2077
      ReceiveSymbol(SYMBOL_DATA, frame.payload(i));
2078
    end loop;
2079
 
2080 15 magro732
    wait until frameComplete(9) = '1' and clk'event and clk = '1';
2081 4 magro732
    frameValid(9) <= '0';
2082
 
2083
    ReceiveSymbol(SYMBOL_CONTROL,
2084
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
2085
                                         STYPE1_END_OF_PACKET, "000"));
2086
    SendSymbol(SYMBOL_CONTROL,
2087
               RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01001", "11111",
2088
                                      STYPE1_NOP, "000"));
2089
 
2090
    ---------------------------------------------------------------------------
2091
    PrintS("-----------------------------------------------------------------");
2092
    PrintS("Step 12:");
2093
    PrintS("Action: Send a packet and then accept it with unexpected ackId.");
2094
    PrintS("Result: The transmitter should enter output-error-stopped.");
2095
    ---------------------------------------------------------------------------
2096
    PrintR("TG_RioSerial-TC4-Step12");
2097
    ---------------------------------------------------------------------------
2098
 
2099
    -- Create the frame.
2100
    CreateRandomPayload(payload.data, seed1, seed2);
2101
    payload.length := 12;
2102
    frame := RioFrameCreate(ackId=>"01010", vc=>'0', crf=>'0', prio=>"00",
2103
                            tt=>"01", ftype=>"0000",
2104
                            sourceId=>x"0000", destId=>x"0000",
2105
                            payload=>payload);
2106
    frameValid(10) <= '1';
2107
    frameWrite(10) <= frame;
2108
 
2109
    -- Receive the frame.
2110
    ReceiveSymbol(SYMBOL_IDLE);
2111
    ReceiveSymbol(SYMBOL_CONTROL,
2112
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
2113
                                         STYPE1_START_OF_PACKET, "000"));
2114
    for i in 0 to frame.length-1 loop
2115
      ReceiveSymbol(SYMBOL_DATA, frame.payload(i));
2116
    end loop;
2117
 
2118 15 magro732
    wait until frameComplete(10) = '1' and clk'event and clk = '1';
2119 4 magro732
    frameValid(10) <= '0';
2120
 
2121
    ReceiveSymbol(SYMBOL_CONTROL,
2122
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
2123
                                         STYPE1_END_OF_PACKET, "000"));
2124
 
2125
    -- Send unexpected ackId in packet-accepted.
2126
    SendSymbol(SYMBOL_CONTROL,
2127
               RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "10000", "11111",
2128
                                      STYPE1_NOP, "000"));
2129
 
2130
    -- Receive link-request.
2131
    ReceiveSymbol(SYMBOL_IDLE);
2132
    ReceiveSymbol(SYMBOL_CONTROL,
2133
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
2134
                                         STYPE1_LINK_REQUEST, "100"));
2135
 
2136
    -- Send a link-response with expected ackId.
2137
    SendSymbol(SYMBOL_CONTROL,
2138
               RioControlSymbolCreate(STYPE0_LINK_RESPONSE, "01011", "11111",
2139
                                      STYPE1_NOP, "000"));
2140
 
2141
    ---------------------------------------------------------------------------
2142
    PrintS("-----------------------------------------------------------------");
2143
    PrintS("Step 13:");
2144
    PrintS("Action: Set two valid packets.");
2145
    PrintS("Result: The two packet should be sent without waiting for ");
2146
    PrintS("        packet-accepted.");
2147
    ---------------------------------------------------------------------------
2148
    PrintR("TG_RioSerial-TC4-Step13");
2149
    ---------------------------------------------------------------------------
2150
 
2151
    -- Create the first frame.
2152
    CreateRandomPayload(payload.data, seed1, seed2);
2153
    payload.length := 13;
2154
    frame := RioFrameCreate(ackId=>"01011", vc=>'0', crf=>'0', prio=>"00",
2155
                            tt=>"01", ftype=>"0000",
2156
                            sourceId=>x"0000", destId=>x"0000",
2157
                            payload=>payload);
2158
    frameValid(11) <= '1';
2159
    frameWrite(11) <= frame;
2160
 
2161
    -- Create the second frame.
2162
    CreateRandomPayload(payload.data, seed1, seed2);
2163
    payload.length := 14;
2164
    frame := RioFrameCreate(ackId=>"01100", vc=>'0', crf=>'0', prio=>"00",
2165
                            tt=>"01", ftype=>"0000",
2166
                            sourceId=>x"0000", destId=>x"0000",
2167
                            payload=>payload);
2168
    frameValid(12) <= '1';
2169
    frameWrite(12) <= frame;
2170
 
2171
    -- Receive the frame.
2172
    ReceiveSymbol(SYMBOL_IDLE);
2173
    ReceiveSymbol(SYMBOL_CONTROL,
2174
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
2175
                                         STYPE1_START_OF_PACKET, "000"));
2176
    for i in 0 to frameWrite(11).length-1 loop
2177
      ReceiveSymbol(SYMBOL_DATA, frameWrite(11).payload(i));
2178
    end loop;
2179
 
2180
    -- Receive the frame.
2181
    ReceiveSymbol(SYMBOL_CONTROL,
2182
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
2183
                                         STYPE1_START_OF_PACKET, "000"));
2184
    for i in 0 to frameWrite(12).length-1 loop
2185
      ReceiveSymbol(SYMBOL_DATA, frameWrite(12).payload(i));
2186
    end loop;
2187
 
2188 15 magro732
    wait until frameComplete(11) = '1' and clk'event and clk = '1';
2189
    frameValid(11) <= '0';
2190
    wait until frameComplete(12) = '1' and clk'event and clk = '1';
2191 4 magro732
    frameValid(12) <= '0';
2192
 
2193
    ReceiveSymbol(SYMBOL_CONTROL,
2194
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
2195
                                         STYPE1_END_OF_PACKET, "000"));
2196
 
2197
    -- Send packet-accepted for both packets.
2198
    SendSymbol(SYMBOL_CONTROL,
2199
               RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01011", "11111",
2200
                                      STYPE1_NOP, "000"));
2201
    SendSymbol(SYMBOL_CONTROL,
2202
               RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01100", "11111",
2203
                                      STYPE1_NOP, "000"));
2204
 
2205
    ---------------------------------------------------------------------------
2206
    PrintS("-----------------------------------------------------------------");
2207
    PrintS("Step 14:");
2208
    PrintS("Action: Set maximum number of valid packets.");
2209
    PrintS("Result: Maximum 31 packets should be sent without waiting for ");
2210
    PrintS("        packet-accepted.");
2211
    ---------------------------------------------------------------------------
2212
    PrintR("TG_RioSerial-TC4-Step14");
2213
    ---------------------------------------------------------------------------
2214
 
2215
    ---------------------------------------------------------------------------
2216
    -- Create the frames.
2217
    ---------------------------------------------------------------------------
2218
 
2219
    for j in 0 to 47 loop
2220
      CreateRandomPayload(payload.data, seed1, seed2);
2221
      payload.length := j+13;
2222 15 magro732
      frame := RioFrameCreate(ackId=>std_logic_vector(to_unsigned((j+13) mod 32, 5)),
2223
                              vc=>'0', crf=>'0', prio=>"00",
2224 4 magro732
                              tt=>"01", ftype=>"0000",
2225
                              sourceId=>x"0000", destId=>x"0000",
2226
                              payload=>payload);
2227
      frameValid(j+13) <= '1';
2228
      frameWrite(j+13) <= frame;
2229
    end loop;
2230
 
2231
    ---------------------------------------------------------------------------
2232
    -- Receive the frames.
2233
    ---------------------------------------------------------------------------
2234
 
2235
    ReceiveSymbol(SYMBOL_IDLE);
2236
 
2237 15 magro732
    for j in 0 to 29 loop
2238 4 magro732
      ReceiveSymbol(SYMBOL_CONTROL,
2239
                    RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
2240
                                           STYPE1_START_OF_PACKET, "000"));
2241
      for i in 0 to frameWrite(j+13).length-1 loop
2242
        ReceiveSymbol(SYMBOL_DATA, frameWrite(j+13).payload(i));
2243
      end loop;
2244
 
2245 15 magro732
      wait until frameComplete(j+13) = '1' and clk'event and clk = '1';
2246 4 magro732
      frameValid(j+13) <= '0';
2247
    end loop;
2248
 
2249 15 magro732
    ReceiveSymbol(SYMBOL_CONTROL,
2250
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
2251
                                         STYPE1_START_OF_PACKET, "000"));
2252
    for i in 0 to frameWrite(43).length-1 loop
2253
      ReceiveSymbol(SYMBOL_DATA, frameWrite(43).payload(i));
2254
    end loop;
2255
    ReceiveSymbol(SYMBOL_CONTROL,
2256
                  RioControlSymbolCreate(STYPE0_STATUS, "01100", "11111",
2257
                                         STYPE1_END_OF_PACKET, "000"));
2258
    wait until frameComplete(43) = '1' and clk'event and clk = '1';
2259
    frameValid(43) <= '0';
2260
 
2261 18 magro732
    -- REMARK: Complete the testcase and acknowledge all transmitted packets...
2262 4 magro732
    SendSymbol(SYMBOL_CONTROL,
2263
               RioControlSymbolCreate(STYPE0_PACKET_ACCEPTED, "01101", "11111",
2264
                                      STYPE1_NOP, "000"));
2265
 
2266
 
2267
    ---------------------------------------------------------------------------
2268
    PrintS("-----------------------------------------------------------------");
2269
    PrintS("Step X:");
2270
    PrintS("Action: Start sending an outbound packet and while in transmission, ");
2271
    PrintS("        start and complete an inbound packet.");
2272
    PrintS("Result: The ack for the inbound packet should be inserted into the");
2273
    PrintS("        outbound packet.");
2274
    ---------------------------------------------------------------------------
2275
    PrintR("TG_RioSerial-TC4-StepX");
2276
    ---------------------------------------------------------------------------
2277
 
2278
    ---------------------------------------------------------------------------
2279
    PrintS("-----------------------------------------------------------------");
2280
    PrintS("Step X:");
2281
    PrintS("Action: Send a packet but not all content is available yet.");
2282
    PrintS("Result: Idle symbols should be inserted into the packet.");
2283
    ---------------------------------------------------------------------------
2284
    PrintR("TG_RioSerial-TC4-StepX");
2285
    ---------------------------------------------------------------------------
2286
 
2287
    ---------------------------------------------------------------------------
2288
    -- REMARK: Send long frames with a CRC in the middle...
2289
    ---------------------------------------------------------------------------
2290
 
2291
    ---------------------------------------------------------------------------
2292
    -- Test completed.
2293
    ---------------------------------------------------------------------------
2294
 
2295
    TestEnd;
2296
  end process;
2297
 
2298
 
2299
  -----------------------------------------------------------------------------
2300
  -- Instantiate the uart.
2301
  -----------------------------------------------------------------------------
2302
 
2303
  TestPort: TestSwitchPort
2304 12 magro732
    generic map(
2305 26 magro732
      NUMBER_WORDS=>NUMBER_WORDS)
2306 4 magro732
    port map(
2307
      clk=>clk, areset_n=>areset_n,
2308
      frameValid_i=>frameValid, frameWrite_i=>frameWrite, frameComplete_o=>frameComplete,
2309
      frameExpected_i=>frameExpected, frameRead_i=>frameRead, frameReceived_o=>frameReceived,
2310
      readFrameEmpty_o=>readFrameEmpty, readFrame_i=>readFrame,
2311
      readFrameRestart_i=>readFrameRestart, readFrameAborted_o=>readFrameAborted,
2312
      readWindowEmpty_o=>readWindowEmpty,
2313
      readWindowReset_i=>readWindowReset, readWindowNext_i=>readWindowNext,
2314
      readContentEmpty_o=>readContentEmpty, readContent_i=>readContent,
2315
      readContentEnd_o=>readContentEnd, readContentData_o=>readContentData,
2316
      writeFrameFull_o=>writeFrameFull, writeFrame_i=>writeFrame, writeFrameAbort_i=>writeFrameAbort,
2317
      writeContent_i=>writeContent, writeContentData_i=>writeContentData);
2318
 
2319
  TestPhy: RioSerial
2320
    generic map(
2321 26 magro732
      TIMEOUT_WIDTH=>11,
2322
      NUMBER_WORDS=>NUMBER_WORDS)
2323 4 magro732
    port map(
2324
      clk=>clk, areset_n=>areset_n,
2325
      portLinkTimeout_i=>portLinkTimeout,
2326
      linkInitialized_o=>linkInitialized,
2327
      inputPortEnable_i=>inputPortEnable,
2328
      outputPortEnable_i=>outputPortEnable,
2329
      localAckIdWrite_i=>localAckIdWrite,
2330
      clrOutstandingAckId_i=>clrOutstandingAckId,
2331
      inboundAckId_i=>inboundAckIdWrite,
2332
      outstandingAckId_i=>outstandingAckIdWrite,
2333
      outboundAckId_i=>outboundAckIdWrite,
2334
      inboundAckId_o=>inboundAckIdRead,
2335
      outstandingAckId_o=>outstandingAckIdRead,
2336
      outboundAckId_o=>outboundAckIdRead,
2337 26 magro732
      readFrameEmpty_i=>readFrameEmpty,
2338
      readFrame_o=>readFrame,
2339
      readFrameRestart_o=>readFrameRestart,
2340 4 magro732
      readFrameAborted_i=>readFrameAborted,
2341
      readWindowEmpty_i=>readWindowEmpty,
2342 26 magro732
      readWindowReset_o=>readWindowReset,
2343
      readWindowNext_o=>readWindowNext,
2344 4 magro732
      readContentEmpty_i=>readContentEmpty,
2345 26 magro732
      readContent_o=>readContent,
2346
      readContentEnd_i=>readContentEnd,
2347
      readContentData_i=>readContentData,
2348
      writeFrameFull_i=>writeFrameFull,
2349
      writeFrame_o=>writeFrame,
2350
      writeFrameAbort_o=>writeFrameAbort,
2351
      writeContent_o=>writeContent,
2352
      writeContentData_o=>writeContentData,
2353 4 magro732
      portInitialized_i=>portInitialized,
2354 16 magro732
      outboundSymbolFull_i=>outboundSymbolFull,
2355
      outboundSymbolWrite_o=>outboundSymbolWrite,
2356 26 magro732
      outboundSymbolType_o=>outboundSymbolType,
2357 4 magro732
      outboundSymbol_o=>outboundSymbol,
2358 16 magro732
      inboundSymbolEmpty_i=>inboundSymbolEmpty,
2359
      inboundSymbolRead_o=>inboundSymbolRead,
2360 26 magro732
      inboundSymbolType_i=>inboundSymbolType,
2361 4 magro732
      inboundSymbol_i=>inboundSymbol);
2362
 
2363
end architecture;
2364
 
2365
 
2366
 
2367
-------------------------------------------------------------------------------
2368
-- 
2369
-------------------------------------------------------------------------------
2370
library ieee;
2371
use ieee.std_logic_1164.all;
2372
use ieee.numeric_std.all;
2373
library std;
2374
use std.textio.all;
2375
use work.rio_common.all;
2376
 
2377
 
2378
-------------------------------------------------------------------------------
2379
-- 
2380
-------------------------------------------------------------------------------
2381
entity TestSwitchPort is
2382 12 magro732
  generic(
2383 26 magro732
    NUMBER_WORDS : natural range 1 to 4 := 1);
2384 4 magro732
  port(
2385
    clk : in std_logic;
2386
    areset_n : in std_logic;
2387
 
2388
    frameValid_i : in std_logic_vector(0 to 63);
2389
    frameWrite_i : in RioFrameArray(0 to 63);
2390 15 magro732
    frameComplete_o : out std_logic_vector(0 to 63);
2391 4 magro732
 
2392
    frameExpected_i : in std_logic;
2393
    frameRead_i : in RioFrame;
2394
    frameReceived_o : out std_logic;
2395
 
2396
    readFrameEmpty_o : out std_logic;
2397
    readFrame_i : in std_logic;
2398
    readFrameRestart_i : in std_logic;
2399
    readFrameAborted_o : out std_logic;
2400
 
2401
    readWindowEmpty_o : out std_logic;
2402
    readWindowReset_i : in std_logic;
2403
    readWindowNext_i : in std_logic;
2404
 
2405
    readContentEmpty_o : out std_logic;
2406
    readContent_i : in std_logic;
2407
    readContentEnd_o : out std_logic;
2408 26 magro732
    readContentData_o : out std_logic_vector(2+(32*NUMBER_WORDS-1) downto 0);
2409 4 magro732
 
2410
    writeFrameFull_o : out std_logic;
2411
    writeFrame_i : in std_logic;
2412
    writeFrameAbort_i : in std_logic;
2413
    writeContent_i : in std_logic;
2414 26 magro732
    writeContentData_i : in std_logic_vector(2+(32*NUMBER_WORDS-1) downto 0));
2415 4 magro732
end entity;
2416
 
2417
 
2418
-------------------------------------------------------------------------------
2419
-- 
2420
-------------------------------------------------------------------------------
2421
architecture TestSwitchPortImpl of TestSwitchPort is
2422
begin
2423
 
2424
  -----------------------------------------------------------------------------
2425
  -- 
2426
  -----------------------------------------------------------------------------
2427
  FrameSender: process
2428 15 magro732
    variable frameComplete : std_logic_vector(0 to 63);
2429 4 magro732
    variable frameIndex : natural range 0 to 70;
2430
    variable backIndex, frontIndex : natural range 0 to 63;
2431 26 magro732
    variable remaining : natural;
2432 4 magro732
  begin
2433
    readFrameEmpty_o <= '1';
2434
    readFrameAborted_o <= '0';
2435
    readWindowEmpty_o <= '1';
2436
    readContentEmpty_o <= '1';
2437
    readContentEnd_o <= '0';
2438
    readContentData_o <= (others=>'U');
2439 15 magro732
    frameComplete_o <= (others=>'0');
2440
    frameComplete := (others=>'0');
2441 4 magro732
    backIndex := 0;
2442
    frontIndex := 0;
2443
    wait until areset_n = '1';
2444
 
2445
    loop
2446
      wait until clk'event and clk = '1';
2447
 
2448
      if (readFrame_i = '1') then
2449
        assert (frontIndex - backIndex) >= 0 report "Unexpected readFrame." severity error;
2450
        if(backIndex < 63) then
2451
          backIndex := backIndex + 1;
2452
        else
2453
          backIndex := 0;
2454
        end if;
2455
      end if;
2456
 
2457
      if (readWindowReset_i = '1') then
2458 15 magro732
        frameComplete := (others=>'0');
2459 4 magro732
        frameIndex := 0;
2460
        frontIndex := backIndex;
2461
        readContentEnd_o <= '0';
2462
        readContentData_o <= (others=>'U');
2463
      end if;
2464
 
2465
      if (readWindowNext_i = '1') then
2466 15 magro732
        assert frameComplete(frontIndex) = '0' report "Reading next frame too fast." severity error;
2467 4 magro732
        assert frameIndex = frameWrite_i(frontIndex).length report "Did not read all frame content." severity error;
2468
        readContentEnd_o <= '0';
2469
        readContentData_o <= (others=>'U');
2470 15 magro732
        frameComplete(frontIndex) := '1';
2471
        frameIndex := 0;
2472
        if(frontIndex < 63) then
2473
          frontIndex := frontIndex + 1;
2474
        else
2475
          frontIndex := 0;
2476 4 magro732
        end if;
2477
      end if;
2478 15 magro732
 
2479
      for i in 0 to 63 loop
2480
        if (frameComplete(i) = '1') and (frameValid_i(i) = '0') then
2481
          frameComplete(i) := '0';
2482
        end if;
2483
      end loop;
2484 13 magro732
      frameComplete_o <= frameComplete;
2485 15 magro732
 
2486
      if ((frameComplete(frontIndex) = '0') and
2487
          (frameValid_i(frontIndex) = '1')) then
2488
        readWindowEmpty_o <= '0';
2489
      else
2490
        readWindowEmpty_o <= '1';
2491
      end if;
2492
 
2493 4 magro732
      if (readFrameRestart_i = '1') then
2494
        frameIndex := 0;
2495
        readContentEnd_o <= '0';
2496
        readContentData_o <= (others=>'U');
2497
      end if;
2498
 
2499
      if (readContent_i = '1') then
2500
        assert frameValid_i(frontIndex) = '1' report "Unexpected content read." severity error;
2501 26 magro732
        remaining := frameWrite_i(frontIndex).length - frameIndex;
2502
        if (remaining > NUMBER_WORDS) then
2503
          readContentData_o(2+(32*NUMBER_WORDS-1) downto 2+(32*NUMBER_WORDS-1)-1) <= std_logic_vector(to_unsigned(NUMBER_WORDS, 2));
2504
          remaining := NUMBER_WORDS;
2505
        else
2506
          readContentData_o(2+(32*NUMBER_WORDS-1) downto 2+(32*NUMBER_WORDS-1)-1) <= std_logic_vector(to_unsigned(remaining, 2));
2507
        end if;
2508
 
2509
        for i in 0 to remaining-1 loop
2510
          readContentData_o((NUMBER_WORDS*32-1)-32*i downto (NUMBER_WORDS-1)*32-32*i) <= frameWrite_i(frontIndex).payload(frameIndex);
2511
          frameIndex := frameIndex + 1;
2512
        end loop;
2513
 
2514 4 magro732
        if (frameIndex /= frameWrite_i(frontIndex).length) then
2515
          readContentEnd_o <= '0';
2516
        else
2517
          readContentEnd_o <= '1';
2518
        end if;
2519
      end if;
2520 15 magro732
 
2521
      if(frameValid_i(frontIndex) = '1') and (frameComplete(frontIndex) = '0') then
2522 4 magro732
        readFrameEmpty_o <= '0';
2523
        readContentEmpty_o <= '0';
2524
      else
2525
        readFrameEmpty_o <= '1';
2526
        readContentEmpty_o <= '1';
2527
      end if;
2528
 
2529
    end loop;
2530
  end process;
2531
 
2532
  -----------------------------------------------------------------------------
2533
  -- 
2534
  -----------------------------------------------------------------------------
2535
  FrameReader: process
2536
    type StateType is (STATE_IDLE, STATE_READ, STATE_UPDATE);
2537
    variable state : StateType;
2538
    variable frameIndex : natural range 0 to 69;
2539 26 magro732
    variable words : natural range 0 to 4;
2540 4 magro732
  begin
2541
    writeFrameFull_o <= '1';
2542
    frameReceived_o <= '0';
2543
    wait until areset_n = '1';
2544
 
2545
    state := STATE_IDLE;
2546
 
2547
    loop
2548
      wait until clk'event and clk = '1';
2549
 
2550
      case state is
2551
        when STATE_IDLE =>
2552
          frameReceived_o <= '0';
2553
          if (frameExpected_i = '1') then
2554
            state := STATE_READ;
2555
            frameIndex := 0;
2556
            writeFrameFull_o <= '0';
2557
          end if;
2558
          assert writeFrame_i = '0' report "Unexpected frame received." severity error;
2559
          --assert writeFrameAbort_i = '0' report "Unexpected frame aborted received." severity error;
2560
          assert writeContent_i = '0' report "Unexpected content received." severity error;
2561
 
2562
        when STATE_READ =>
2563
          if (writeFrame_i = '1') then
2564
            state := STATE_UPDATE;
2565
            frameReceived_o <= '1';
2566
            writeFrameFull_o <= '1';
2567
            assert frameIndex = frameRead_i.length report "Did not finish the expected frame." severity error;
2568
          end if;
2569
          if (writeFrameAbort_i = '1') then
2570
            frameIndex := 0;
2571
          end if;
2572
          if (writeContent_i = '1') then
2573 26 magro732
            words := to_integer(unsigned(writeContentData_i(2+(32*NUMBER_WORDS-1) downto 2+(32*NUMBER_WORDS-1)-1)));
2574
            for i in 0 to words loop
2575
              assert writeContentData_i((NUMBER_WORDS*32-1)-32*i downto (NUMBER_WORDS-1)*32-32*i) = frameRead_i.payload(frameIndex)
2576
                report "Unexpected frame content received." severity error;
2577
              frameIndex := frameIndex + 1;
2578
            end loop;
2579 4 magro732
          end if;
2580
          if (frameExpected_i = '0') then
2581
            state := STATE_IDLE;
2582
          end if;
2583
 
2584
        when STATE_UPDATE =>
2585
          if (frameExpected_i = '0') then
2586
            state := STATE_IDLE;
2587
          end if;
2588
 
2589
      end case;
2590
    end loop;
2591
  end process;
2592
 
2593
end architecture;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.