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

Subversion Repositories rio

[/] [rio/] [branches/] [2.0.0-development/] [bench/] [vhdl/] [TestRioSerial.vhd] - Blame information for rev 48

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

powered by: WebSVN 2.1.0

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