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

Subversion Repositories rio

[/] [rio/] [trunk/] [bench/] [vhdl/] [TestRioSwitch.vhd] - Blame information for rev 28

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 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 RioSwitch implementation.
10
-- 
11
-- To Do:
12
-- -
13
-- 
14
-- Author(s): 
15
-- - Magnus Rosenius, magro732@opencores.org 
16
-- 
17
-------------------------------------------------------------------------------
18
-- 
19
-- Copyright (C) 2013 Authors and OPENCORES.ORG 
20
-- 
21
-- This source file may be used and distributed without 
22
-- restriction provided that this copyright statement is not 
23
-- removed from the file and that any derivative work contains 
24
-- the original copyright notice and the associated disclaimer. 
25
-- 
26
-- This source file is free software; you can redistribute it 
27
-- and/or modify it under the terms of the GNU Lesser General 
28
-- Public License as published by the Free Software Foundation; 
29
-- either version 2.1 of the License, or (at your option) any 
30
-- later version. 
31
-- 
32
-- This source is distributed in the hope that it will be 
33
-- useful, but WITHOUT ANY WARRANTY; without even the implied 
34
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
35
-- PURPOSE. See the GNU Lesser General Public License for more 
36
-- details. 
37
-- 
38
-- You should have received a copy of the GNU Lesser General 
39
-- Public License along with this source; if not, download it 
40
-- from http://www.opencores.org/lgpl.shtml 
41
-- 
42
-------------------------------------------------------------------------------
43
 
44
 
45
-------------------------------------------------------------------------------
46
-- TestRioSwitch.
47
-------------------------------------------------------------------------------
48
 
49
library ieee;
50
use ieee.std_logic_1164.all;
51
use ieee.numeric_std.all;
52
use ieee.math_real.all;
53
library std;
54
use std.textio.all;
55
use work.rio_common.all;
56
 
57
 
58
-------------------------------------------------------------------------------
59
-- Entity for TestRioSwitch.
60
-------------------------------------------------------------------------------
61
entity TestRioSwitch is
62
end entity;
63
 
64
 
65
-------------------------------------------------------------------------------
66
-- Architecture for TestRioSwitch.
67
-------------------------------------------------------------------------------
68
architecture TestRioSwitchImpl of TestRioSwitch is
69
 
70
  component RioSwitch is
71
    generic(
72
      SWITCH_PORTS : natural range 3 to 255 := 4;
73
      DEVICE_IDENTITY : std_logic_vector(15 downto 0);
74
      DEVICE_VENDOR_IDENTITY : std_logic_vector(15 downto 0);
75
      DEVICE_REV : std_logic_vector(31 downto 0);
76
      ASSY_IDENTITY : std_logic_vector(15 downto 0);
77
      ASSY_VENDOR_IDENTITY : std_logic_vector(15 downto 0);
78
      ASSY_REV : std_logic_vector(15 downto 0));
79
    port(
80
      clk : in std_logic;
81
      areset_n : in std_logic;
82
 
83
      writeFrameFull_i : in Array1(SWITCH_PORTS-1 downto 0);
84
      writeFrame_o : out Array1(SWITCH_PORTS-1 downto 0);
85
      writeFrameAbort_o : out Array1(SWITCH_PORTS-1 downto 0);
86
      writeContent_o : out Array1(SWITCH_PORTS-1 downto 0);
87
      writeContentData_o : out Array32(SWITCH_PORTS-1 downto 0);
88
 
89
      readFrameEmpty_i : in Array1(SWITCH_PORTS-1 downto 0);
90
      readFrame_o : out Array1(SWITCH_PORTS-1 downto 0);
91
      readContent_o : out Array1(SWITCH_PORTS-1 downto 0);
92
      readContentEnd_i : in Array1(SWITCH_PORTS-1 downto 0);
93
      readContentData_i : in Array32(SWITCH_PORTS-1 downto 0);
94
 
95
      portLinkTimeout_o : out std_logic_vector(23 downto 0);
96
 
97
      linkInitialized_i : in Array1(SWITCH_PORTS-1 downto 0);
98
      outputPortEnable_o : out Array1(SWITCH_PORTS-1 downto 0);
99
      inputPortEnable_o : out Array1(SWITCH_PORTS-1 downto 0);
100
 
101
      localAckIdWrite_o : out Array1(SWITCH_PORTS-1 downto 0);
102
      clrOutstandingAckId_o : out Array1(SWITCH_PORTS-1 downto 0);
103
      inboundAckId_o : out Array5(SWITCH_PORTS-1 downto 0);
104
      outstandingAckId_o : out Array5(SWITCH_PORTS-1 downto 0);
105
      outboundAckId_o : out Array5(SWITCH_PORTS-1 downto 0);
106
      inboundAckId_i : in Array5(SWITCH_PORTS-1 downto 0);
107
      outstandingAckId_i : in Array5(SWITCH_PORTS-1 downto 0);
108
      outboundAckId_i : in Array5(SWITCH_PORTS-1 downto 0);
109
 
110
      configStb_o : out std_logic;
111
      configWe_o : out std_logic;
112
      configAddr_o : out std_logic_vector(23 downto 0);
113
      configData_o : out std_logic_vector(31 downto 0);
114
      configData_i : in std_logic_vector(31 downto 0));
115
  end component;
116
 
117
  component TestPort is
118
    port(
119
      clk : in std_logic;
120
      areset_n : in std_logic;
121
 
122
      frameValid_i : in std_logic;
123
      frameWrite_i : in RioFrame;
124
      frameComplete_o : out std_logic;
125
 
126
      frameExpected_i : in std_logic;
127
      frameRead_i : in RioFrame;
128
      frameReceived_o : out std_logic;
129
 
130
      readFrameEmpty_o : out std_logic;
131
      readFrame_i : in std_logic;
132
      readContent_i : in std_logic;
133
      readContentEnd_o : out std_logic;
134
      readContentData_o : out std_logic_vector(31 downto 0);
135
      writeFrameFull_o : out std_logic;
136
      writeFrame_i : in std_logic;
137
      writeFrameAbort_i : in std_logic;
138
      writeContent_i : in std_logic;
139
      writeContentData_i : in std_logic_vector(31 downto 0));
140
  end component;
141
 
142
  constant PORTS : natural := 7;
143
  constant SWITCH_IDENTITY : std_logic_vector(15 downto 0) := x"0123";
144
  constant SWITCH_VENDOR_IDENTITY : std_logic_vector(15 downto 0) := x"4567";
145
  constant SWITCH_REV : std_logic_vector(31 downto 0) := x"89abcdef";
146
  constant SWITCH_ASSY_IDENTITY : std_logic_vector(15 downto 0) := x"0011";
147
  constant SWITCH_ASSY_VENDOR_IDENTITY : std_logic_vector(15 downto 0) := x"2233";
148
  constant SWITCH_ASSY_REV : std_logic_vector(15 downto 0) := x"4455";
149
 
150
  signal clk : std_logic;
151
  signal areset_n : std_logic;
152
 
153
  signal frameValid : Array1(PORTS-1 downto 0);
154
  signal frameWrite : RioFrameArray(PORTS-1 downto 0);
155
  signal frameComplete : Array1(PORTS-1 downto 0);
156
 
157
  signal frameExpected : Array1(PORTS-1 downto 0);
158
  signal frameRead : RioFrameArray(PORTS-1 downto 0);
159
  signal frameReceived : Array1(PORTS-1 downto 0);
160
 
161
  signal writeFrameFull : Array1(PORTS-1 downto 0);
162
  signal writeFrame : Array1(PORTS-1 downto 0);
163
  signal writeFrameAbort : Array1(PORTS-1 downto 0);
164
  signal writeContent : Array1(PORTS-1 downto 0);
165
  signal writeContentData : Array32(PORTS-1 downto 0);
166
 
167
  signal readFrameEmpty : Array1(PORTS-1 downto 0);
168
  signal readFrame : Array1(PORTS-1 downto 0);
169
  signal readContent : Array1(PORTS-1 downto 0);
170
  signal readContentEnd : Array1(PORTS-1 downto 0);
171
  signal readContentData : Array32(PORTS-1 downto 0);
172
 
173
  signal portLinkTimeout : std_logic_vector(23 downto 0);
174
 
175
  signal linkInitialized : Array1(PORTS-1 downto 0);
176
  signal outputPortEnable : Array1(PORTS-1 downto 0);
177
  signal inputPortEnable : Array1(PORTS-1 downto 0);
178
 
179
  signal localAckIdWrite : Array1(PORTS-1 downto 0);
180
  signal clrOutstandingAckId : Array1(PORTS-1 downto 0);
181
  signal inboundAckIdWrite : Array5(PORTS-1 downto 0);
182
  signal outstandingAckIdWrite : Array5(PORTS-1 downto 0);
183
  signal outboundAckIdWrite : Array5(PORTS-1 downto 0);
184
  signal inboundAckIdRead : Array5(PORTS-1 downto 0);
185
  signal outstandingAckIdRead : Array5(PORTS-1 downto 0);
186
  signal outboundAckIdRead : Array5(PORTS-1 downto 0);
187
 
188
  signal configStb, configStbExpected : std_logic;
189
  signal configWe, configWeExpected : std_logic;
190
  signal configAddr, configAddrExpected : std_logic_vector(23 downto 0);
191
  signal configDataWrite, configDataWriteExpected : std_logic_vector(31 downto 0);
192
  signal configDataRead, configDataReadExpected : std_logic_vector(31 downto 0);
193
 
194
begin
195
 
196
  -----------------------------------------------------------------------------
197
  -- Clock generation.
198
  -----------------------------------------------------------------------------
199
  ClockGenerator: process
200
  begin
201
    clk <= '0';
202
    wait for 20 ns;
203
    clk <= '1';
204
    wait for 20 ns;
205
  end process;
206
 
207
 
208
  -----------------------------------------------------------------------------
209
  -- Serial port emulator.
210
  -----------------------------------------------------------------------------
211
  TestDriver: process
212
 
213
    ---------------------------------------------------------------------------
214 28 magro732
    -- Place a new ingress frame on a port.
215 2 magro732
    ---------------------------------------------------------------------------
216
    procedure SendFrame(constant portIndex : natural range 0 to 7;
217
                        constant frame : RioFrame) is
218
    begin
219
      frameValid(portIndex) <= '1';
220
      frameWrite(portIndex) <= frame;
221
      wait until frameComplete(portIndex) = '1';
222
      frameValid(portIndex) <= '0';
223
    end procedure;
224
 
225 28 magro732
    procedure SendFrame(constant portIndex : natural range 0 to 7;
226
                        constant sourceId : std_logic_vector(15 downto 0);
227
                        constant destinationId : std_logic_vector(15 downto 0);
228
                        constant payload : RioPayload) is
229
      variable frame : RioFrame;
230
    begin
231
      frame := RioFrameCreate(ackId=>"00000", vc=>'0', crf=>'0', prio=>"00",
232
                              tt=>"01", ftype=>"0000",
233
                              sourceId=>sourceId, destId=>destinationId,
234
                              payload=>payload);
235
 
236
      frameValid(portIndex) <= '1';
237
      frameWrite(portIndex) <= frame;
238
    end procedure;
239
 
240 2 magro732
    ---------------------------------------------------------------------------
241 28 magro732
    -- Expect a new egress frame on a port.
242 2 magro732
    ---------------------------------------------------------------------------
243
    procedure ReceiveFrame(constant portIndex : natural range 0 to 7;
244
                           constant frame : RioFrame) is
245
    begin
246
      frameExpected(portIndex) <= '1';
247
      frameRead(portIndex) <= frame;
248
      wait until frameReceived(portIndex) = '1';
249
      frameExpected(portIndex) <= '0';
250
    end procedure;
251
 
252 28 magro732
    procedure ReceiveFrame(constant portIndex : natural range 0 to 7;
253
                           constant sourceId : std_logic_vector(15 downto 0);
254
                           constant destinationId : std_logic_vector(15 downto 0);
255
                           constant payload : RioPayload) is
256
      variable frame : RioFrame;
257
    begin
258
      frame := RioFrameCreate(ackId=>"00000", vc=>'0', crf=>'0', prio=>"00",
259
                              tt=>"01", ftype=>"0000",
260
                              sourceId=>sourceId, destId=>destinationId,
261
                              payload=>payload);
262
 
263
      frameExpected(portIndex) <= '1';
264
      frameRead(portIndex) <= frame;
265
    end procedure;
266
 
267 2 magro732
    ---------------------------------------------------------------------------
268 28 magro732
    -- Read a configuration-space register.
269 2 magro732
    ---------------------------------------------------------------------------
270
    procedure ReadConfig32(constant portIndex : natural range 0 to 7;
271
                           constant destinationId : std_logic_vector(15 downto 0);
272
                           constant sourceId : std_logic_vector(15 downto 0);
273
                           constant hop : std_logic_vector(7 downto 0);
274
                           constant tid : std_logic_vector(7 downto 0);
275
                           constant address : std_logic_vector(23 downto 0);
276
                           constant data : std_logic_vector(31 downto 0)) is
277
      variable maintData : DoubleWordArray(0 to 7);
278
    begin
279
      SendFrame(portIndex, RioFrameCreate(ackId=>"00000", vc=>'0', crf=>'0', prio=>"00",
280
                                          tt=>"01", ftype=>FTYPE_MAINTENANCE_CLASS,
281
                                          sourceId=>sourceId, destId=>destinationId,
282
                                          payload=>RioMaintenance(transaction=>"0000",
283
                                                                  size=>"1000",
284
                                                                  tid=>tid,
285
                                                                  hopCount=>hop,
286
                                                                  configOffset=>address(23 downto 3),
287
                                                                  wdptr=>address(2),
288
                                                                  dataLength=>0,
289
                                                                  data=>maintData)));
290
      if (address(2) = '0') then
291
        maintData(0) := data & x"00000000";
292
      else
293
        maintData(0) := x"00000000" & data ;
294
      end if;
295
 
296
      ReceiveFrame(portIndex, RioFrameCreate(ackId=>"00000", vc=>'0', crf=>'0', prio=>"00",
297
                                             tt=>"01", ftype=>FTYPE_MAINTENANCE_CLASS,
298
                                             sourceId=>destinationId, destId=>sourceId,
299
                                             payload=>RioMaintenance(transaction=>"0010",
300
                                                                     size=>"0000",
301
                                                                     tid=>tid,
302
                                                                     hopCount=>x"ff",
303
                                                                     configOffset=>"000000000000000000000",
304
                                                                     wdptr=>'0',
305
                                                                     dataLength=>1,
306
                                                                     data=>maintData)));
307
    end procedure;
308
 
309
    ---------------------------------------------------------------------------
310 28 magro732
    -- Write a configuration-space register.
311 2 magro732
    ---------------------------------------------------------------------------
312
    procedure WriteConfig32(constant portIndex : natural range 0 to 7;
313
                            constant destinationId : std_logic_vector(15 downto 0);
314
                            constant sourceId : std_logic_vector(15 downto 0);
315
                            constant hop : std_logic_vector(7 downto 0);
316
                            constant tid : std_logic_vector(7 downto 0);
317
                            constant address : std_logic_vector(23 downto 0);
318
                            constant data : std_logic_vector(31 downto 0)) is
319
      variable maintData : DoubleWordArray(0 to 7);
320
    begin
321
      if (address(2) = '0') then
322
        maintData(0) := data & x"00000000";
323
      else
324
        maintData(0) := x"00000000" & data ;
325
      end if;
326
 
327
      SendFrame(portIndex, RioFrameCreate(ackId=>"00000", vc=>'0', crf=>'0', prio=>"00",
328
                                          tt=>"01", ftype=>FTYPE_MAINTENANCE_CLASS,
329
                                          sourceId=>sourceId, destId=>destinationId,
330
                                          payload=>RioMaintenance(transaction=>"0001",
331
                                                                  size=>"1000",
332
                                                                  tid=>tid,
333
                                                                  hopCount=>hop,
334
                                                                  configOffset=>address(23 downto 3),
335
                                                                  wdptr=>address(2),
336
                                                                  dataLength=>1,
337
                                                                  data=>maintData)));
338
 
339
      ReceiveFrame(portIndex, RioFrameCreate(ackId=>"00000", vc=>'0', crf=>'0', prio=>"00",
340
                                             tt=>"01", ftype=>FTYPE_MAINTENANCE_CLASS,
341
                                             sourceId=>destinationId, destId=>sourceId,
342
                                             payload=>RioMaintenance(transaction=>"0011",
343
                                                                     size=>"0000",
344
                                                                     tid=>tid,
345
                                                                     hopCount=>x"ff",
346
                                                                     configOffset=>"000000000000000000000",
347
                                                                     wdptr=>'0',
348
                                                                     dataLength=>0,
349
                                                                     data=>maintData)));
350
    end procedure;
351
 
352
    ---------------------------------------------------------------------------
353 28 magro732
    -- Set a route table entry.
354 2 magro732
    ---------------------------------------------------------------------------
355 28 magro732
    procedure RouteSet(constant deviceId : std_logic_vector(15 downto 0);
356
                       constant portIndex : std_logic_vector(7 downto 0)) is
357
      variable frame : RioFrame;
358
    begin
359
      WriteConfig32(portIndex=>0, destinationId=>x"ffff", sourceId=>x"ffff", hop=>x"00",
360
                    tid=>x"de", address=>x"000070", data=>(x"0000" & deviceId));
361
      WriteConfig32(portIndex=>0, destinationId=>x"ffff", sourceId=>x"ffff", hop=>x"00",
362
                    tid=>x"ad", address=>x"000074", data=>(x"000000" & portIndex));
363
    end procedure;
364
 
365
    ---------------------------------------------------------------------------
366
    -- Set the default route table entry.
367
    ---------------------------------------------------------------------------
368
    procedure RouteSetDefault(constant portIndex : std_logic_vector(7 downto 0)) is
369
      variable frame : RioFrame;
370
    begin
371
      WriteConfig32(portIndex=>0, destinationId=>x"ffff", sourceId=>x"ffff", hop=>x"00",
372
                    tid=>x"ad", address=>x"000078", data=>(x"000000" & portIndex));
373
    end procedure;
374
 
375
    ---------------------------------------------------------------------------
376
    -- Send a frame on an ingress port and expect it at an egress port.
377
    ---------------------------------------------------------------------------
378 2 magro732
    procedure RouteFrame(constant sourcePortIndex : natural range 0 to 7;
379
                         constant destinationPortIndex : natural range 0 to 7;
380
                         constant sourceId : std_logic_vector(15 downto 0);
381
                         constant destinationId : std_logic_vector(15 downto 0);
382
                         constant payload : RioPayload) is
383
      variable frame : RioFrame;
384
    begin
385
      frame := RioFrameCreate(ackId=>"00000", vc=>'0', crf=>'0', prio=>"00",
386
                              tt=>"01", ftype=>"0000",
387
                              sourceId=>sourceId, destId=>destinationId,
388
                              payload=>payload);
389
 
390
      frameExpected(destinationPortIndex) <= '1';
391
      frameRead(destinationPortIndex) <= frame;
392
 
393
      frameValid(sourcePortIndex) <= '1';
394
      frameWrite(sourcePortIndex) <= frame;
395
      wait until frameComplete(sourcePortIndex) = '1';
396
      frameValid(sourcePortIndex) <= '0';
397
 
398
      wait until frameReceived(destinationPortIndex) = '1';
399
      frameExpected(destinationPortIndex) <= '0';
400
 
401
    end procedure;
402 28 magro732
 
403 2 magro732
    ---------------------------------------------------------------------------
404 28 magro732
    -- Variable definitions.
405 2 magro732
    ---------------------------------------------------------------------------
406
 
407
    -- These variabels are needed for the random number generation.
408
    variable seed1 : positive := 1;
409
    variable seed2: positive := 1;
410
 
411
    variable data : DoubleWordArray(0 to 31);
412
    variable randomPayload : RioPayload;
413
    variable randomPayload1 : RioPayload;
414
    variable randomPayload2 : RioPayload;
415
    variable frame : RioFrameArray(0 to PORTS-1);
416
 
417
  begin
418
    areset_n <= '0';
419
 
420
    linkInitialized <= (others=>'0');
421
 
422
    for portIndex in 0 to PORTS-1 loop
423
      frameValid(portIndex) <= '0';
424
      frameExpected(portIndex) <= '0';
425
      localAckIdWrite(portIndex) <= '0';
426
      clrOutstandingAckId(portIndex) <= '0';
427
      inboundAckIdWrite(portIndex) <= (others=>'0');
428
      outstandingAckIdWrite(portIndex) <= (others=>'0');
429
      outboundAckIdWrite(portIndex) <= (others=>'0');
430
    end loop;
431
 
432
    wait until clk'event and clk = '1';
433
    wait until clk'event and clk = '1';
434
    areset_n <= '1';
435
    wait until clk'event and clk = '1';
436
    wait until clk'event and clk = '1';
437
 
438
    ---------------------------------------------------------------------------
439
    PrintS("-----------------------------------------------------------------");
440
    PrintS("TG_RioSwitch");
441
    PrintS("-----------------------------------------------------------------");
442
    PrintS("TG_RioSwitch-TC1");
443
    PrintS("Description: Test switch maintenance accesses on different ports.");
444
    PrintS("Requirement: XXXXX");
445
    PrintS("-----------------------------------------------------------------");
446
    PrintS("Step 1:");
447
    PrintS("Action: Send maintenance read request packets to read switch identity.");
448
    PrintS("Result: The switch should answer with its configured identitiy.");
449
    ---------------------------------------------------------------------------
450
    PrintR("TG_RioSwitch-TC1-Step1");
451
    ---------------------------------------------------------------------------
452
 
453
    ReadConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
454
                 tid=>x"00", address=>x"000000", data=>(SWITCH_IDENTITY & SWITCH_VENDOR_IDENTITY));
455
    ReadConfig32(portIndex=>1, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
456
                 tid=>x"01", address=>x"000004", data=>SWITCH_REV);
457
    ReadConfig32(portIndex=>2, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
458
                 tid=>x"02", address=>x"000008", data=>(SWITCH_ASSY_IDENTITY & SWITCH_ASSY_VENDOR_IDENTITY));
459
    ReadConfig32(portIndex=>3, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
460
                 tid=>x"03", address=>x"00000c", data=>(SWITCH_ASSY_REV & x"0100"));
461
 
462
    ---------------------------------------------------------------------------
463
    PrintS("-----------------------------------------------------------------");
464
    PrintS("Step 2:");
465
    PrintS("Action: Check the switch Processing Element Features.");
466
    PrintS("Result: The expected switch features should be returned. ");
467
    PrintS("        Switch with extended features pointer valid. Common ");
468
    PrintS("        transport large system support and standard route table ");
469
    PrintS("        configuration support.");
470
    ---------------------------------------------------------------------------
471
    PrintR("TG_RioSwitch-TC1-Step2");
472
    ---------------------------------------------------------------------------
473
 
474
    ReadConfig32(portIndex=>4, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
475
                 tid=>x"04", address=>x"000010", data=>x"10000118");
476
 
477
    ---------------------------------------------------------------------------
478
    PrintS("-----------------------------------------------------------------");
479
    PrintS("Step 3:");
480
    PrintS("Action: Check the switch port information.");
481
    PrintS("Result: The expected port and number of ports should be returned.");
482
    ---------------------------------------------------------------------------
483
    PrintR("TG_RioSwitch-TC1-Step3");
484
    ---------------------------------------------------------------------------
485
 
486
    ReadConfig32(portIndex=>5, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
487
                 tid=>x"05", address=>x"000014", data=>x"00000705");
488
 
489
    ---------------------------------------------------------------------------
490
    PrintS("-----------------------------------------------------------------");
491
    PrintS("Step 4:");
492
    PrintS("Action: Check the switch number of supported routes.");
493
    PrintS("Result: The expected number of supported routes should be returned.");
494
    ---------------------------------------------------------------------------
495
    PrintR("TG_RioSwitch-TC1-Step4");
496
    ---------------------------------------------------------------------------
497
 
498
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
499
                 tid=>x"06", address=>x"000034", data=>x"00000800");
500
 
501
    ---------------------------------------------------------------------------
502
    PrintS("-----------------------------------------------------------------");
503
    PrintS("Step 5:");
504
    PrintS("Action: Test host base device id lock by reading it, then hold it ");
505
    PrintS("        and try to grab it from another address.");
506
    PrintS("Result: The value should follow the specification.");
507
    ---------------------------------------------------------------------------
508
    PrintR("TG_RioSwitch-TC1-Step5");
509
    ---------------------------------------------------------------------------
510
 
511
    -- Check that the lock is released.
512
    ReadConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
513
                 tid=>x"00", address=>x"000068", data=>x"0000ffff");
514
 
515
    -- Try to accuire the lock.
516
    WriteConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
517
                  tid=>x"00", address=>x"000068", data=>x"00000002");
518
 
519
    -- Check that the lock has been accuired.
520
    ReadConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
521
                 tid=>x"00", address=>x"000068", data=>x"00000002");
522
 
523
    -- Try to accuire the lock from another source.
524
    WriteConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
525
                  tid=>x"00", address=>x"000068", data=>x"00000003");
526
 
527
    -- Check that the lock refuses the new access.
528
    ReadConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
529
                 tid=>x"00", address=>x"000068", data=>x"00000002");
530
 
531
    -- Release the lock.
532
    WriteConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
533
                  tid=>x"00", address=>x"000068", data=>x"00000002");
534
 
535
    -- Check that the lock is released.
536
    ReadConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
537
                 tid=>x"00", address=>x"000068", data=>x"0000ffff");
538
 
539
    -- Check that the lock can be accuired from another source once unlocked.
540
    WriteConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
541
                  tid=>x"00", address=>x"000068", data=>x"00000003");
542
 
543
    -- Check that the lock is released.
544
    ReadConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
545
                 tid=>x"00", address=>x"000068", data=>x"00000003");
546
 
547
    -- Release the lock again.
548
    WriteConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
549
                  tid=>x"00", address=>x"000068", data=>x"00000003");
550
 
551
    -- Check that the lock is released.
552
    ReadConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
553
                 tid=>x"00", address=>x"000068", data=>x"0000ffff");
554
 
555
    ---------------------------------------------------------------------------
556
    PrintS("-----------------------------------------------------------------");
557
    PrintS("Step 6");
558
    PrintS("Action: Check the component tag register.");
559
    PrintS("Result: The written value in the component tag should be saved.");
560
    ---------------------------------------------------------------------------
561
    PrintR("TG_RioSwitch-TC1-Step6");
562
    ---------------------------------------------------------------------------
563
 
564
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
565
                 tid=>x"06", address=>x"00006c", data=>x"00000000");
566
 
567
    WriteConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
568
                  tid=>x"06", address=>x"00006c", data=>x"ffffffff");
569
 
570
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
571
                 tid=>x"06", address=>x"00006c", data=>x"ffffffff");
572
 
573
    ---------------------------------------------------------------------------
574
    PrintS("-----------------------------------------------------------------");
575
    PrintS("Step 7");
576
    PrintS("Action: Read and write to the port link timeout.");
577
    PrintS("Result: Check that the portLinkTimeout output from the switch changes.");
578
    ---------------------------------------------------------------------------
579
    PrintR("TG_RioSwitch-TC1-Step7");
580
    ---------------------------------------------------------------------------
581
 
582
    assert portLinkTimeout = x"ffffff" report "Unexpected portLinkTimeout." severity error;
583
 
584
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
585
                 tid=>x"06", address=>x"000120", data=>x"ffffff00");
586
 
587
    WriteConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
588
                  tid=>x"06", address=>x"000120", data=>x"00000100");
589
 
590
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
591
                 tid=>x"06", address=>x"000120", data=>x"00000100");
592
 
593
    assert portLinkTimeout = x"000001" report "Unexpected portLinkTimeout." severity error;
594
 
595
    ---------------------------------------------------------------------------
596
    PrintS("-----------------------------------------------------------------");
597
    PrintS("Step 8");
598
    PrintS("Action: Read from the port general control.");
599
    PrintS("Result: Check the discovered bit.");
600
    ---------------------------------------------------------------------------
601
    PrintR("TG_RioSwitch-TC1-Step8");
602
    ---------------------------------------------------------------------------
603
 
604
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
605
                 tid=>x"06", address=>x"00013c", data=>x"00000000");
606
 
607
    WriteConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
608
                  tid=>x"06", address=>x"00013c", data=>x"20000000");
609
 
610
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
611
                 tid=>x"06", address=>x"00013c", data=>x"20000000");
612
 
613
    WriteConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
614
                  tid=>x"06", address=>x"00013c", data=>x"00000000");
615
 
616
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
617
                 tid=>x"06", address=>x"00013c", data=>x"00000000");
618
 
619
    ---------------------------------------------------------------------------
620
    PrintS("-----------------------------------------------------------------");
621
    PrintS("Step 9");
622
    PrintS("Action: Read from the port N error and status.");
623
    PrintS("Result: Check the port ok and port uninitialized bits.");
624
    ---------------------------------------------------------------------------
625
    PrintR("TG_RioSwitch-TC1-Step9");
626
    ---------------------------------------------------------------------------
627
 
628
    linkInitialized(0) <= '0';
629
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
630
                 tid=>x"06", address=>x"000158", data=>x"00000001");
631
    linkInitialized(0) <= '1';
632
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
633
                 tid=>x"06", address=>x"000158", data=>x"00000002");
634
 
635
    linkInitialized(1) <= '0';
636
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
637
                 tid=>x"06", address=>x"000178", data=>x"00000001");
638
    linkInitialized(1) <= '1';
639
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
640
                 tid=>x"06", address=>x"000178", data=>x"00000002");
641
 
642
    linkInitialized(2) <= '0';
643
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
644
                 tid=>x"06", address=>x"000198", data=>x"00000001");
645
    linkInitialized(2) <= '1';
646
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
647
                 tid=>x"06", address=>x"000198", data=>x"00000002");
648
 
649
    linkInitialized(3) <= '0';
650
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
651
                 tid=>x"06", address=>x"0001b8", data=>x"00000001");
652
    linkInitialized(3) <= '1';
653
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
654
                 tid=>x"06", address=>x"0001b8", data=>x"00000002");
655
 
656
    linkInitialized(4) <= '0';
657
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
658
                 tid=>x"06", address=>x"0001d8", data=>x"00000001");
659
    linkInitialized(4) <= '1';
660
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
661
                 tid=>x"06", address=>x"0001d8", data=>x"00000002");
662
 
663
    linkInitialized(5) <= '0';
664
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
665
                 tid=>x"06", address=>x"0001f8", data=>x"00000001");
666
    linkInitialized(5) <= '1';
667
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
668
                 tid=>x"06", address=>x"0001f8", data=>x"00000002");
669
 
670
    linkInitialized(6) <= '0';
671
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
672
                 tid=>x"06", address=>x"000218", data=>x"00000001");
673
    linkInitialized(6) <= '1';
674
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
675
                 tid=>x"06", address=>x"000218", data=>x"00000002");
676
 
677
    ---------------------------------------------------------------------------
678
    PrintS("-----------------------------------------------------------------");
679
    PrintS("Step 10");
680
    PrintS("Action: Read and write to/from the port N control.");
681
    PrintS("Result: Check the output/input port enable.");
682
    ---------------------------------------------------------------------------
683
    PrintR("TG_RioSwitch-TC1-Step10");
684
    ---------------------------------------------------------------------------
685
 
686
    assert outputPortEnable(0) = '0' report "Unexpected outputPortEnable." severity error;
687
    assert inputPortEnable(0) = '0' report "Unexpected inputPortEnable." severity error;
688
 
689
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
690
                 tid=>x"06", address=>x"00015c", data=>x"00000001");
691
 
692
    WriteConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
693
                  tid=>x"06", address=>x"00015c", data=>x"00600001");
694
 
695
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
696
                 tid=>x"06", address=>x"00015c", data=>x"00600001");
697
 
698
    assert outputPortEnable(0) = '1' report "Unexpected outputPortEnable." severity error;
699
    assert inputPortEnable(0) = '1' report "Unexpected inputPortEnable." severity error;
700
 
701
    ---------------------------------------------------------------------------
702
 
703
    assert outputPortEnable(1) = '0' report "Unexpected outputPortEnable." severity error;
704
    assert inputPortEnable(1) = '0' report "Unexpected inputPortEnable." severity error;
705
 
706
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
707
                 tid=>x"06", address=>x"00017c", data=>x"00000001");
708
 
709
    WriteConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
710
                  tid=>x"06", address=>x"00017c", data=>x"00600001");
711
 
712
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
713
                 tid=>x"06", address=>x"00017c", data=>x"00600001");
714
 
715
    assert outputPortEnable(1) = '1' report "Unexpected outputPortEnable." severity error;
716
    assert inputPortEnable(1) = '1' report "Unexpected inputPortEnable." severity error;
717
 
718
    ---------------------------------------------------------------------------
719
 
720
    assert outputPortEnable(2) = '0' report "Unexpected outputPortEnable." severity error;
721
    assert inputPortEnable(2) = '0' report "Unexpected inputPortEnable." severity error;
722
 
723
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
724
                 tid=>x"06", address=>x"00019c", data=>x"00000001");
725
 
726
    WriteConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
727
                  tid=>x"06", address=>x"00019c", data=>x"00600001");
728
 
729
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
730
                 tid=>x"06", address=>x"00019c", data=>x"00600001");
731
 
732
    assert outputPortEnable(2) = '1' report "Unexpected outputPortEnable." severity error;
733
    assert inputPortEnable(2) = '1' report "Unexpected inputPortEnable." severity error;
734
 
735
    ---------------------------------------------------------------------------
736
 
737
    assert outputPortEnable(3) = '0' report "Unexpected outputPortEnable." severity error;
738
    assert inputPortEnable(3) = '0' report "Unexpected inputPortEnable." severity error;
739
 
740
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
741
                 tid=>x"06", address=>x"0001bc", data=>x"00000001");
742
 
743
    WriteConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
744
                  tid=>x"06", address=>x"0001bc", data=>x"00600001");
745
 
746
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
747
                 tid=>x"06", address=>x"0001bc", data=>x"00600001");
748
 
749
    assert outputPortEnable(3) = '1' report "Unexpected outputPortEnable." severity error;
750
    assert inputPortEnable(3) = '1' report "Unexpected inputPortEnable." severity error;
751
 
752
    ---------------------------------------------------------------------------
753
 
754
    assert outputPortEnable(4) = '0' report "Unexpected outputPortEnable." severity error;
755
    assert inputPortEnable(4) = '0' report "Unexpected inputPortEnable." severity error;
756
 
757
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
758
                 tid=>x"06", address=>x"0001dc", data=>x"00000001");
759
 
760
    WriteConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
761
                  tid=>x"06", address=>x"0001dc", data=>x"00600001");
762
 
763
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
764
                 tid=>x"06", address=>x"0001dc", data=>x"00600001");
765
 
766
    assert outputPortEnable(4) = '1' report "Unexpected outputPortEnable." severity error;
767
    assert inputPortEnable(4) = '1' report "Unexpected inputPortEnable." severity error;
768
 
769
    ---------------------------------------------------------------------------
770
 
771
    assert outputPortEnable(5) = '0' report "Unexpected outputPortEnable." severity error;
772
    assert inputPortEnable(5) = '0' report "Unexpected inputPortEnable." severity error;
773
 
774
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
775
                 tid=>x"06", address=>x"0001fc", data=>x"00000001");
776
 
777
    WriteConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
778
                  tid=>x"06", address=>x"0001fc", data=>x"00600001");
779
 
780
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
781
                 tid=>x"06", address=>x"0001fc", data=>x"00600001");
782
 
783
    assert outputPortEnable(5) = '1' report "Unexpected outputPortEnable." severity error;
784
    assert inputPortEnable(5) = '1' report "Unexpected inputPortEnable." severity error;
785
 
786
    ---------------------------------------------------------------------------
787
 
788
    assert outputPortEnable(6) = '0' report "Unexpected outputPortEnable." severity error;
789
    assert inputPortEnable(6) = '0' report "Unexpected inputPortEnable." severity error;
790
 
791
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
792
                 tid=>x"06", address=>x"00021c", data=>x"00000001");
793
 
794
    WriteConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
795
                  tid=>x"06", address=>x"00021c", data=>x"00600001");
796
 
797
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
798
                 tid=>x"06", address=>x"00021c", data=>x"00600001");
799
 
800
    assert outputPortEnable(6) = '1' report "Unexpected outputPortEnable." severity error;
801
    assert inputPortEnable(6) = '1' report "Unexpected inputPortEnable." severity error;
802
 
803
    ---------------------------------------------------------------------------
804
    PrintS("-----------------------------------------------------------------");
805
    PrintS("Step 11");
806
    PrintS("Action: Read and write to/from the implementation defined space.");
807
    PrintS("Result: Check the accesses on the external configuration port.");
808
    ---------------------------------------------------------------------------
809
    PrintR("TG_RioSwitch-TC1-Step11");
810
    ---------------------------------------------------------------------------
811
 
812
    configStbExpected <= '1';
813
    configWeExpected <= '0';
814
    configAddrExpected <= x"010000";
815
    configDataReadExpected <= x"deadbeef";
816
 
817
    ReadConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
818
                 tid=>x"06", address=>x"010000", data=>x"deadbeef");
819
 
820
    configStbExpected <= '1';
821
    configWeExpected <= '1';
822
    configAddrExpected <= x"010004";
823
    configDataWriteExpected <= x"c0debabe";
824
 
825
    WriteConfig32(portIndex=>6, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
826
                  tid=>x"06", address=>x"010004", data=>x"c0debabe");
827
 
828
    ---------------------------------------------------------------------------
829
    PrintS("-----------------------------------------------------------------");
830
    PrintS("TG_RioSwitch-TC2");
831
    PrintS("Description: Test the configuration of the routing table and the ");
832
    PrintS("             routing of packets.");
833
    PrintS("Requirement: XXXXX");
834
    PrintS("-----------------------------------------------------------------");
835
    PrintS("Step 1:");
836
    PrintS("Action: Configure the routing table for address 0->port 1.");
837
    PrintS("Result: A packet to address 0 should be forwarded to port 1.");
838
    ---------------------------------------------------------------------------
839
    PrintR("TG_RioSwitch-TC2-Step1");
840
    ---------------------------------------------------------------------------
841
 
842
    ReadConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
843
                 tid=>x"07", address=>x"000070", data=>x"00000000");
844
    WriteConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
845
                  tid=>x"08", address=>x"000074", data=>x"00000001");
846
    ReadConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
847
                 tid=>x"09", address=>x"000074", data=>x"00000001");
848
 
849
    -- Send a frame from a port and check if it is correctly routed.
850
    randomPayload.length := 3;
851
    CreateRandomPayload(randomPayload.data, seed1, seed2);
852
    RouteFrame(sourcePortIndex=>0, destinationPortIndex=>1,
853
               sourceId=>x"ffff", destinationId=>x"0000", payload=>randomPayload);
854
 
855
    ---------------------------------------------------------------------------
856
    PrintS("-----------------------------------------------------------------");
857
    PrintS("Step 2:");
858
    PrintS("Action: Test the configuration of the default route->port 6.");
859
    PrintS("Result: An unknown address should be routed to port 6.");
860
    ---------------------------------------------------------------------------
861
    PrintR("TG_RioSwitch-TC2-Step2");
862
    ---------------------------------------------------------------------------
863
 
864
    ReadConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
865
                 tid=>x"0a", address=>x"000078", data=>x"00000000");
866
    WriteConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
867
                  tid=>x"0b", address=>x"000078", data=>x"00000006");
868
    ReadConfig32(portIndex=>0, destinationId=>x"0000", sourceId=>x"0002", hop=>x"00",
869
                 tid=>x"0c", address=>x"000078", data=>x"00000006");
870
 
871
    -- Send a frame from a port and check if it is correctly routed.
872
    randomPayload.length := 4;
873
    CreateRandomPayload(randomPayload.data, seed1, seed2);
874
    RouteFrame(sourcePortIndex=>1, destinationPortIndex=>6,
875
               sourceId=>x"0000", destinationId=>x"ffff", payload=>randomPayload);
876
 
877
    ---------------------------------------------------------------------------
878
    PrintS("-----------------------------------------------------------------");
879
    PrintS("TG_RioSwitch-TC3");
880
    PrintS("Description: Test the routing of normal packets.");
881
    PrintS("Requirement: XXXXX");
882
    PrintS("-----------------------------------------------------------------");
883
    PrintS("Step 1:");
884 28 magro732
    PrintS("Action: Send two packets but not at the same time.");
885 2 magro732
    PrintS("Result: Both packets should be received at the expected ports.");
886
    ---------------------------------------------------------------------------
887
    PrintR("TG_RioSwitch-TC3-Step1");
888
    ---------------------------------------------------------------------------
889
 
890 28 magro732
    -- Setup the routing table for the following steps.
891
    RouteSet(x"0000", x"00");
892
    RouteSet(x"0001", x"00");
893
    RouteSet(x"0002", x"00");
894
    RouteSet(x"0003", x"00");
895
    RouteSet(x"0004", x"01");
896
    RouteSet(x"0005", x"02");
897
    RouteSet(x"0006", x"03");
898
    RouteSetDefault(x"06");
899
 
900 2 magro732
    -- Frame on port 0 to port 1.
901
    randomPayload.length := 3;
902
    CreateRandomPayload(randomPayload.data, seed1, seed2);
903
    SendFrame(portIndex=>0,
904 28 magro732
              sourceId=>x"ffff", destinationId=>x"0004", payload=>randomPayload);
905 2 magro732
    ReceiveFrame(portIndex=>1,
906 28 magro732
                 sourceId=>x"ffff", destinationId=>x"0004", payload=>randomPayload);
907 2 magro732
 
908
    -- Frame on port 1 to port 6.
909
    randomPayload.length := 4;
910
    CreateRandomPayload(randomPayload.data, seed1, seed2);
911
    SendFrame(portIndex=>1,
912
              sourceId=>x"0000", destinationId=>x"ffff", payload=>randomPayload);
913
    ReceiveFrame(portIndex=>6,
914
                 sourceId=>x"0000", destinationId=>x"ffff", payload=>randomPayload);
915
 
916
    wait until frameComplete(1) = '1';
917
    frameValid(1) <= '0';
918
    wait until frameReceived(6) = '1';
919
    frameExpected(6) <= '0';
920
 
921
    wait until frameComplete(0) = '1';
922
    frameValid(0) <= '0';
923
    wait until frameReceived(1) = '1';
924
    frameExpected(1) <= '0';
925
 
926
    ---------------------------------------------------------------------------
927
    PrintS("-----------------------------------------------------------------");
928
    PrintS("Step 2:");
929 28 magro732
    PrintS("Action: Send two packets to the same port that is full and one to");
930 2 magro732
    PrintS("        another that is also full. Then receive the packets one at");
931
    PrintS("        a time.");
932
    PrintS("Result: The packet to the port that is ready should go though.");
933
    ---------------------------------------------------------------------------
934
    PrintR("TG_RioSwitch-TC3-Step2");
935
    ---------------------------------------------------------------------------
936
 
937
    -- Frame on port 0 to port 1.
938
    randomPayload.length := 5;
939
    CreateRandomPayload(randomPayload.data, seed1, seed2);
940
    SendFrame(portIndex=>0,
941 28 magro732
              sourceId=>x"ffff", destinationId=>x"0004", payload=>randomPayload);
942 2 magro732
 
943 28 magro732
    -- Frame on port 1 to port 2.
944 2 magro732
    randomPayload1.length := 6;
945
    CreateRandomPayload(randomPayload1.data, seed1, seed2);
946
    SendFrame(portIndex=>1,
947 28 magro732
              sourceId=>x"0000", destinationId=>x"0005", payload=>randomPayload1);
948 2 magro732
 
949 28 magro732
    -- Frame on port 2 to port 2.
950 2 magro732
    randomPayload2.length := 7;
951
    CreateRandomPayload(randomPayload2.data, seed1, seed2);
952
    SendFrame(portIndex=>2,
953 28 magro732
              sourceId=>x"0000", destinationId=>x"0005", payload=>randomPayload2);
954 2 magro732
 
955
    wait for 10 us;
956
 
957
    ReceiveFrame(portIndex=>1,
958 28 magro732
                 sourceId=>x"ffff", destinationId=>x"0004", payload=>randomPayload);
959 2 magro732
    wait until frameComplete(0) = '1';
960
    frameValid(0) <= '0';
961
    wait until frameReceived(1) = '1';
962
    frameExpected(1) <= '0';
963
 
964
    wait for 10 us;
965
 
966 28 magro732
    ReceiveFrame(portIndex=>2,
967
                 sourceId=>x"0000", destinationId=>x"0005", payload=>randomPayload1);
968 2 magro732
    wait until frameComplete(1) = '1';
969
    frameValid(1) <= '0';
970 28 magro732
    wait until frameReceived(2) = '1';
971
    frameExpected(2) <= '0';
972 2 magro732
 
973
    wait for 10 us;
974
 
975 28 magro732
    ReceiveFrame(portIndex=>2,
976
                 sourceId=>x"0000", destinationId=>x"0005", payload=>randomPayload2);
977 2 magro732
    wait until frameComplete(2) = '1';
978
    frameValid(2) <= '0';
979 28 magro732
    wait until frameReceived(2) = '1';
980
    frameExpected(2) <= '0';
981 2 magro732
 
982
    ---------------------------------------------------------------------------
983
    -- Test completed.
984
    ---------------------------------------------------------------------------
985
 
986
    wait for 10 us;
987
 
988 28 magro732
    assert readFrameEmpty = "1111111"
989 2 magro732
      report "Pending frames exist." severity error;
990
 
991
    TestEnd;
992
  end process;
993
 
994
  -----------------------------------------------------------------------------
995
  -- Instantiate a process receiving the configuration accesses to the
996
  -- implementation defined space.
997
  -----------------------------------------------------------------------------
998
  process
999
  begin
1000
    loop
1001
      wait until configStb = '1' and clk'event and clk = '1';
1002
      assert configStb = configStbExpected report "Unexpected configStb." severity error;
1003
      assert configWe = configWeExpected report "Unexpected configWe." severity error;
1004
      assert configAddr = configAddrExpected report "Unexpected configAddr." severity error;
1005
      if (configWe = '1') then
1006
        assert configDataWrite = configDataWriteExpected report "Unexpected configDataWrite." severity error;
1007
      else
1008
        configDataRead <= configDataReadExpected;
1009
      end if;
1010
    end loop;
1011
  end process;
1012
 
1013
  -----------------------------------------------------------------------------
1014
  -- Instantiate the test port array.
1015
  -----------------------------------------------------------------------------
1016
 
1017
  TestPortGeneration: for portIndex in 0 to PORTS-1 generate
1018
    TestPortInst: TestPort
1019
      port map(
1020
        clk=>clk, areset_n=>areset_n,
1021
        frameValid_i=>frameValid(portIndex),
1022
        frameWrite_i=>frameWrite(portIndex),
1023
        frameComplete_o=>frameComplete(portIndex),
1024
        frameExpected_i=>frameExpected(portIndex),
1025
        frameRead_i=>frameRead(portIndex),
1026
        frameReceived_o=>frameReceived(portIndex),
1027
        readFrameEmpty_o=>readFrameEmpty(portIndex),
1028
        readFrame_i=>readFrame(portIndex),
1029
        readContent_i=>readContent(portIndex),
1030
        readContentEnd_o=>readContentEnd(portIndex),
1031
        readContentData_o=>readContentData(portIndex),
1032
        writeFrameFull_o=>writeFrameFull(portIndex),
1033
        writeFrame_i=>writeFrame(portIndex),
1034
        writeFrameAbort_i=>writeFrameAbort(portIndex),
1035
        writeContent_i=>writeContent(portIndex),
1036
        writeContentData_i=>writeContentData(portIndex));
1037
  end generate;
1038
 
1039
  -----------------------------------------------------------------------------
1040
  -- Instantiate the switch.
1041
  -----------------------------------------------------------------------------
1042
 
1043
  TestSwitch: RioSwitch
1044
    generic map(
1045
      SWITCH_PORTS=>7,
1046
      DEVICE_IDENTITY=>SWITCH_IDENTITY,
1047
      DEVICE_VENDOR_IDENTITY=>SWITCH_VENDOR_IDENTITY,
1048
      DEVICE_REV=>SWITCH_REV,
1049
      ASSY_IDENTITY=>SWITCH_ASSY_IDENTITY,
1050
      ASSY_VENDOR_IDENTITY=>SWITCH_ASSY_VENDOR_IDENTITY,
1051
      ASSY_REV=>SWITCH_ASSY_REV)
1052
    port map(
1053
      clk=>clk, areset_n=>areset_n,
1054
      writeFrameFull_i=>writeFrameFull,
1055 28 magro732
      writeFrame_o=>writeFrame,
1056
      writeFrameAbort_o=>writeFrameAbort,
1057
      writeContent_o=>writeContent,
1058
      writeContentData_o=>writeContentData,
1059 2 magro732
      readFrameEmpty_i=>readFrameEmpty,
1060 28 magro732
      readFrame_o=>readFrame,
1061
      readContent_o=>readContent,
1062
      readContentEnd_i=>readContentEnd,
1063 2 magro732
      readContentData_i=>readContentData,
1064
      portLinkTimeout_o=>portLinkTimeout,
1065
      linkInitialized_i=>linkInitialized,
1066 28 magro732
      outputPortEnable_o=>outputPortEnable,
1067
      inputPortEnable_o=>inputPortEnable,
1068 2 magro732
      localAckIdWrite_o=>localAckIdWrite,
1069
      clrOutstandingAckId_o=>clrOutstandingAckId,
1070
      inboundAckId_o=>inboundAckIdWrite,
1071
      outstandingAckId_o=>outstandingAckIdWrite,
1072
      outboundAckId_o=>outboundAckIdWrite,
1073
      inboundAckId_i=>inboundAckIdRead,
1074
      outstandingAckId_i=>outstandingAckIdRead,
1075
      outboundAckId_i=>outboundAckIdRead,
1076
      configStb_o=>configStb, configWe_o=>configWe, configAddr_o=>configAddr,
1077
      configData_o=>configDataWrite, configData_i=>configDataRead);
1078
 
1079
 
1080
end architecture;
1081
 
1082
 
1083
 
1084
-------------------------------------------------------------------------------
1085 28 magro732
-- Switch port test stub.
1086 2 magro732
-------------------------------------------------------------------------------
1087
library ieee;
1088
use ieee.std_logic_1164.all;
1089
use ieee.numeric_std.all;
1090
library std;
1091
use std.textio.all;
1092
use work.rio_common.all;
1093
 
1094
 
1095
-------------------------------------------------------------------------------
1096 28 magro732
-- Entity for TestPort.
1097 2 magro732
-------------------------------------------------------------------------------
1098
entity TestPort is
1099
  port(
1100
    clk : in std_logic;
1101
    areset_n : in std_logic;
1102
 
1103
    frameValid_i : in std_logic;
1104
    frameWrite_i : in RioFrame;
1105
    frameComplete_o : out std_logic;
1106
 
1107
    frameExpected_i : in std_logic;
1108
    frameRead_i : in RioFrame;
1109
    frameReceived_o : out std_logic;
1110
 
1111
    readFrameEmpty_o : out std_logic;
1112
    readFrame_i : in std_logic;
1113
    readContent_i : in std_logic;
1114
    readContentEnd_o : out std_logic;
1115
    readContentData_o : out std_logic_vector(31 downto 0);
1116
 
1117
    writeFrameFull_o : out std_logic;
1118
    writeFrame_i : in std_logic;
1119
    writeFrameAbort_i : in std_logic;
1120
    writeContent_i : in std_logic;
1121
    writeContentData_i : in std_logic_vector(31 downto 0));
1122
end entity;
1123
 
1124
 
1125
-------------------------------------------------------------------------------
1126 28 magro732
-- Architecture for TestPort.
1127 2 magro732
-------------------------------------------------------------------------------
1128
architecture TestPortImpl of TestPort is
1129
begin
1130
 
1131
  -----------------------------------------------------------------------------
1132 28 magro732
  -- Egress frame receiver.
1133 2 magro732
  -----------------------------------------------------------------------------
1134
  FrameReader: process
1135
    type StateType is (STATE_IDLE, STATE_WRITE);
1136
    variable state : StateType;
1137
    variable frameIndex : natural range 0 to 69;
1138
  begin
1139
    writeFrameFull_o <= '1';
1140
    frameReceived_o <= '0';
1141
    wait until areset_n = '1';
1142
 
1143
    state := STATE_IDLE;
1144
 
1145
    loop
1146
      wait until clk'event and clk = '1';
1147
 
1148
      case state is
1149
 
1150
        when STATE_IDLE =>
1151
          frameReceived_o <= '0';
1152
          if (frameExpected_i = '1') then
1153
            writeFrameFull_o <= '0';
1154
            state := STATE_WRITE;
1155
            frameIndex := 0;
1156
          else
1157
            writeFrameFull_o <= '1';
1158
          end if;
1159
          assert writeFrame_i = '0' report "Unexpected frame." severity error;
1160
          assert writeFrameAbort_i = '0' report "Unexpected frame abort." severity error;
1161
          assert writeContent_i = '0' report "Unexpected data." severity error;
1162
 
1163
        when STATE_WRITE =>
1164
          if (writeContent_i = '1') then
1165
            -- Writing content.
1166
            if (frameIndex < frameRead_i.length) then
1167
              assert writeContentData_i = frameRead_i.payload(frameIndex)
1168
                report "Unexpected frame content received:" &
1169
                " index=" & integer'image(frameIndex) &
1170
                " expected=" & integer'image(to_integer(unsigned(frameRead_i.payload(frameIndex)))) &
1171
                " got=" & integer'image(to_integer(unsigned(writeContentData_i)))
1172
                severity error;
1173
 
1174
              frameIndex := frameIndex + 1;
1175
            else
1176
              report "Unexpected frame content received:" &
1177
                " index=" & integer'image(frameIndex) &
1178
                " expected=" & integer'image(to_integer(unsigned(frameRead_i.payload(frameIndex)))) &
1179
                " got=" & integer'image(to_integer(unsigned(writeContentData_i)))
1180
                severity error;
1181
 
1182
              frameIndex := frameIndex + 1;
1183
            end if;
1184
          else
1185
            -- Not writing any content.
1186
          end if;
1187
 
1188
          if (writeFrame_i = '1') then
1189
            -- Writing a complete frame.
1190
            assert frameIndex = frameRead_i.length report "Unexpected frame length received." severity error;
1191
            state := STATE_IDLE;
1192
            frameReceived_o <= '1';
1193
            writeFrameFull_o <= '1';
1194
          else
1195
            -- Not writing any frame.
1196
          end if;
1197
 
1198
          if (writeFrameAbort_i = '1') then
1199
            -- The frame should be aborted.
1200
            frameIndex := 0;
1201
          else
1202
            -- Not aborting any frame.
1203
          end if;
1204
      end case;
1205
    end loop;
1206
  end process;
1207
 
1208
  -----------------------------------------------------------------------------
1209 28 magro732
  -- Ingress frame sender.
1210 2 magro732
  -----------------------------------------------------------------------------
1211
  FrameSender: process
1212
    type StateType is (STATE_IDLE, STATE_READ);
1213
    variable state : StateType;
1214
    variable frameIndex : natural range 0 to 69;
1215
  begin
1216
    readFrameEmpty_o <= '1';
1217
    readContentEnd_o <= '1';
1218
    readContentData_o <= (others => 'U');
1219
    frameComplete_o <= '0';
1220
    wait until areset_n = '1';
1221
 
1222
    state := STATE_IDLE;
1223
 
1224
    loop
1225
      wait until clk'event and clk = '1';
1226
 
1227
      case state is
1228
 
1229
        when STATE_IDLE =>
1230
          frameComplete_o <= '0';
1231
          if (frameValid_i = '1') then
1232
            state := STATE_READ;
1233
            frameIndex := 0;
1234
            readFrameEmpty_o <= '0';
1235
          end if;
1236
 
1237
        when STATE_READ =>
1238
          if (readContent_i = '1') then
1239
            if (frameIndex < frameWrite_i.length) then
1240
              readContentData_o <= frameWrite_i.payload(frameIndex);
1241
              readContentEnd_o <= '0';
1242
              frameIndex := frameIndex + 1;
1243
            elsif (frameIndex = frameWrite_i.length) then
1244
              readContentEnd_o <= '1';
1245
            else
1246
              report "Reading empty frame." severity error;
1247
            end if;
1248
          else
1249
            -- Not reading data.
1250
          end if;
1251
 
1252
          if (readFrame_i = '1') then
1253
            state := STATE_IDLE;
1254
            assert frameIndex = frameWrite_i.length report "Unread frame data discarded." severity error;
1255
            frameComplete_o <= '1';
1256
            readFrameEmpty_o <= '1';
1257
            readContentData_o <= (others => 'U');
1258
          else
1259
            -- Not reading a frame.
1260
          end if;
1261
 
1262
      end case;
1263
    end loop;
1264
  end process;
1265
 
1266
end architecture;

powered by: WebSVN 2.1.0

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