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

Subversion Repositories rio

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

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

powered by: WebSVN 2.1.0

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