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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [uvm_src/] [tlm1/] [uvm_tlm_req_rsp.svh] - Blame information for rev 16

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 HanySalah
//
2
//----------------------------------------------------------------------
3
//   Copyright 2007-2011 Mentor Graphics Corporation
4
//   Copyright 2007-2011 Cadence Design Systems, Inc.
5
//   Copyright 2010 Synopsys, Inc.
6
//   All Rights Reserved Worldwide
7
//
8
//   Licensed under the Apache License, Version 2.0 (the
9
//   "License"); you may not use this file except in
10
//   compliance with the License.  You may obtain a copy of
11
//   the License at
12
//
13
//       http://www.apache.org/licenses/LICENSE-2.0
14
//
15
//   Unless required by applicable law or agreed to in
16
//   writing, software distributed under the License is
17
//   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
18
//   CONDITIONS OF ANY KIND, either express or implied.  See
19
//   the License for the specific language governing
20
//   permissions and limitations under the License.
21
//----------------------------------------------------------------------
22
 
23
 
24
//------------------------------------------------------------------------------
25
// Title: TLM Channel Classes
26
//------------------------------------------------------------------------------
27
// This section defines built-in TLM channel classes.
28
//------------------------------------------------------------------------------
29
 
30
//------------------------------------------------------------------------------
31
//
32
// CLASS: uvm_tlm_req_rsp_channel #(REQ,RSP)
33
//
34
// The uvm_tlm_req_rsp_channel contains a request FIFO of type ~REQ~ and a response
35
// FIFO of type ~RSP~. These FIFOs can be of any size. This channel is
36
// particularly useful for dealing with pipelined protocols where the request
37
// and response are not tightly coupled.
38
//
39
// Type parameters:
40
//
41
// REQ - Type of the request transactions conveyed by this channel.
42
// RSP - Type of the response transactions conveyed by this channel.
43
//
44
//------------------------------------------------------------------------------
45
 
46
class uvm_tlm_req_rsp_channel #(type REQ=int, type RSP=REQ) extends uvm_component;
47
 
48
  typedef uvm_tlm_req_rsp_channel #(REQ, RSP) this_type;
49
 
50
  const static string type_name = "uvm_tlm_req_rsp_channel #(REQ,RSP)";
51
 
52
  // Port: put_request_export
53
  //
54
  // The put_export provides both the blocking and non-blocking put interface
55
  // methods to the request FIFO:
56
  //
57
  //|  task put (input T t);
58
  //|  function bit can_put ();
59
  //|  function bit try_put (input T t);
60
  //
61
  // Any put port variant can connect and send transactions to the request FIFO
62
  // via this export, provided the transaction types match.
63
 
64
  uvm_put_export #(REQ) put_request_export;
65
 
66
 
67
  // Port: get_peek_response_export
68
  //
69
  // The get_peek_response_export provides all the blocking and non-blocking get
70
  // and peek interface methods to the response FIFO:
71
  //
72
  //|  task get (output T t);
73
  //|  function bit can_get ();
74
  //|  function bit try_get (output T t);
75
  //|  task peek (output T t);
76
  //|  function bit can_peek ();
77
  //|  function bit try_peek (output T t);
78
  //
79
  // Any get or peek port variant can connect to and retrieve transactions from
80
  // the response FIFO via this export, provided the transaction types match.
81
 
82
  uvm_get_peek_export #(RSP) get_peek_response_export;
83
 
84
 
85
  // Port: get_peek_request_export
86
  //
87
  // The get_peek_export provides all the blocking and non-blocking get and peek
88
  // interface methods to the response FIFO:
89
  //
90
  //|  task get (output T t);
91
  //|  function bit can_get ();
92
  //|  function bit try_get (output T t);
93
  //|  task peek (output T t);
94
  //|  function bit can_peek ();
95
  //|  function bit try_peek (output T t);
96
  //
97
  // Any get or peek port variant can connect to and retrieve transactions from
98
  // the response FIFO via this export, provided the transaction types match.
99
 
100
 
101
  uvm_get_peek_export #(REQ) get_peek_request_export;
102
 
103
 
104
  // Port: put_response_export
105
  //
106
  // The put_export provides both the blocking and non-blocking put interface
107
  // methods to the response FIFO:
108
  //
109
  //|  task put (input T t);
110
  //|  function bit can_put ();
111
  //|  function bit try_put (input T t);
112
  //
113
  // Any put port variant can connect and send transactions to the response FIFO
114
  // via this export, provided the transaction types match.
115
 
116
  uvm_put_export #(RSP) put_response_export;
117
 
118
 
119
  // Port: request_ap
120
  //
121
  // Transactions passed via ~put~ or ~try_put~ (via any port connected to the
122
  // put_request_export) are sent out this port via its write method.
123
  //
124
  //|  function void write (T t);
125
  //
126
  // All connected analysis exports and imps will receive these transactions.
127
 
128
  uvm_analysis_port #(REQ) request_ap;
129
 
130
 
131
  // Port: response_ap
132
  //
133
  // Transactions passed via ~put~ or ~try_put~ (via any port connected to the
134
  // put_response_export) are sent out this port via its write method.
135
  //
136
  //|  function void write (T t);
137
  //
138
  // All connected analysis exports and imps will receive these transactions.
139
 
140
  uvm_analysis_port   #(RSP) response_ap;
141
 
142
 
143
  // Port: master_export
144
  //
145
  // Exports a single interface that allows a master to put requests and get or
146
  // peek responses. It is a combination of the put_request_export and
147
  // get_peek_response_export.
148
 
149
  uvm_master_imp #(REQ, RSP, this_type, uvm_tlm_fifo #(REQ), uvm_tlm_fifo #(RSP)) master_export;
150
 
151
 
152
  // Port: slave_export
153
  //
154
  // Exports a single interface that allows a slave to get or peek requests and
155
  // to put responses. It is a combination of the get_peek_request_export
156
  // and put_response_export.
157
 
158
  uvm_slave_imp  #(REQ, RSP, this_type, uvm_tlm_fifo #(REQ), uvm_tlm_fifo #(RSP)) slave_export;
159
 
160
  // port aliases for backward compatibility
161
  uvm_put_export      #(REQ) blocking_put_request_export,
162
                             nonblocking_put_request_export;
163
  uvm_get_peek_export #(REQ) get_request_export,
164
                             blocking_get_request_export,
165
                             nonblocking_get_request_export,
166
                             peek_request_export,
167
                             blocking_peek_request_export,
168
                             nonblocking_peek_request_export,
169
                             blocking_get_peek_request_export,
170
                             nonblocking_get_peek_request_export;
171
 
172
  uvm_put_export      #(RSP) blocking_put_response_export,
173
                             nonblocking_put_response_export;
174
  uvm_get_peek_export #(RSP) get_response_export,
175
                             blocking_get_response_export,
176
                             nonblocking_get_response_export,
177
                             peek_response_export,
178
                             blocking_peek_response_export,
179
                             nonblocking_peek_response_export,
180
                             blocking_get_peek_response_export,
181
                             nonblocking_get_peek_response_export;
182
 
183
  uvm_master_imp #(REQ, RSP, this_type, uvm_tlm_fifo #(REQ), uvm_tlm_fifo #(RSP))
184
                             blocking_master_export,
185
                             nonblocking_master_export;
186
 
187
  uvm_slave_imp  #(REQ, RSP, this_type, uvm_tlm_fifo #(REQ), uvm_tlm_fifo #(RSP))
188
                             blocking_slave_export,
189
                             nonblocking_slave_export;
190
  // internal fifos
191
  protected uvm_tlm_fifo #(REQ) m_request_fifo;
192
  protected uvm_tlm_fifo #(RSP) m_response_fifo;
193
 
194
 
195
  // Function: new
196
  //
197
  // The ~name~ and ~parent~ are the standard  constructor arguments.
198
  // The ~parent~ must be ~null~ if this component is defined within a static
199
  // component such as a module, program block, or interface. The last two
200
  // arguments specify the request and response FIFO sizes, which have default
201
  // values of 1.
202
 
203
  function new (string name, uvm_component parent=null,
204
                int request_fifo_size=1,
205
                int response_fifo_size=1);
206
 
207
    super.new (name, parent);
208
 
209
    m_request_fifo  = new ("request_fifo",  this, request_fifo_size);
210
    m_response_fifo = new ("response_fifo", this, response_fifo_size);
211
 
212
    request_ap      = new ("request_ap",  this);
213
    response_ap     = new ("response_ap", this);
214
 
215
    put_request_export       = new ("put_request_export",       this);
216
    get_peek_request_export  = new ("get_peek_request_export",  this);
217
 
218
    put_response_export      = new ("put_response_export",      this);
219
    get_peek_response_export = new ("get_peek_response_export", this);
220
 
221
    master_export   = new ("master_export", this, m_request_fifo, m_response_fifo);
222
    slave_export    = new ("slave_export",  this, m_request_fifo, m_response_fifo);
223
 
224
    create_aliased_exports();
225
 
226
    set_report_id_action_hier(s_connection_error_id, UVM_NO_ACTION);
227
 
228
  endfunction
229
 
230
  virtual function void connect_phase(uvm_phase phase);
231
    put_request_export.connect       (m_request_fifo.put_export);
232
    get_peek_request_export.connect  (m_request_fifo.get_peek_export);
233
    m_request_fifo.put_ap.connect    (request_ap);
234
    put_response_export.connect      (m_response_fifo.put_export);
235
    get_peek_response_export.connect (m_response_fifo.get_peek_export);
236
    m_response_fifo.put_ap.connect   (response_ap);
237
  endfunction
238
 
239
  function void create_aliased_exports();
240
    // request
241
    blocking_put_request_export         = put_request_export;
242
    nonblocking_put_request_export      = put_request_export;
243
    get_request_export                  = get_peek_request_export;
244
    blocking_get_request_export         = get_peek_request_export;
245
    nonblocking_get_request_export      = get_peek_request_export;
246
    peek_request_export                 = get_peek_request_export;
247
    blocking_peek_request_export        = get_peek_request_export;
248
    nonblocking_peek_request_export     = get_peek_request_export;
249
    blocking_get_peek_request_export    = get_peek_request_export;
250
    nonblocking_get_peek_request_export = get_peek_request_export;
251
 
252
    // response
253
    blocking_put_response_export         = put_response_export;
254
    nonblocking_put_response_export      = put_response_export;
255
    get_response_export                  = get_peek_response_export;
256
    blocking_get_response_export         = get_peek_response_export;
257
    nonblocking_get_response_export      = get_peek_response_export;
258
    peek_response_export                 = get_peek_response_export;
259
    blocking_peek_response_export        = get_peek_response_export;
260
    nonblocking_peek_response_export     = get_peek_response_export;
261
    blocking_get_peek_response_export    = get_peek_response_export;
262
    nonblocking_get_peek_response_export = get_peek_response_export;
263
 
264
    // master/slave
265
    blocking_master_export    = master_export;
266
    nonblocking_master_export = master_export;
267
    blocking_slave_export     = slave_export;
268
    nonblocking_slave_export  = slave_export;
269
  endfunction
270
 
271
  // get_type_name
272
  // -------------
273
 
274
  function string get_type_name ();
275
    return type_name;
276
  endfunction
277
 
278
 
279
  // create
280
  // ------
281
 
282
  function uvm_object create (string name="");
283
    this_type v;
284
    v=new(name);
285
    return v;
286
  endfunction
287
 
288
 
289
endclass
290
 
291
 
292
//------------------------------------------------------------------------------
293
//
294
// CLASS: uvm_tlm_transport_channel #(REQ,RSP)
295
//
296
// A uvm_tlm_transport_channel is a  that implements
297
// the transport interface. It is useful when modeling a non-pipelined bus at
298
// the transaction level. Because the requests and responses have a tightly
299
// coupled one-to-one relationship, the request and response FIFO sizes are both
300
// set to one.
301
//
302
//------------------------------------------------------------------------------
303
 
304
class uvm_tlm_transport_channel #(type REQ=int, type RSP=REQ)
305
                                     extends uvm_tlm_req_rsp_channel #(REQ, RSP);
306
 
307
  typedef uvm_tlm_transport_channel #(REQ, RSP) this_type;
308
 
309
  // Port: transport_export
310
  //
311
  // The put_export provides both the blocking and non-blocking transport
312
  // interface methods to the response FIFO:
313
  //
314
  //|  task transport(REQ request, output RSP response);
315
  //|  function bit nb_transport(REQ request, output RSP response);
316
  //
317
  // Any transport port variant can connect to and send requests and retrieve
318
  // responses via this export, provided the transaction types match. Upon
319
  // return, the response argument carries the response to the request.
320
 
321
  uvm_transport_imp #(REQ, RSP, this_type) transport_export;
322
 
323
 
324
  // Function: new
325
  //
326
  // The ~name~ and ~parent~ are the standard  constructor
327
  // arguments. The ~parent~ must be ~null~ if this component is defined within a
328
  // statically elaborated construct such as a module, program block, or
329
  // interface.
330
 
331
  function new (string name, uvm_component parent=null);
332
    super.new(name, parent, 1, 1);
333
    transport_export = new("transport_export", this);
334
  endfunction
335
 
336
  task transport (REQ request, output RSP response );
337
    this.m_request_fifo.put( request );
338
    this.m_response_fifo.get( response );
339
  endtask
340
 
341
  function bit nb_transport (REQ req, output RSP rsp );
342
    if(this.m_request_fifo.try_put(req))
343
      return this.m_response_fifo.try_get(rsp);
344
    else
345
      return 0;
346
  endfunction
347
 
348
endclass

powered by: WebSVN 2.1.0

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