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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [BFM/] [src/] [tb/] [legacy/] [q_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 q_pkg;
30
 
31
  // --------------------------------------------------------------------
32
  //
33
  virtual class q_base_class #(parameter type Q_T = logic);
34
 
35
    Q_T            tr_h;
36
    mailbox #(Q_T) q;
37
 
38
    // --------------------------------------------------------------------
39
    //
40
    pure virtual task run_q;
41
 
42
 
43
    // --------------------------------------------------------------------
44
    //
45
    task put(ref Q_T tr_h);
46
      q.put(tr_h);
47
    endtask: put
48
 
49
 
50
    // --------------------------------------------------------------------
51
    //
52
    task get(ref Q_T tr_h);
53
      q.get(tr_h);
54
    endtask: get
55
 
56
 
57
    //--------------------------------------------------------------------
58
    function new;
59
      this.q = new();
60
      fork
61
        forever
62
          run_q();
63
      join_none
64
    endfunction: new
65
 
66
 
67
  // --------------------------------------------------------------------
68
  //
69
  endclass: q_base_class
70
 
71
 
72
  // --------------------------------------------------------------------
73
  //
74
  virtual class nonblocking_transmission_q_class #(parameter type Q_T = logic)
75
    extends q_base_class #(Q_T);
76
 
77
    // --------------------------------------------------------------------
78
    //
79
    pure virtual task transmit(ref Q_T tr_h);
80
    pure virtual task idle();
81
 
82
 
83
    // --------------------------------------------------------------------
84
    //
85
    task automatic run_q;
86
      if(q.try_get(tr_h) != 0)
87
        transmit(tr_h);
88
      else
89
        idle();
90
    endtask: run_q
91
 
92
 
93
  // --------------------------------------------------------------------
94
  //
95
  endclass: nonblocking_transmission_q_class
96
 
97
 
98
  // --------------------------------------------------------------------
99
  //
100
  virtual class blocking_transmission_q_class #(parameter type Q_T = logic)
101
    extends q_base_class #(Q_T);
102
 
103
    // --------------------------------------------------------------------
104
    //
105
    pure virtual task transmit(ref Q_T tr_h);
106
 
107
 
108
    // --------------------------------------------------------------------
109
    //
110
    task run_q;
111
      q.get(tr_h);
112
      transmit(tr_h);
113
    endtask: run_q
114
 
115
 
116
  // --------------------------------------------------------------------
117
  //
118
  endclass: blocking_transmission_q_class
119
 
120
 
121
  // --------------------------------------------------------------------
122
  //
123
  virtual class blocking_receiver_q_class #(parameter type Q_T = logic)
124
    extends q_base_class #(Q_T);
125
 
126
    // --------------------------------------------------------------------
127
    //
128
    pure virtual task receive(ref Q_T tr_h);
129
 
130
 
131
    // --------------------------------------------------------------------
132
    //
133
    task run_q;
134
      receive(tr_h);
135
      q.put(tr_h);
136
    endtask: run_q
137
 
138
 
139
  //--------------------------------------------------------------------
140
  //
141
  endclass: blocking_receiver_q_class
142
 
143
 
144
//--------------------------------------------------------------------
145
//
146
endpackage: q_pkg
147
 

powered by: WebSVN 2.1.0

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