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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [BFM/] [src/] [tb/] [legacy/] [tb_bfm_pkg.sv] - Blame information for rev 50

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 50 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_bfm_pkg;
30
 
31
  // --------------------------------------------------------------------
32
  //
33
  class tb_nonblocking_transaction_q_class #(parameter type T = logic);
34
 
35
    T             tr_h;
36
    mailbox #(T)  q;
37
    semaphore     q_semaphore;
38
 
39
    //--------------------------------------------------------------------
40
    function new;
41
 
42
      this.q            = new();
43
      this.q_semaphore  = new(1);
44
 
45
    endfunction: new
46
 
47
 
48
    // --------------------------------------------------------------------
49
    //
50
    event start;
51
    event done;
52
 
53
    virtual task automatic
54
      transaction
55
      (
56
        ref T tr_h
57
      );
58
 
59
      ->start;
60
 
61
      $display("^^^ %16.t | %m | ERROR! Task not defined |", $time);
62
 
63
      ->done;
64
 
65
    endtask: transaction
66
 
67
 
68
    // --------------------------------------------------------------------
69
    //
70
    virtual task automatic
71
      idle;
72
 
73
      $display("^^^ %16.t | %m | ERROR! Task not defined |", $time);
74
 
75
    endtask: idle
76
 
77
 
78
    // --------------------------------------------------------------------
79
    //
80
    task
81
      put
82
      (
83
        ref T tr_h
84
      );
85
 
86
      $display("^^^ %16.t | %m | ", $time);
87
 
88
      q.put(tr_h);
89
 
90
    endtask: put
91
 
92
 
93
    // --------------------------------------------------------------------
94
    //
95
    task automatic
96
      run_q;
97
 
98
        if(q_semaphore.try_get() == 0)
99
        begin
100
          $display("^^^ %16.t | %m | ERROR! Aready active |", $time);
101
          return;
102
        end
103
 
104
        $display("^^^ %16.t | %m is active |", $time);
105
 
106
        run_q_fork : fork
107
          forever
108
            if(q.try_get(tr_h) != 0)
109
              transaction(tr_h);
110
            else
111
              idle();
112
        join_none
113
 
114
        #0;
115
 
116
    endtask: run_q
117
 
118
 
119
    // --------------------------------------------------------------------
120
    //
121
    function void
122
      init;
123
 
124
      fork
125
        run_q();
126
      join_none
127
 
128
      $display("^^^ %16.t | %m | initialization", $time);
129
 
130
    endfunction: init
131
 
132
  endclass: tb_nonblocking_transaction_q_class
133
 
134
 
135
  // --------------------------------------------------------------------
136
  //
137
  class tb_blocking_transaction_q_class #(parameter type T = logic);
138
 
139
    T             tr_h;
140
    mailbox #(T)  q;
141
    semaphore     q_semaphore;
142
 
143
    //--------------------------------------------------------------------
144
    function new;
145
 
146
      this.q            = new();
147
      this.q_semaphore  = new(1);
148
 
149
    endfunction: new
150
 
151
 
152
    // --------------------------------------------------------------------
153
    //
154
    event start;
155
    event done;
156
 
157
    virtual task automatic
158
      transaction
159
      (
160
        ref T tr_h
161
      );
162
 
163
      ->start;
164
 
165
      $display("^^^ %16.t | %m | ERROR! Task not defined |", $time);
166
 
167
      ->done;
168
 
169
    endtask: transaction
170
 
171
 
172
    // --------------------------------------------------------------------
173
    //
174
    task
175
      put
176
      (
177
        ref T tr_h
178
      );
179
 
180
      q.put(tr_h);
181
 
182
    endtask: put
183
 
184
 
185
    // --------------------------------------------------------------------
186
    //
187
    task automatic
188
      run_q;
189
 
190
        if(q_semaphore.try_get() == 0)
191
        begin
192
          $display("^^^ %16.t | %m | ERROR! Aready active |", $time);
193
          return;
194
        end
195
 
196
        $display("^^^ %16.t | %m is active |", $time);
197
 
198
        this.q = new();
199
 
200
        run_q_fork : fork
201
          forever
202
          begin
203
            q.get(tr_h);
204
            transaction(tr_h);
205
          end
206
        join_none
207
 
208
        #0;
209
 
210
    endtask: run_q
211
 
212
 
213
    // --------------------------------------------------------------------
214
    //
215
    function void
216
      init;
217
 
218
      fork
219
        run_q();
220
      join_none
221
 
222
      $display("^^^ %16.t | %m | initialization", $time);
223
 
224
    endfunction: init
225
 
226
  endclass: tb_blocking_transaction_q_class
227
 
228
 
229
endpackage: tb_bfm_pkg
230
 

powered by: WebSVN 2.1.0

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