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

Subversion Repositories qaz_libs

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

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

Line No. Rev Author Line
1 45 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 axis_bfm_pkg;
30
 
31
 
32
  // --------------------------------------------------------------------
33
  //
34
  import q_pkg::*;
35
  import bfm_pkg::*;
36
 
37
 
38
  // --------------------------------------------------------------------
39
  //
40
  class axis_tr_class #(N, I, D, U)
41
    extends transaction_class #(axis_tr_class #(N, I, D, U));
42
 
43
    rand logic [(8*N)-1:0]  tdata;
44
    rand logic [N-1:0]      tstrb;
45
    rand logic [N-1:0]      tkeep;
46
    rand logic              tlast;
47
    rand logic [I-1:0]      tid;
48
    rand logic [D-1:0]      tdest;
49
    rand logic [U-1:0]      tuser;
50
 
51
    // --------------------------------------------------------------------
52
    //
53
    function void copy(TR_T from);
54
    // delay_class        delay_h;
55
      this.tdata  = from.tdata;
56
      this.tstrb  = from.tstrb;
57
      this.tkeep  = from.tkeep;
58
      this.tlast  = from.tlast;
59
      this.tid    = from.tid;
60
      this.tdest  = from.tdest;
61
      this.tuser  = from.tuser;
62
    endfunction: copy
63
 
64
 
65
  // --------------------------------------------------------------------
66
  //
67
  endclass: axis_tr_class
68
 
69
 
70
  // --------------------------------------------------------------------
71
  //
72
  class axis_tx_bfm_class  #(N, I, D, U)
73
    extends blocking_transmission_q_class #(axis_tr_class #(.N(N), .I(I), .D(D), .U(U)));
74
 
75
    virtual axis_if #(.N(N), .I(I), .D(D), .U(U)) axis_out;
76
 
77
 
78
    //--------------------------------------------------------------------
79
    //
80
    function void set_default;
81
      axis_out.cb_m.tvalid  <= 0;
82
      axis_out.cb_m.tdata   <= 'bx;
83
      axis_out.cb_m.tstrb   <= 'bx;
84
      axis_out.cb_m.tkeep   <= 'bx;
85
      axis_out.cb_m.tlast   <= 'bx;
86
      axis_out.cb_m.tid     <= 'bx;
87
      axis_out.cb_m.tdest   <= 'bx;
88
      axis_out.cb_m.tuser   <= 'bx;
89
    endfunction: set_default
90
 
91
 
92
    //--------------------------------------------------------------------
93
    //
94
    task tx_transaction(axis_tr_class #(.N(N), .I(I), .D(D), .U(U)) tr_h);
95
      axis_out.zero_cycle_delay();
96
      repeat(tr_h.delay_h.delay) @(axis_out.cb_m);
97
 
98
      axis_out.cb_m.tvalid  <= 1;
99
      axis_out.cb_m.tdata   <= tr_h.tdata;
100
      axis_out.cb_m.tstrb   <= 0;
101
      axis_out.cb_m.tkeep   <= 0;
102
      axis_out.cb_m.tlast   <= tr_h.tlast;
103
      axis_out.cb_m.tid     <= 0;
104
      axis_out.cb_m.tdest   <= 0;
105
      axis_out.cb_m.tuser   <= tr_h.tuser;
106
 
107
      @(axis_out.cb_m);
108
      wait(axis_out.cb_m.tready);
109
      // @(axis_out.cb_m iff axis_out.cb_m.tready);
110
 
111
      set_default();
112
    endtask: tx_transaction
113
 
114
 
115
    // --------------------------------------------------------------------
116
    //
117
    event tx_done;
118
 
119
    task automatic transmit(ref Q_T tr_h);
120
      tx_transaction(tr_h);
121
      ->tx_done;
122
    endtask: transmit
123
 
124
 
125
    //--------------------------------------------------------------------
126
    //
127
    task init;
128
      set_default();
129
    endtask: init
130
 
131
 
132
    //--------------------------------------------------------------------
133
    //
134
    function new(virtual axis_if #(.N(N), .I(I), .D(D), .U(U)) axis_out);
135
      this.axis_out = axis_out;
136
      tr_h = new();
137
      fork
138
        init();
139
      join_none
140
      $display("^^^ %16.t | %m", $time);
141
    endfunction: new
142
 
143
  // --------------------------------------------------------------------
144
  //
145
  endclass: axis_tx_bfm_class
146
 
147
 
148
  // --------------------------------------------------------------------
149
  //
150
  class axis_rx_bfm_class  #(N, I, D, U)
151
    extends blocking_receiver_q_class #(axis_tr_class #(.N(N), .I(I), .D(D), .U(U)));
152
 
153
    virtual axis_if #(.N(N), .I(I), .D(D), .U(U)) axis_in;
154
 
155
 
156
    //--------------------------------------------------------------------
157
    //
158
    function void set_tready(bit value);
159
      axis_in.cb_s.tready  <= value;
160
    endfunction: set_tready
161
 
162
 
163
    //--------------------------------------------------------------------
164
    //
165
    task rx_transaction(axis_tr_class #(.N(N), .I(I), .D(D), .U(U)) tr_h);
166
      repeat(tr_h.delay_h.delay) @(axis_in.cb_s);
167
      axis_in.cb_s.tready <= 1;
168
 
169
      @(axis_in.cb_s);
170
      wait(axis_in.cb_s.tvalid);
171
      // @(axis_in.cb_s iff axis_in.cb_s.tvalid);
172
 
173
      tr_h.tdata  <= axis_in.cb_s.tdata;
174
      tr_h.tstrb  <= axis_in.cb_s.tstrb;
175
      tr_h.tkeep  <= axis_in.cb_s.tkeep;
176
      tr_h.tlast  <= axis_in.cb_s.tlast;
177
      tr_h.tid    <= axis_in.cb_s.tid;
178
      tr_h.tdest  <= axis_in.cb_s.tdest;
179
      tr_h.tuser  <= axis_in.cb_s.tuser;
180
 
181
      axis_in.cb_s.tready <= 0;
182
    endtask: rx_transaction
183
 
184
 
185
    // --------------------------------------------------------------------
186
    //
187
    event rx_frame_done;
188
 
189
    virtual task receive(ref Q_T tr_h);
190
      tr_h = new();
191
      void'(tr_h.delay_h.next());
192
      rx_transaction(tr_h);
193
      ->rx_frame_done;
194
    endtask: receive
195
 
196
 
197
    //--------------------------------------------------------------------
198
    //
199
    task init;
200
      set_tready(0);
201
    endtask: init
202
 
203
 
204
    //--------------------------------------------------------------------
205
    //
206
    function new (virtual axis_if #(.N(N), .I(I), .D(D), .U(U)) axis_in);
207
      this.axis_in = axis_in;
208
      fork
209
        init();
210
      join_none
211
      $display("^^^ %16.t | %m", $time);
212
    endfunction: new
213
 
214
  endclass: axis_rx_bfm_class
215
 
216
 
217
// --------------------------------------------------------------------
218
//
219
endpackage: axis_bfm_pkg
220
 

powered by: WebSVN 2.1.0

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