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

Subversion Repositories rio

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

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

powered by: WebSVN 2.1.0

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