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

Subversion Repositories rio

[/] [rio/] [trunk/] [bench/] [vhdl/] [TestRioSerial.vhd] - Blame information for rev 4

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

powered by: WebSVN 2.1.0

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