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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [axi4_stream_lib/] [sim/] [src/] [legacy/] [tb_axis_to_axi4_agent_class_pkg.sv] - Blame information for rev 49

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 49 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2015 Authors and OPENCORES.ORG                 ////
4
////                                                              ////
5
//// This source file may be used and distributed without         ////
6
//// restriction provided that this copyright statement is not    ////
7
//// removed from the file and that any derivative work contains  ////
8
//// the original copyright notice and the associated disclaimer. ////
9
////                                                              ////
10
//// This source file is free software; you can redistribute it   ////
11
//// and/or modify it under the terms of the GNU Lesser General   ////
12
//// Public License as published by the Free Software Foundation; ////
13
//// either version 2.1 of the License, or (at your option) any   ////
14
//// later version.                                               ////
15
////                                                              ////
16
//// This source is distributed in the hope that it will be       ////
17
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
18
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
19
//// PURPOSE.  See the GNU Lesser General Public License for more ////
20
//// details.                                                     ////
21
////                                                              ////
22
//// You should have received a copy of the GNU Lesser General    ////
23
//// Public License along with this source; if not, download it   ////
24
//// from http://www.opencores.org/lgpl.shtml                     ////
25
////                                                              ////
26
//////////////////////////////////////////////////////////////////////
27
 
28
 
29
package tb_axis_to_axi4_agent_class_pkg;
30
 
31
  // --------------------------------------------------------------------
32
  //
33
  import axi4_memory_pkg::*;
34
  import axis_bfm_pkg::*;
35
 
36
 
37
  // --------------------------------------------------------------------
38
  //
39
  class tb_axis_to_axi4_agent_class  #(N, A, I, D, U);
40
 
41
    axi4_memory_class #(A, N, I) m_h;
42
    axis_tx_bfm_class  #(N, I, D, U) s_h;
43
    memory_tr_class #(A, N, I) m_tr_h;
44
    axis_tr_class  #(N, I, D, U) s_tr_h;
45
 
46
    virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m;
47
    virtual axis_if #(.N(N), .I(I), .D(D), .U(U)) axis_in;
48
 
49
    mailbox #(memory_tr_class #(A, N, I)) q;
50
 
51
 
52
    // --------------------------------------------------------------------
53
    //
54
    task wait_for_sof;
55
      @(posedge axis_in.cb_s.tuser);
56
      $display("^^^ %16.t | %m", $time);
57
    endtask: wait_for_sof
58
 
59
 
60
    // --------------------------------------------------------------------
61
    //
62
    task wait_for_dma_done(int bvalid_count);
63
      repeat(bvalid_count)
64
        @(axi4_m.cb_s iff axi4_m.cb_m.bvalid & axi4_m.cb_s.bready);
65
      $display("^^^ %16.t | %m", $time);
66
    endtask: wait_for_dma_done
67
 
68
 
69
    // --------------------------------------------------------------------
70
    //
71
    task random_transaction(int addr, int size, int stride);
72
      m_h.clear_all();
73
      m_tr_h = new();
74
      m_tr_h.random(addr, size);
75
      q.put(m_tr_h);
76
 
77
      $display("^^^ %16.t | %m | m_tr_h.data.size = %x", $time, m_tr_h.data.size);
78
      for(int i = 0; i < m_tr_h.data.size; i += N)
79
      begin
80
        s_tr_h = new();
81
        for(int k = 0; k < N; k++)
82
        begin
83
          s_tr_h.tdata[k*8 +: 8] = m_tr_h.data[i + k];
84
        end
85
 
86
        if(i == 0)
87
          s_tr_h.tuser = 'b1;
88
        else
89
          s_tr_h.tuser = 'b0;
90
 
91
        if(i + N < m_tr_h.data.size)
92
          s_tr_h.tlast = 1'b0;
93
        else
94
          s_tr_h.tlast = 1'b1;
95
 
96
        s_h.q.put(s_tr_h);
97
      end
98
 
99
      wait_for_dma_done(size / stride);
100
    endtask: random_transaction
101
 
102
 
103
    // --------------------------------------------------------------------
104
    //
105
    task automatic compare(int offset);
106
      byte data[];
107
 
108
      $display("^^^ %16.t | %m", $time);
109
      $display("^^^ %16.t | q.num             = %d", $time, q.num);
110
      $display("^^^ %16.t | s_h.q.num         = %d", $time, s_h.q.num);
111
      $display("^^^ %16.t | m_tr_h.data.size  = %d", $time, m_tr_h.data.size);
112
 
113
      if(q.try_get(m_tr_h) == 0)
114
      begin
115
        $display("!!! %16.t | ERROR!!! try_get(m_tr_h) == 0", $time);
116
        $stop;
117
      end
118
 
119
      data = new[m_tr_h.data.size];
120
      m_h.dump_words(offset, data);
121
 
122
      foreach(m_tr_h.data[i])
123
        if(data[i] != m_tr_h.data[i])
124
        begin
125
          $display("!!! %16.t | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", $time);
126
          $display("!!! %16.t | %x ", $time, i);
127
          $display("!!! %16.t | %x | %x |", $time, data[i], m_tr_h.data[i]);
128
          $stop;
129
        end
130
 
131
      $display("^^^ %16.t | %m | done!", $time);
132
 
133
    endtask: compare
134
 
135
 
136
    //--------------------------------------------------------------------
137
    //
138
    function new
139
      (
140
        virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m,
141
        virtual axis_if #(.N(N), .I(I), .D(D), .U(U)) axis_in
142
      );
143
 
144
      this.axi4_m = axi4_m;
145
      this.axis_in = axis_in;
146
      m_h = new(axi4_m);
147
      s_h = new(axis_in);
148
      q = new();
149
    endfunction: new
150
 
151
 
152
  // --------------------------------------------------------------------
153
  //
154
  endclass: tb_axis_to_axi4_agent_class
155
 
156
// --------------------------------------------------------------------
157
//
158
endpackage: tb_axis_to_axi4_agent_class_pkg

powered by: WebSVN 2.1.0

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