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

Subversion Repositories rio

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

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

Line No. Rev Author Line
1 42 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 test code to verify a RioWbBridge 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
-- REMARK: Move the testport package and entities to a seperate file.
46
-------------------------------------------------------------------------------
47
-- 
48
-------------------------------------------------------------------------------
49
library ieee;
50
use ieee.std_logic_1164.all;
51
use work.rio_common.all;
52
 
53
-------------------------------------------------------------------------------
54
-- 
55
-------------------------------------------------------------------------------
56
package TestPortPackage is
57
  constant ADDRESS_WIDTH : natural := 31;
58
  constant DATA_SIZE_MAX : natural := 32;
59
 
60
  type TestPortMessageWishbone is record
61
    writeAccess : boolean;
62
    address : std_logic_vector(ADDRESS_WIDTH-1 downto 0);
63
    byteSelect : std_logic_vector(7 downto 0);
64
    length : natural range 1 to DATA_SIZE_MAX;
65
    data : DoublewordArray(DATA_SIZE_MAX-1 downto 0);
66
    latency : natural;
67
  end record;
68
 
69
  type TestPortMessageSymbol is record
70
    symbolType : std_logic_vector(1 downto 0);
71
    symbolContent : std_logic_vector(31 downto 0);
72
    ignoreIdle : boolean;
73
  end record;
74
 
75
  type TestPortMessagePacketBuffer is record
76
    frame : RioFrame;
77
    willAbort : boolean;
78
  end record;
79
 
80
  -----------------------------------------------------------------------------
81
  -- 
82
  -----------------------------------------------------------------------------
83
 
84
  component TestPortWishbone is
85
    port(
86
      clk : in std_logic;
87
      areset_n : in std_logic;
88
 
89
      messageEmpty_o : out std_logic;
90
      messageWrite_i : in std_logic;
91
      message_i : in TestPortMessageWishbone;
92
      messageAck_o : out std_logic;
93
 
94
      cyc_i : in std_logic;
95
      stb_i : in std_logic;
96
      we_i : in std_logic;
97
      adr_i : in std_logic_vector(30 downto 0);
98
      sel_i : in std_logic_vector(7 downto 0);
99
      dat_i : in std_logic_vector(63 downto 0);
100
      dat_o : in std_logic_vector(63 downto 0);
101
      err_o : out std_logic;
102
      ack_o : out std_logic);
103
  end component;
104
 
105
  component TestPortPacketBuffer is
106
    port(
107
      clk : in std_logic;
108
      areset_n : in std_logic;
109
 
110
      outboundEmpty_o : out std_logic;
111
      outboundWrite_i : in std_logic;
112
      outboundMessage_i : in TestPortMessagePacketBuffer;
113
      outboundAck_o : out std_logic;
114
 
115
      inboundEmpty_o : out std_logic;
116
      inboundWrite_i : in std_logic;
117
      inboundMessage_i : in TestPortMessagePacketBuffer;
118
      inboundAck_o : out std_logic;
119
 
120
      readFrameEmpty_o : out std_logic;
121
      readFrame_i : in std_logic;
122
      readFrameRestart_i : in std_logic;
123
      readFrameAborted_o : out std_logic;
124
      readWindowEmpty_o : out std_logic;
125
      readWindowReset_i : in std_logic;
126
      readWindowNext_i : in std_logic;
127
      readContentEmpty_o : out std_logic;
128
      readContent_i : in std_logic;
129
      readContentEnd_o : out std_logic;
130
      readContentData_o : out std_logic_vector(31 downto 0);
131
 
132
      writeFrame_i : in std_logic;
133
      writeFrameAbort_i : in std_logic;
134
      writeContent_i : in std_logic;
135
      writeContentData_i : in std_logic_vector(31 downto 0));
136
  end component;
137
 
138
  -----------------------------------------------------------------------------
139
  -- 
140
  -----------------------------------------------------------------------------
141
  procedure TestPortWishboneWrite(
142
    signal writeSignal : out std_logic;
143
    signal messageSignal : out TestPortMessageWishbone;
144
    signal ackSignal : in std_logic;
145
    constant writeAccess : in boolean;
146
    constant address : in std_logic_vector(ADDRESS_WIDTH-1 downto 0);
147
    constant byteSelect : in std_logic_vector(7 downto 0);
148
    constant length : in natural range 1 to DATA_SIZE_MAX;
149
    constant data : in DoublewordArray(0 to DATA_SIZE_MAX-1);
150
    constant latency : natural := 0);
151
 
152
  procedure TestPortPacketBufferWrite(
153
    signal writeSignal : out std_logic;
154
    signal messageSignal : out TestPortMessagePacketBuffer;
155
    signal ackSignal : in std_logic;
156
    constant frame : in RioFrame;
157
    constant willAbort : boolean := false);
158
 
159
end package;
160
 
161
-------------------------------------------------------------------------------
162
-- 
163
-------------------------------------------------------------------------------
164
package body TestPortPackage is
165
 
166
  -----------------------------------------------------------------------------
167
  -- 
168
  -----------------------------------------------------------------------------
169
  procedure TestPortWishboneWrite(
170
    signal writeSignal : out std_logic;
171
    signal messageSignal : out TestPortMessageWishbone;
172
    signal ackSignal : in std_logic;
173
    constant writeAccess : in boolean;
174
    constant address : in std_logic_vector(ADDRESS_WIDTH-1 downto 0);
175
    constant byteSelect : in std_logic_vector(7 downto 0);
176
    constant length : in natural range 1 to DATA_SIZE_MAX;
177
    constant data : in DoublewordArray(0 to DATA_SIZE_MAX-1);
178
    constant latency : natural := 0) is
179
  begin
180
    writeSignal <= '1';
181
    messageSignal.writeAccess <= writeAccess;
182
    messageSignal.address <= address;
183
    messageSignal.byteSelect <= byteSelect;
184
    messageSignal.length <= length;
185
    messageSignal.data <= data;
186
    messageSignal.latency <= latency;
187
    wait until ackSignal = '1';
188
    writeSignal <= '0';
189
    wait until ackSignal = '0';
190
  end procedure;
191
 
192
  -----------------------------------------------------------------------------
193
  -- 
194
  -----------------------------------------------------------------------------
195
  procedure TestPortPacketBufferWrite(
196
    signal writeSignal : out std_logic;
197
    signal messageSignal : out TestPortMessagePacketBuffer;
198
    signal ackSignal : in std_logic;
199
    constant frame : in RioFrame;
200
    constant willAbort : boolean := false) is
201
  begin
202
    writeSignal <= '1';
203
    messageSignal.frame <= frame;
204
    messageSignal.willAbort <= willAbort;
205
    wait until ackSignal = '1';
206
    writeSignal <= '0';
207
    wait until ackSignal = '0';
208
  end procedure;
209
 
210
end package body;
211
 
212
 
213
 
214
 
215
-------------------------------------------------------------------------------
216
-- 
217
-------------------------------------------------------------------------------
218
library ieee;
219
use ieee.std_logic_1164.all;
220
use ieee.numeric_std.all;
221
library std;
222
use std.textio.all;
223
use work.rio_common.all;
224
use work.TestPortPackage.all;
225
 
226
 
227
-------------------------------------------------------------------------------
228
-- 
229
-------------------------------------------------------------------------------
230
entity TestPortPacketBuffer is
231
  port(
232
    clk : in std_logic;
233
    areset_n : in std_logic;
234
 
235
    outboundEmpty_o : out std_logic;
236
    outboundWrite_i : in std_logic;
237
    outboundMessage_i : in TestPortMessagePacketBuffer;
238
    outboundAck_o : out std_logic;
239
 
240
    inboundEmpty_o : out std_logic;
241
    inboundWrite_i : in std_logic;
242
    inboundMessage_i : in TestPortMessagePacketBuffer;
243
    inboundAck_o : out std_logic;
244
 
245
    readFrameEmpty_o : out std_logic;
246
    readFrame_i : in std_logic;
247
    readFrameRestart_i : in std_logic;
248
    readFrameAborted_o : out std_logic;
249
    readWindowEmpty_o : out std_logic;
250
    readWindowReset_i : in std_logic;
251
    readWindowNext_i : in std_logic;
252
    readContentEmpty_o : out std_logic;
253
    readContent_i : in std_logic;
254
    readContentEnd_o : out std_logic;
255
    readContentData_o : out std_logic_vector(31 downto 0);
256
 
257
    -- writeFrameFull_o is missing yes, but you can control it from the testbench directly
258
    -- instead.
259
    writeFrame_i : in std_logic;
260
    writeFrameAbort_i : in std_logic;
261
    writeContent_i : in std_logic;
262
    writeContentData_i : in std_logic_vector(31 downto 0));
263
end entity;
264
 
265
 
266
-------------------------------------------------------------------------------
267
-- 
268
-------------------------------------------------------------------------------
269
architecture TestPortPacketBufferPortImpl of TestPortPacketBuffer is
270
  constant QUEUE_SIZE : natural := 63;
271
  type QueueArray is array (natural range <>) of MessageFrame;
272
 
273
  function QueueIndexInc(constant i : natural) return natural is
274
    variable returnValue : natural;
275
  begin
276
    if(i = QUEUE_SIZE) then
277
      returnValue := 0;
278
    else
279
      returnValue := i + 1;
280
    end if;
281
    return returnValue;
282
  end function;
283
 
284
begin
285
 
286
  -----------------------------------------------------------------------------
287
  -- 
288
  -----------------------------------------------------------------------------
289
  Outbound: process
290
    variable frameQueue : QueueArray(0 to QUEUE_SIZE);
291
    variable front, back, window : natural range 0 to QUEUE_SIZE;
292
    variable frameIndex : natural;
293
  begin
294
    wait until areset_n = '1';
295
 
296
    readFrameEmpty_o <= '1';
297
    readFrameAborted_o <= '0';
298
    readWindowEmpty_o <= '1';
299
    readContentEmpty_o <= '1';
300
    readContentEnd_o <= '0';
301
    readContentData_o <= (others=>'0');
302
 
303
    front := 0;
304
    back := 0;
305
    window := 0;
306
    frameIndex := 0;
307
    outboundEmpty_o <= '1';
308
    outboundAck_o <= '0';
309
 
310
    loop
311
      wait until clk = '1' or outboundWrite_i = '1';
312
 
313
      if (clk'event) then
314
        if (readFrame_i = '1') then
315
          if (back /= front) then
316
            back := QueueIndexInc(back);
317
          else
318
            TestError("OUTBOUND:BACK:reading when no frame is present");
319
          end if;
320
        end if;
321
 
322
        if (readFrameRestart_i = '1') then
323
          frameIndex := 0;
324
        end if;
325
 
326
        if (readWindowReset_i = '1') then
327
          window := back;
328
          frameIndex := 0;
329
        end if;
330
 
331
        if (readWindowNext_i = '1') then
332
          if (window /= front) then
333
            window := QueueIndexInc(window);
334
            frameIndex := 0;
335
          else
336
            TestError("OUTBOUND:WINDOW:reading when no frame is present");
337
          end if;
338
        end if;
339
 
340
        if (readContent_i = '1') then
341
          if (back /= front) then
342
            if (frameIndex < frameQueue(window).frame.length) then
343
              readContentData_o <= frameQueue(window).frame.payload(frameIndex);
344
              frameIndex := frameIndex + 1;
345
              if (frameIndex = frameQueue(window).frame.length) then
346
                readContentEnd_o <= '1';
347
              else
348
                readContentEnd_o <= '0';
349
              end if;
350
            else
351
              TestError("OUTBOUND:CONTENT:reading when frame has ended");
352
            end if;
353
          else
354
            TestError("OUTBOUND:CONTENT:reading when no frame is present");
355
          end if;
356
        end if;
357
 
358
        if (front = back) then
359
          readFrameEmpty_o <= '1';
360
        else
361
          readFrameEmpty_o <= '0';
362
        end if;
363
 
364
        if (front = window) then
365
          readWindowEmpty_o <= '1';
366
          readContentEmpty_o <= '1';
367
        else
368
          readWindowEmpty_o <= '0';
369
          if (frameIndex /= frameQueue(window).frame.length) then
370
            readContentEmpty_o <= '0';
371
          else
372
            readContentEmpty_o <= '1';
373
          end if;
374
        end if;
375
 
376
        if (front = back) then
377
          outboundEmpty_o <= '1';
378
        else
379
          outboundEmpty_o <= '0';
380
        end if;
381
      elsif (outboundWrite_i'event) then
382
        frameQueue(front) := outboundMessage_i;
383
        front := QueueIndexInc(front);
384
 
385
        outboundEmpty_o <= '0';
386
        outboundAck_o <= '1';
387
        wait until outboundWrite_i = '0';
388
        outboundAck_o <= '0';
389
      end if;
390
    end loop;
391
  end process;
392
 
393
  -----------------------------------------------------------------------------
394
  -- 
395
  -----------------------------------------------------------------------------
396
  Inbound: process
397
    variable frameQueue : QueueArray(0 to QUEUE_SIZE);
398
    variable front, back : natural range 0 to QUEUE_SIZE;
399
    variable frameIndex : natural range 0 to 69;
400
  begin
401
    wait until areset_n = '1';
402
 
403
    inboundEmpty_o <= '1';
404
    inboundAck_o <= '0';
405
 
406
    front := 0;
407
    back := 0;
408
    frameIndex := 0;
409
 
410
    loop
411
      wait until clk = '1' or inboundWrite_i = '1';
412
 
413
      if (clk'event) then
414
 
415
        if (writeFrame_i = '1') then
416
          if (frameIndex = 0) then
417
            TestError("INBOUND:Empty frame written.");
418
          end if;
419
          if (frameIndex /= frameQueue(back).frame.length) then
420
            TestError("INBOUND:Frame with unmatching length was written.");
421
          end if;
422
          if (back /= front) then
423
            back := QueueIndexInc(back);
424
          else
425
            TestError("INBOUND:Unexpected frame written.");
426
          end if;
427
          frameIndex := 0;
428
        end if;
429
 
430
        if (writeFrameAbort_i = '1') then
431
          if (back /= front) then
432
            if (frameQueue(back).willAbort) then
433
              if (frameIndex /= frameQueue(back).frame.length) then
434
                TestError("INBOUND:Frame with unmatching length was aborted.");
435
              end if;
436
              back := QueueIndexInc(back);
437
            else
438
              TestError("INBOUND:Not expecting this frame to abort.");
439
            end if;
440
          end if;
441
          frameIndex := 0;
442
        end if;
443
 
444
        if (writeContent_i = '1') then
445
          if (frameIndex < frameQueue(back).frame.length) then
446
            if (frameQueue(back).frame.payload(frameIndex) /= writeContentData_i) then
447
              TestError("INBOUND:Unexpected frame content written.");
448
            end if;
449
            frameIndex := frameIndex + 1;
450
          else
451
            TestError("INBOUND:Receiving more frame content than expected.");
452
          end if;
453
        end if;
454
 
455
        if (front = back) then
456
          inboundEmpty_o <= '1';
457
        else
458
          inboundEmpty_o <= '0';
459
        end if;
460
      elsif (inboundWrite_i'event) then
461
        frameQueue(front) := inboundMessage_i;
462
        front := QueueIndexInc(front);
463
 
464
        inboundEmpty_o <= '0';
465
        inboundAck_o <= '1';
466
        wait until inboundWrite_i = '0';
467
        inboundAck_o <= '0';
468
      end if;
469
    end loop;
470
  end process;
471
 
472
end architecture;
473
 
474
 
475
 
476
-------------------------------------------------------------------------------
477
-- 
478
-------------------------------------------------------------------------------
479
library ieee;
480
use ieee.std_logic_1164.all;
481
use ieee.numeric_std.all;
482
library std;
483
use std.textio.all;
484
use work.rio_common.all;
485
use work.TestPortPackage.all;
486
 
487
 
488
-------------------------------------------------------------------------------
489
-- 
490
-------------------------------------------------------------------------------
491
entity TestPortWishbone is
492
  port(
493
    clk : in std_logic;
494
    areset_n : in std_logic;
495
 
496
    messageEmpty_o : out std_logic;
497
    messageWrite_i : in std_logic;
498
    message_i : in TestPortMessageWishbone;
499
    messageAck_o : out std_logic;
500
 
501
    cyc_i : in std_logic;
502
    stb_i : in std_logic;
503
    we_i : in std_logic;
504
    adr_i : in std_logic_vector(30 downto 0);
505
    sel_i : in std_logic_vector(7 downto 0);
506
    dat_i : in std_logic_vector(63 downto 0);
507
    dat_o : in std_logic_vector(63 downto 0);
508
    err_o : out std_logic;
509
    ack_o : out std_logic);
510
end entity;
511
 
512
 
513
-------------------------------------------------------------------------------
514
-- 
515
-------------------------------------------------------------------------------
516
architecture TestWishbonePortImpl of TestWishbonePort is
517
  constant QUEUE_SIZE : natural := 63;
518
  type QueueArray is array (natural range <>) of MessageFrame;
519
 
520
  function QueueIndexInc(constant i : natural) return natural is
521
    variable returnValue : natural;
522
  begin
523
    if(i = QUEUE_SIZE) then
524
      returnValue := 0;
525
    else
526
      returnValue := i + 1;
527
    end if;
528
    return returnValue;
529
  end function;
530
 
531
begin
532
 
533
  -----------------------------------------------------------------------------
534
  -- 
535
  -----------------------------------------------------------------------------
536
  Slave: process
537
    variable queue : QueueArray(0 to QUEUE_SIZE);
538
    variable front, back : natural range 0 to QUEUE_SIZE;
539
    variable cyclePosition : natural;
540
    variable latencyCounter : natural;
541
  begin
542
    wait until areset_n = '1';
543
 
544
    messageEmpty_o <= '1';
545
    messageAck_o <= '0';
546
 
547
    dat_o <= (others=>'U');
548
    err_o <= '0';
549
    ack_o <= '0';
550
 
551
    front := 0;
552
    back := 0;
553
    cyclePosition := 0;
554
    latencyCounter := 0;
555
 
556
    loop
557
      wait until clk = '1' or messageWrite_i = '1';
558
 
559
      if (clk'event) then
560
        if (cyc_i = '1') then
561
          if (front /= back) then
562
            TestCompare(stb_i, '1', "stb_i");
563
            if (queue(back).writeAccess) then
564
              TestCompare(we_i, '1', "we_i");
565
            else
566
              TestCompare(we_i, '0', "we_i");
567
            end if;
568
            TestCompare(adr_i, queue(back).address, "adr_i");
569
            TestCompare(sel_i, queue(back).byteSelect, "sel_i");
570
            TestCompare(dat_i, queue(back).data(cyclePosition), "dat_i");
571
 
572
            if (latencyCounter = queue(back).latency) then
573
              ack_o <= '1';
574
              latencyCounter := 0;
575
              if(cyclePosition = queue(back).length) then
576
                back := QueueIndexInc(back);
577
                cyclePosition := 0;
578
              else
579
                cyclePosition := cyclePosition + 1;
580
              end if;
581
            else
582
              ack_o <= '0';
583
              latencyCounter := latencyCounter + 1;
584
            end if;
585
          else
586
            TestError("Unexpected access.");
587
          end if;
588
        else
589
          if (cyclePostion /= 0) or (latencyCounter /= 0) then
590
            TestError("Cycle unexpectedly aborted.");
591
            cyclePosition := 0;
592
            latencyCounter := 0;
593
          end if;
594
          TestCompare(stb_i, '0', "stb_i");
595
        end if;
596
 
597
        if (front = back) then
598
          outboundWriteEmpty_o <= '1';
599
        else
600
          outboundWriteEmpty_o <= '0';
601
        end if;
602
      elsif (messageWrite_i'event) then
603
        queue(front) := message_i;
604
        front := QueueIndexInc(front);
605
 
606
        messageEmpty_o <= '0';
607
        messageAck_o <= '1';
608
        wait until messageWrite_i = '0';
609
        messageAck_o <= '0';
610
      end if;
611
    end loop;
612
  end process;
613
 
614
end architecture;
615
 
616
 
617
-------------------------------------------------------------------------------
618
-- TestRioWbBridge.
619
-------------------------------------------------------------------------------
620
 
621
library ieee;
622
use ieee.std_logic_1164.all;
623
use ieee.numeric_std.all;
624
use ieee.math_real.all;
625
library std;
626
use std.textio.all;
627
use work.rio_common.all;
628
use work.TestPortPackage.all;
629
 
630
 
631
-------------------------------------------------------------------------------
632
-- Entity for TestRioWbBridge.
633
-------------------------------------------------------------------------------
634
entity TestRioWbBridge is
635
end entity;
636
 
637
 
638
-------------------------------------------------------------------------------
639
-- Architecture for TestRioWbBridge.
640
-------------------------------------------------------------------------------
641
architecture TestRioWbBridgeImpl of TestRioWbBridge is
642
 
643
  component RioWbBridge is
644
    generic(
645
      EXTENDED_ADDRESS : natural range 0 to 2 := 0;
646
      DEVICE_IDENTITY : std_logic_vector(15 downto 0);
647
      DEVICE_VENDOR_IDENTITY : std_logic_vector(15 downto 0);
648
      DEVICE_REV : std_logic_vector(31 downto 0);
649
      ASSY_IDENTITY : std_logic_vector(15 downto 0);
650
      ASSY_VENDOR_IDENTITY : std_logic_vector(15 downto 0);
651
      ASSY_REV : std_logic_vector(15 downto 0));
652
    port(
653
      clk : in std_logic;
654
      areset_n : in std_logic;
655
 
656
      readFrameEmpty_i : in std_logic;
657
      readFrame_o : out std_logic;
658
      readContent_o : out std_logic;
659
      readContentEnd_i : in std_logic;
660
      readContentData_i : in std_logic_vector(31 downto 0);
661
      writeFrameFull_i : in std_logic;
662
      writeFrame_o : out std_logic;
663
      writeFrameAbort_o : out std_logic;
664
      writeContent_o : out std_logic;
665
      writeContentData_o : out std_logic_vector(31 downto 0);
666
 
667
      cyc_o : out std_logic;
668
      stb_o : out std_logic;
669
      we_o : out std_logic;
670
      adr_o : out std_logic_vector(16*EXTENDED_ADDRESS+30 downto 0);
671
      sel_o : out std_logic_vector(7 downto 0);
672
      dat_o : out std_logic_vector(63 downto 0);
673
      dat_i : in std_logic_vector(63 downto 0);
674
      err_i : in std_logic;
675
      ack_i : in std_logic);
676
  end component;
677
 
678
  -----------------------------------------------------------------------------
679
  -- 
680
  -----------------------------------------------------------------------------
681
 
682
  signal clk : std_logic;
683
  signal areset_n : std_logic;
684
  signal enable : std_logic;
685
 
686
  signal writeFrameFull : std_logic;
687
  signal writeFrame : std_logic;
688
  signal writeFrameAbort : std_logic;
689
  signal writeContent : std_logic;
690
  signal writeContentData : std_logic_vector(31 downto 0);
691
 
692
  signal readFrameEmpty : std_logic;
693
  signal readFrame : std_logic;
694
  signal readFrameRestart : std_logic;
695
  signal readFrameAborted : std_logic;
696
  signal readContentEmpty : std_logic;
697
  signal readContent : std_logic;
698
  signal readContentEnd : std_logic;
699
  signal readContentData : std_logic_vector(31 downto 0);
700
 
701
  signal wbCyc : std_logic;
702
  signal wbStb : std_logic;
703
  signal wbWe : std_logic;
704
  signal wbAdr : std_logic_vector(30 downto 0);
705
  signal wbSel : std_logic_vector(7 downto 0);
706
  signal wbDatWrite : std_logic_vector(63 downto 0);
707
  signal wbDatRead : std_logic_vector(63 downto 0);
708
  signal wbAck : std_logic;
709
  signal wbErr : std_logic;
710
 
711
  signal outboundEmpty : std_logic;
712
  signal outboundWrite : std_logic;
713
  signal outboundMessage : TestPortMessagePacketBuffer;
714
  signal outboundAck : std_logic;
715
 
716
  signal inboundEmpty : std_logic;
717
  signal inboundWrite : std_logic;
718
  signal inboundMessage : TestPortMessagePacketBuffer;
719
  signal inboundAck : std_logic;
720
 
721
  signal wbMessageEmpty : std_logic;
722
  signal wbMessageWrite : std_logic;
723
  signal wbMessage : TestPortMessageWishbone;
724
  signal wbMessageAck : std_logic;
725
 
726
begin
727
 
728
  -----------------------------------------------------------------------------
729
  -- Clock generation.
730
  -----------------------------------------------------------------------------
731
  ClockGenerator: process
732
  begin
733
    clk <= '0';
734
    wait for 20 ns;
735
    clk <= '1';
736
    wait for 20 ns;
737
  end process;
738
 
739
 
740
  -----------------------------------------------------------------------------
741
  -- Serial port emulator.
742
  -----------------------------------------------------------------------------
743
  TestDriver: process
744
 
745
    -----------------------------------------------------------------------------
746
    -- Procedures to handle outbound and inbound packets.
747
    -----------------------------------------------------------------------------
748
    procedure OutboundFrame(constant frame : in RioFrame) is
749
    begin
750
      TestPortPacketBufferWrite(outboundWrite, outboundMessage, outboundAck,
751
                                frame, false);
752
    end procedure;
753
 
754
    procedure InboundFrame(constant frame : in RioFrame) is
755
    begin
756
      TestPortPacketBufferWrite(inboundWrite, inboundMessage, inboundAck,
757
                                frame, false);
758
    end procedure;
759
 
760
    ---------------------------------------------------------------------------
761
    -- Procedure to handle wishbone accesses.
762
    ---------------------------------------------------------------------------
763
    procedure SetSlaveAccess(constant writeAccess : in boolean;
764
                             constant address : in std_logic_vector(ADDRESS_WIDTH-1 downto 0);
765
                             constant byteSelect : in std_logic_vector(7 downto 0);
766
                             constant length : in natural range 1 to DATA_SIZE_MAX;
767
                             constant data : in DoublewordArray(0 to DATA_SIZE_MAX-1);
768
                             constant latency : natural := 0) is
769
    begin
770
      TestPortWishboneWrite(wbMessageWrite, wbMessage, wbMessageAck,
771
                            writeAccess, address, byteSelect, length, data, latency);
772
    end procedure;
773
 
774
 
775
    ---------------------------------------------------------------------------
776
    -- 
777
    ---------------------------------------------------------------------------
778
    variable seed1 : positive := 1;
779
    variable seed2: positive := 1;
780
 
781
    variable ioData : DoubleWordArray(0 to 31);
782
    variable frame : RioFrame;
783
 
784
  begin
785
    areset_n <= '0';
786
 
787
    writeFrameFull <= '0';
788
 
789
    wait until clk'event and clk = '1';
790
    wait until clk'event and clk = '1';
791
    areset_n <= '1';
792
    wait until clk'event and clk = '1';
793
    wait until clk'event and clk = '1';
794
 
795
    ---------------------------------------------------------------------------
796
    PrintS("-----------------------------------------------------------------");
797
    PrintS("TG_RioLogicalCommon");
798
    PrintS("-----------------------------------------------------------------");
799
    PrintS("TG_RioLogicalCommon-TC1");
800
    PrintS("Description: Test maintenance read requests.");
801
    PrintS("Requirement: XXXXX");
802
    PrintS("-----------------------------------------------------------------");
803
    PrintS("Step 1:");
804
    PrintS("Action: Send maintenance read request for one word on even offset.");
805
    PrintS("Result: Check the accesses on the external configuration port.");
806
    PrintS("-----------------------------------------------------------------");
807
    ---------------------------------------------------------------------------
808
    PrintR("TG_RioLogicalCommon-TC1-Step1");
809
    ---------------------------------------------------------------------------
810
 
811
    ioData(0) := x"deadbeefc0debabe";
812
 
813
    InboundFrame(RioFrameCreate(ackId=>"00000", vc=>'0', crf=>'0', prio=>"00",
814
                                tt=>"01", ftype=>FTYPE_REQUEST_CLASS,
815
                                sourceId=>x"dead", destId=>x"beef",
816
                                payload=>RioNread(rdsize=>"0000",
817
                                                  tid=>x"aa",
818
                                                  address=>"00000000000000000000000000000",
819
                                                  wdptr=>'0',
820
                                                  xamsbs=>"00")));
821
 
822
    OutboundFrame(RioFrameCreate(ackId=>"00000", vc=>'0', crf=>'0', prio=>"00",
823
                                 tt=>"01", ftype=>FTYPE_RESPONSE_CLASS,
824
                                 sourceId=>x"beef", destId=>x"dead",
825
                                 payload=>RioResponse(status=>"0000",
826
                                                      tid=>x"aa",
827
                                                      dataLength=>1,
828
                                                      data=>ioData)));
829
 
830
    SetSlaveAccess(false, "0000000000000000000000000000000", "00000001", 1, ioData);
831
 
832
    TestWait(inboundEmpty, '1', "inbound frame");
833
    TestWait(outboundEmpty, '1', "outbound frame");
834
    TestWait(wbMessageEmpty, '1', "wishbone access");
835
 
836
    ---------------------------------------------------------------------------
837
    -- Test completed.
838
    ---------------------------------------------------------------------------
839
 
840
    TestEnd;
841
  end process;
842
 
843
  -----------------------------------------------------------------------------
844
  -- Instantiate the test object.
845
  -----------------------------------------------------------------------------
846
  TestObject: RioWbBridge
847
    generic map(
848
      EXTENDED_ADDRESS=>0)
849
    port map(
850
      clk=>clk,
851
      areset_n=>areset_n,
852
      readFrameEmpty_i=>readFrameEmpty,
853
      readFrame_o=>readFrame,
854
      readContent_o=>readContent,
855
      readContentEnd_i=>readContentEnd,
856
      readContentData_i=>readContentData,
857
      writeFrameFull_i=>writeFrameFull,
858
      writeFrame_o=>writeFrame,
859
      writeFrameAbort_o=>writeFrameAbort,
860
      writeContent_o=>writeContent,
861
      writeContentData_o=>writeContentData,
862
      cyc_o=>wbCyc,
863
      stb_o=>wbStb,
864
      we_o=>wbWe,
865
      adr_o=>wbAdr,
866
      sel_o=>wbSel,
867
      dat_o=>wbDatWrite,
868
      dat_i=>wbDatRead,
869
      err_i=>wbErr,
870
      ack_i=>wbAck);
871
 
872
  -----------------------------------------------------------------------------
873
  -- Instantiate the test ports.
874
  -----------------------------------------------------------------------------
875
 
876
  TestPortPacketBufferInst: TestPortPacketBuffer
877
    port map(
878
      clk=>clk, areset_n=>areset_n,
879
      outboundEmpty_o=>outboundEmpty,
880
      outboundWrite_i=>outboundWrite,
881
      outboundMessage_i=>outboundMessage,
882
      outboundAck_o=>outboundAck,
883
      inboundEmpty_o=>inboundEmpty,
884
      inboundWrite_i=>inboundWrite,
885
      inboundMessage_i=>inboundMessage,
886
      inboundAck_o=>inboundAck,
887
      readFrameEmpty_o=>readFrameEmpty,
888
      readFrame_i=>readFrame,
889
      readFrameRestart_i=>readFrameRestart,
890
      readFrameAborted_o=>readFrameAborted,
891
      readContentEmpty_o=>readContentEmpty,
892
      readContent_i=>readContent,
893
      readContentEnd_o=>readContentEnd,
894
      readContentData_o=>readContentData,
895
      writeFrame_i=>writeFrame,
896
      writeFrameAbort_i=>writeFrameAbort,
897
      writeContent_i=>writeContent,
898
      writeContentData_i=>writeContentData);
899
 
900
  TestPortWishboneInst: TestPortWishbone
901
    port map(
902
      clk=>clk,
903
      areset_n=>areset_n,
904
      messageEmpty_o=>wbMessageEmpty,
905
      messageWrite_i=>wbMessageWrite,
906
      message_i=>wbMessage,
907
      messageAck_o=>wbMessageAck,
908
      cyc_i=>wbCyc,
909
      stb_i=>wbStb,
910
      we_i=>wbWe,
911
      adr_i=>wbAdr,
912
      sel_i=>wbSel,
913
      dat_i=>wbDatWrite,
914
      dat_o=>wbDatRead,
915
      err_o=>wbErr,
916
      ack_o=>wbAck);
917
 
918
end architecture;

powered by: WebSVN 2.1.0

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