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

Subversion Repositories rio

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

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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