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 |
|
|
typedef class uvm_event;
|
24 |
|
|
typedef class uvm_event_pool;
|
25 |
|
|
typedef class uvm_component;
|
26 |
|
|
typedef class uvm_parent_child_link;
|
27 |
|
|
|
28 |
|
|
//------------------------------------------------------------------------------
|
29 |
|
|
//
|
30 |
|
|
// CLASS: uvm_transaction
|
31 |
|
|
//
|
32 |
|
|
// The uvm_transaction class is the root base class for UVM transactions.
|
33 |
|
|
// Inheriting all the methods of , uvm_transaction adds a timing and
|
34 |
|
|
// recording interface.
|
35 |
|
|
//
|
36 |
|
|
// This class provides timestamp properties, notification events, and transaction
|
37 |
|
|
// recording support.
|
38 |
|
|
//
|
39 |
|
|
// Use of this class as a base for user-defined transactions
|
40 |
|
|
// is deprecated. Its subtype, , shall be used as the
|
41 |
|
|
// base class for all user-defined transaction types.
|
42 |
|
|
//
|
43 |
|
|
// The intended use of this API is via a to call ,
|
44 |
|
|
// , and during the course of
|
45 |
|
|
// sequence item execution. These methods in the component base class will
|
46 |
|
|
// call into the corresponding methods in this class to set the corresponding
|
47 |
|
|
// timestamps (~accept_time~, ~begin_time~, and ~end_time~), trigger the
|
48 |
|
|
// corresponding event ( and , and, if enabled,
|
49 |
|
|
// record the transaction contents to a vendor-specific transaction database.
|
50 |
|
|
//
|
51 |
|
|
// Note that get_next_item/item_done when called on a uvm_seq_item_pull_port
|
52 |
|
|
// will automatically trigger the begin_event and end_events via calls to begin_tr and end_tr.
|
53 |
|
|
// While convenient, it is generally the responsibility of drivers to mark a
|
54 |
|
|
// transaction's progress during execution. To allow the driver or layering sequence
|
55 |
|
|
// to control sequence item timestamps, events, and recording, you must call
|
56 |
|
|
// at the beginning
|
57 |
|
|
// of the driver's ~run_phase~ task.
|
58 |
|
|
//
|
59 |
|
|
// Users may also use the transaction's event pool, ,
|
60 |
|
|
// to define custom events for the driver to trigger and the sequences to wait on. Any
|
61 |
|
|
// in-between events such as marking the beginning of the address and data
|
62 |
|
|
// phases of transaction execution could be implemented via the
|
63 |
|
|
// pool.
|
64 |
|
|
//
|
65 |
|
|
// In pipelined protocols, the driver may release a sequence (return from
|
66 |
|
|
// finish_item() or it's `uvm_do macro) before the item has been completed.
|
67 |
|
|
// If the driver uses the begin_tr/end_tr API in uvm_component, the sequence can
|
68 |
|
|
// wait on the item's to block until the item was fully executed,
|
69 |
|
|
// as in the following example.
|
70 |
|
|
//
|
71 |
|
|
//| task uvm_execute(item, ...);
|
72 |
|
|
//| // can use the `uvm_do macros as well
|
73 |
|
|
//| start_item(item);
|
74 |
|
|
//| item.randomize();
|
75 |
|
|
//| finish_item(item);
|
76 |
|
|
//| item.end_event.wait_on();
|
77 |
|
|
//| // get_response(rsp, item.get_transaction_id()); //if needed
|
78 |
|
|
//| endtask
|
79 |
|
|
//|
|
80 |
|
|
//
|
81 |
|
|
// A simple two-stage pipeline driver that can execute address and
|
82 |
|
|
// data phases concurrently might be implemented as follows:
|
83 |
|
|
//
|
84 |
|
|
//| task run();
|
85 |
|
|
//| // this driver supports a two-deep pipeline
|
86 |
|
|
//| fork
|
87 |
|
|
//| do_item();
|
88 |
|
|
//| do_item();
|
89 |
|
|
//| join
|
90 |
|
|
//| endtask
|
91 |
|
|
//|
|
92 |
|
|
//|
|
93 |
|
|
//| task do_item();
|
94 |
|
|
//|
|
95 |
|
|
//| forever begin
|
96 |
|
|
//| mbus_item req;
|
97 |
|
|
//|
|
98 |
|
|
//| lock.get();
|
99 |
|
|
//|
|
100 |
|
|
//| seq_item_port.get(req); // Completes the sequencer-driver handshake
|
101 |
|
|
//|
|
102 |
|
|
//| accept_tr(req);
|
103 |
|
|
//|
|
104 |
|
|
//| // request bus, wait for grant, etc.
|
105 |
|
|
//|
|
106 |
|
|
//| begin_tr(req);
|
107 |
|
|
//|
|
108 |
|
|
//| // execute address phase
|
109 |
|
|
//|
|
110 |
|
|
//| // allows next transaction to begin address phase
|
111 |
|
|
//| lock.put();
|
112 |
|
|
//|
|
113 |
|
|
//| // execute data phase
|
114 |
|
|
//| // (may trigger custom "data_phase" event here)
|
115 |
|
|
//|
|
116 |
|
|
//| end_tr(req);
|
117 |
|
|
//|
|
118 |
|
|
//| end
|
119 |
|
|
//|
|
120 |
|
|
//| endtask: do_item
|
121 |
|
|
//
|
122 |
|
|
//------------------------------------------------------------------------------
|
123 |
|
|
|
124 |
|
|
virtual class uvm_transaction extends uvm_object;
|
125 |
|
|
|
126 |
|
|
// Function: new
|
127 |
|
|
//
|
128 |
|
|
// Creates a new transaction object. The name is the instance name of the
|
129 |
|
|
// transaction. If not supplied, then the object is unnamed.
|
130 |
|
|
|
131 |
|
|
extern function new (string name="", uvm_component initiator=null);
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
// Function: accept_tr
|
135 |
|
|
//
|
136 |
|
|
// Calling ~accept_tr~ indicates that the transaction item has been received by
|
137 |
|
|
// a consumer component. Typically a would call ,
|
138 |
|
|
// which calls this method-- upon return from a ~get_next_item()~, ~get()~, or ~peek()~
|
139 |
|
|
// call on its sequencer port, .
|
140 |
|
|
//
|
141 |
|
|
// With some
|
142 |
|
|
// protocols, the received item may not be started immediately after it is
|
143 |
|
|
// accepted. For example, a bus driver, having accepted a request transaction,
|
144 |
|
|
// may still have to wait for a bus grant before beginning to execute
|
145 |
|
|
// the request.
|
146 |
|
|
//
|
147 |
|
|
// This function performs the following actions:
|
148 |
|
|
//
|
149 |
|
|
// - The transaction's internal accept time is set to the current simulation
|
150 |
|
|
// time, or to accept_time if provided and non-zero. The ~accept_time~ may be
|
151 |
|
|
// any time, past or future.
|
152 |
|
|
//
|
153 |
|
|
// - The transaction's internal accept event is triggered. Any processes
|
154 |
|
|
// waiting on the this event will resume in the next delta cycle.
|
155 |
|
|
//
|
156 |
|
|
// - The method is called to allow for any post-accept
|
157 |
|
|
// action in derived classes.
|
158 |
|
|
|
159 |
|
|
extern function void accept_tr (time accept_time = 0);
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
// Function: do_accept_tr
|
163 |
|
|
//
|
164 |
|
|
// This user-definable callback is called by just before the accept
|
165 |
|
|
// event is triggered. Implementations should call ~super.do_accept_tr~ to
|
166 |
|
|
// ensure correct operation.
|
167 |
|
|
|
168 |
|
|
extern virtual protected function void do_accept_tr ();
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
// Function: begin_tr
|
172 |
|
|
//
|
173 |
|
|
// This function indicates that the transaction has been started and is not
|
174 |
|
|
// the child of another transaction. Generally, a consumer component begins
|
175 |
|
|
// execution of a transactions it receives.
|
176 |
|
|
//
|
177 |
|
|
// Typically a would call , which
|
178 |
|
|
// calls this method, before actual execution of a sequence item transaction.
|
179 |
|
|
// Sequence items received by a driver are always a child of a parent sequence.
|
180 |
|
|
// In this case, begin_tr obtains the parent handle and delegates to .
|
181 |
|
|
//
|
182 |
|
|
// See for more information on how the
|
183 |
|
|
// begin-time might differ from when the transaction item was received.
|
184 |
|
|
//
|
185 |
|
|
// This function performs the following actions:
|
186 |
|
|
//
|
187 |
|
|
// - The transaction's internal start time is set to the current simulation
|
188 |
|
|
// time, or to begin_time if provided and non-zero. The begin_time may be
|
189 |
|
|
// any time, past or future, but should not be less than the accept time.
|
190 |
|
|
//
|
191 |
|
|
// - If recording is enabled, then a new database-transaction is started with
|
192 |
|
|
// the same begin time as above.
|
193 |
|
|
//
|
194 |
|
|
// - The method is called to allow for any post-begin action in
|
195 |
|
|
// derived classes.
|
196 |
|
|
//
|
197 |
|
|
// - The transaction's internal begin event is triggered. Any processes
|
198 |
|
|
// waiting on this event will resume in the next delta cycle.
|
199 |
|
|
//
|
200 |
|
|
// The return value is a transaction handle, which is valid (non-zero) only if
|
201 |
|
|
// recording is enabled. The meaning of the handle is implementation specific.
|
202 |
|
|
|
203 |
|
|
|
204 |
|
|
extern function integer begin_tr (time begin_time = 0);
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
// Function: begin_child_tr
|
208 |
|
|
//
|
209 |
|
|
// This function indicates that the transaction has been started as a child of
|
210 |
|
|
// a parent transaction given by ~parent_handle~. Generally, a consumer
|
211 |
|
|
// component calls this method via to indicate
|
212 |
|
|
// the actual start of execution of this transaction.
|
213 |
|
|
//
|
214 |
|
|
// The parent handle is obtained by a previous call to begin_tr or
|
215 |
|
|
// begin_child_tr. If the parent_handle is invalid (=0), then this function
|
216 |
|
|
// behaves the same as .
|
217 |
|
|
//
|
218 |
|
|
// This function performs the following actions:
|
219 |
|
|
//
|
220 |
|
|
// - The transaction's internal start time is set to the current simulation
|
221 |
|
|
// time, or to begin_time if provided and non-zero. The begin_time may be
|
222 |
|
|
// any time, past or future, but should not be less than the accept time.
|
223 |
|
|
//
|
224 |
|
|
// - If recording is enabled, then a new database-transaction is started with
|
225 |
|
|
// the same begin time as above. The inherited method
|
226 |
|
|
// is then called, which records the current property values to this new
|
227 |
|
|
// transaction. Finally, the newly started transaction is linked to the
|
228 |
|
|
// parent transaction given by parent_handle.
|
229 |
|
|
//
|
230 |
|
|
// - The method is called to allow for any post-begin
|
231 |
|
|
// action in derived classes.
|
232 |
|
|
//
|
233 |
|
|
// - The transaction's internal begin event is triggered. Any processes
|
234 |
|
|
// waiting on this event will resume in the next delta cycle.
|
235 |
|
|
//
|
236 |
|
|
// The return value is a transaction handle, which is valid (non-zero) only if
|
237 |
|
|
// recording is enabled. The meaning of the handle is implementation specific.
|
238 |
|
|
|
239 |
|
|
extern function integer begin_child_tr (time begin_time = 0,
|
240 |
|
|
integer parent_handle = 0);
|
241 |
|
|
|
242 |
|
|
|
243 |
|
|
// Function: do_begin_tr
|
244 |
|
|
//
|
245 |
|
|
// This user-definable callback is called by and just
|
246 |
|
|
// before the begin event is triggered. Implementations should call
|
247 |
|
|
// ~super.do_begin_tr~ to ensure correct operation.
|
248 |
|
|
|
249 |
|
|
extern virtual protected function void do_begin_tr ();
|
250 |
|
|
|
251 |
|
|
|
252 |
|
|
// Function: end_tr
|
253 |
|
|
//
|
254 |
|
|
// This function indicates that the transaction execution has ended.
|
255 |
|
|
// Generally, a consumer component ends execution of the transactions it
|
256 |
|
|
// receives.
|
257 |
|
|
//
|
258 |
|
|
// You must have previously called or for this
|
259 |
|
|
// call to be successful.
|
260 |
|
|
//
|
261 |
|
|
// Typically a would call , which
|
262 |
|
|
// calls this method, upon completion of a sequence item transaction.
|
263 |
|
|
// Sequence items received by a driver are always a child of a parent sequence.
|
264 |
|
|
// In this case, begin_tr obtain the parent handle and delegate to .
|
265 |
|
|
//
|
266 |
|
|
// This function performs the following actions:
|
267 |
|
|
//
|
268 |
|
|
// - The transaction's internal end time is set to the current simulation
|
269 |
|
|
// time, or to ~end_time~ if provided and non-zero. The ~end_time~ may be any
|
270 |
|
|
// time, past or future, but should not be less than the begin time.
|
271 |
|
|
//
|
272 |
|
|
// - If recording is enabled and a database-transaction is currently active,
|
273 |
|
|
// then the record method inherited from uvm_object is called, which records
|
274 |
|
|
// the final property values. The transaction is then ended. If ~free_handle~
|
275 |
|
|
// is set, the transaction is released and can no longer be linked to (if
|
276 |
|
|
// supported by the implementation).
|
277 |
|
|
//
|
278 |
|
|
// - The method is called to allow for any post-end
|
279 |
|
|
// action in derived classes.
|
280 |
|
|
//
|
281 |
|
|
// - The transaction's internal end event is triggered. Any processes waiting
|
282 |
|
|
// on this event will resume in the next delta cycle.
|
283 |
|
|
|
284 |
|
|
extern function void end_tr (time end_time=0, bit free_handle=1);
|
285 |
|
|
|
286 |
|
|
|
287 |
|
|
// Function: do_end_tr
|
288 |
|
|
//
|
289 |
|
|
// This user-definable callback is called by just before the end event
|
290 |
|
|
// is triggered. Implementations should call ~super.do_end_tr~ to ensure correct
|
291 |
|
|
// operation.
|
292 |
|
|
|
293 |
|
|
extern virtual protected function void do_end_tr ();
|
294 |
|
|
|
295 |
|
|
|
296 |
|
|
// Function: get_tr_handle
|
297 |
|
|
//
|
298 |
|
|
// Returns the handle associated with the transaction, as set by a previous
|
299 |
|
|
// call to or with transaction recording enabled.
|
300 |
|
|
|
301 |
|
|
extern function integer get_tr_handle ();
|
302 |
|
|
|
303 |
|
|
|
304 |
|
|
// Function: disable_recording
|
305 |
|
|
//
|
306 |
|
|
// Turns off recording for the transaction stream. This method does not
|
307 |
|
|
// effect a 's recording streams.
|
308 |
|
|
|
309 |
|
|
extern function void disable_recording ();
|
310 |
|
|
|
311 |
|
|
// Function: enable_recording
|
312 |
|
|
// Turns on recording to the ~stream~ specified.
|
313 |
|
|
//
|
314 |
|
|
// If transaction recording is on, then a call to ~record~ is made when the
|
315 |
|
|
// transaction is ended.
|
316 |
|
|
extern function void enable_recording (uvm_tr_stream stream);
|
317 |
|
|
|
318 |
|
|
// Function: is_recording_enabled
|
319 |
|
|
//
|
320 |
|
|
// Returns 1 if recording is currently on, 0 otherwise.
|
321 |
|
|
|
322 |
|
|
extern function bit is_recording_enabled();
|
323 |
|
|
|
324 |
|
|
|
325 |
|
|
// Function: is_active
|
326 |
|
|
//
|
327 |
|
|
// Returns 1 if the transaction has been started but has not yet been ended.
|
328 |
|
|
// Returns 0 if the transaction has not been started.
|
329 |
|
|
|
330 |
|
|
extern function bit is_active ();
|
331 |
|
|
|
332 |
|
|
|
333 |
|
|
// Function: get_event_pool
|
334 |
|
|
//
|
335 |
|
|
// Returns the event pool associated with this transaction.
|
336 |
|
|
//
|
337 |
|
|
// By default, the event pool contains the events: begin, accept, and end.
|
338 |
|
|
// Events can also be added by derivative objects. An event pool is a
|
339 |
|
|
// specialization of , e.g. a ~uvm_pool#(uvm_event)~.
|
340 |
|
|
|
341 |
|
|
extern function uvm_event_pool get_event_pool ();
|
342 |
|
|
|
343 |
|
|
|
344 |
|
|
// Function: set_initiator
|
345 |
|
|
//
|
346 |
|
|
// Sets initiator as the initiator of this transaction.
|
347 |
|
|
//
|
348 |
|
|
// The initiator can be the component that produces the transaction. It can
|
349 |
|
|
// also be the component that started the transaction. This or any other
|
350 |
|
|
// usage is up to the transaction designer.
|
351 |
|
|
|
352 |
|
|
extern function void set_initiator (uvm_component initiator);
|
353 |
|
|
|
354 |
|
|
|
355 |
|
|
// Function: get_initiator
|
356 |
|
|
//
|
357 |
|
|
// Returns the component that produced or started the transaction, as set by
|
358 |
|
|
// a previous call to set_initiator.
|
359 |
|
|
|
360 |
|
|
extern function uvm_component get_initiator ();
|
361 |
|
|
|
362 |
|
|
|
363 |
|
|
// Function: get_accept_time
|
364 |
|
|
|
365 |
|
|
extern function time get_accept_time ();
|
366 |
|
|
|
367 |
|
|
// Function: get_begin_time
|
368 |
|
|
|
369 |
|
|
extern function time get_begin_time ();
|
370 |
|
|
|
371 |
|
|
// Function: get_end_time
|
372 |
|
|
//
|
373 |
|
|
// Returns the time at which this transaction was accepted, begun, or ended,
|
374 |
|
|
// as by a previous call to , , , or .
|
375 |
|
|
|
376 |
|
|
extern function time get_end_time ();
|
377 |
|
|
|
378 |
|
|
|
379 |
|
|
// Function: set_transaction_id
|
380 |
|
|
//
|
381 |
|
|
// Sets this transaction's numeric identifier to id. If not set via this
|
382 |
|
|
// method, the transaction ID defaults to -1.
|
383 |
|
|
//
|
384 |
|
|
// When using sequences to generate stimulus, the transaction ID is used along
|
385 |
|
|
// with the sequence ID to route responses in sequencers and to correlate
|
386 |
|
|
// responses to requests.
|
387 |
|
|
|
388 |
|
|
extern function void set_transaction_id(integer id);
|
389 |
|
|
|
390 |
|
|
|
391 |
|
|
// Function: get_transaction_id
|
392 |
|
|
//
|
393 |
|
|
// Returns this transaction's numeric identifier, which is -1 if not set
|
394 |
|
|
// explicitly by ~set_transaction_id~.
|
395 |
|
|
//
|
396 |
|
|
// When using a to generate stimulus, the transaction
|
397 |
|
|
// ID is used along
|
398 |
|
|
// with the sequence ID to route responses in sequencers and to correlate
|
399 |
|
|
// responses to requests.
|
400 |
|
|
|
401 |
|
|
extern function integer get_transaction_id();
|
402 |
|
|
|
403 |
|
|
|
404 |
|
|
// Variable: events
|
405 |
|
|
//
|
406 |
|
|
// The event pool instance for this transaction. This pool is used to track
|
407 |
|
|
// various milestones: by default, begin, accept, and end
|
408 |
|
|
|
409 |
|
|
const uvm_event_pool events = new;
|
410 |
|
|
|
411 |
|
|
|
412 |
|
|
// Variable: begin_event
|
413 |
|
|
//
|
414 |
|
|
// A ~uvm_event#(uvm_object)~ that is triggered when this transaction's actual execution on the
|
415 |
|
|
// bus begins, typically as a result of a driver calling .
|
416 |
|
|
// Processes that wait on this event will block until the transaction has
|
417 |
|
|
// begun.
|
418 |
|
|
//
|
419 |
|
|
// For more information, see the general discussion for .
|
420 |
|
|
// See for details on the event API.
|
421 |
|
|
//
|
422 |
|
|
uvm_event#(uvm_object) begin_event;
|
423 |
|
|
|
424 |
|
|
// Variable: end_event
|
425 |
|
|
//
|
426 |
|
|
// A ~uvm_event#(uvm_object)~ that is triggered when this transaction's actual execution on
|
427 |
|
|
// the bus ends, typically as a result of a driver calling .
|
428 |
|
|
// Processes that wait on this event will block until the transaction has
|
429 |
|
|
// ended.
|
430 |
|
|
//
|
431 |
|
|
// For more information, see the general discussion for .
|
432 |
|
|
// See for details on the event API.
|
433 |
|
|
//
|
434 |
|
|
//| virtual task my_sequence::body();
|
435 |
|
|
//| ...
|
436 |
|
|
//| start_item(item); \
|
437 |
|
|
//| item.randomize(); } `uvm_do(item)
|
438 |
|
|
//| finish_item(item); /
|
439 |
|
|
//| // return from finish item does not always mean item is completed
|
440 |
|
|
//| item.end_event.wait_on();
|
441 |
|
|
//| ...
|
442 |
|
|
//
|
443 |
|
|
uvm_event#(uvm_object) end_event;
|
444 |
|
|
|
445 |
|
|
//----------------------------------------------------------------------------
|
446 |
|
|
//
|
447 |
|
|
// Internal methods properties; do not use directly
|
448 |
|
|
//
|
449 |
|
|
//----------------------------------------------------------------------------
|
450 |
|
|
|
451 |
|
|
//Override data control methods for internal properties
|
452 |
|
|
extern virtual function void do_print (uvm_printer printer);
|
453 |
|
|
extern virtual function void do_record (uvm_recorder recorder);
|
454 |
|
|
extern virtual function void do_copy (uvm_object rhs);
|
455 |
|
|
|
456 |
|
|
|
457 |
|
|
extern protected function integer m_begin_tr (time begin_time=0,
|
458 |
|
|
integer parent_handle=0);
|
459 |
|
|
|
460 |
|
|
local integer m_transaction_id = -1;
|
461 |
|
|
|
462 |
|
|
local time begin_time=-1;
|
463 |
|
|
local time end_time=-1;
|
464 |
|
|
local time accept_time=-1;
|
465 |
|
|
|
466 |
|
|
local uvm_component initiator;
|
467 |
|
|
local uvm_tr_stream stream_handle;
|
468 |
|
|
local uvm_recorder tr_recorder;
|
469 |
|
|
|
470 |
|
|
endclass
|
471 |
|
|
|
472 |
|
|
|
473 |
|
|
//------------------------------------------------------------------------------
|
474 |
|
|
// IMPLEMENTATION
|
475 |
|
|
//------------------------------------------------------------------------------
|
476 |
|
|
|
477 |
|
|
|
478 |
|
|
// new
|
479 |
|
|
// ---
|
480 |
|
|
|
481 |
|
|
function uvm_transaction::new (string name="",
|
482 |
|
|
uvm_component initiator = null);
|
483 |
|
|
|
484 |
|
|
super.new(name);
|
485 |
|
|
this.initiator = initiator;
|
486 |
|
|
m_transaction_id = -1;
|
487 |
|
|
begin_event = events.get("begin");
|
488 |
|
|
end_event = events.get("end");
|
489 |
|
|
|
490 |
|
|
endfunction // uvm_transaction
|
491 |
|
|
|
492 |
|
|
|
493 |
|
|
// set_transaction_id
|
494 |
|
|
function void uvm_transaction::set_transaction_id(integer id);
|
495 |
|
|
m_transaction_id = id;
|
496 |
|
|
endfunction
|
497 |
|
|
|
498 |
|
|
// get_transaction_id
|
499 |
|
|
function integer uvm_transaction::get_transaction_id();
|
500 |
|
|
return (m_transaction_id);
|
501 |
|
|
endfunction
|
502 |
|
|
|
503 |
|
|
// set_initiator
|
504 |
|
|
// ------------
|
505 |
|
|
|
506 |
|
|
function void uvm_transaction::set_initiator(uvm_component initiator);
|
507 |
|
|
this.initiator = initiator;
|
508 |
|
|
endfunction
|
509 |
|
|
|
510 |
|
|
// get_initiator
|
511 |
|
|
// ------------
|
512 |
|
|
|
513 |
|
|
function uvm_component uvm_transaction::get_initiator();
|
514 |
|
|
return initiator;
|
515 |
|
|
endfunction
|
516 |
|
|
|
517 |
|
|
// get_event_pool
|
518 |
|
|
// --------------
|
519 |
|
|
|
520 |
|
|
function uvm_event_pool uvm_transaction::get_event_pool();
|
521 |
|
|
return events;
|
522 |
|
|
endfunction
|
523 |
|
|
|
524 |
|
|
|
525 |
|
|
// is_active
|
526 |
|
|
// ---------
|
527 |
|
|
|
528 |
|
|
function bit uvm_transaction::is_active();
|
529 |
|
|
return (end_time == -1);
|
530 |
|
|
endfunction
|
531 |
|
|
|
532 |
|
|
|
533 |
|
|
// get_begin_time
|
534 |
|
|
// --------------
|
535 |
|
|
|
536 |
|
|
function time uvm_transaction::get_begin_time ();
|
537 |
|
|
return begin_time;
|
538 |
|
|
endfunction
|
539 |
|
|
|
540 |
|
|
|
541 |
|
|
// get_end_time
|
542 |
|
|
// ------------
|
543 |
|
|
|
544 |
|
|
function time uvm_transaction::get_end_time ();
|
545 |
|
|
return end_time;
|
546 |
|
|
endfunction
|
547 |
|
|
|
548 |
|
|
|
549 |
|
|
// get_accept_time
|
550 |
|
|
// ---------------
|
551 |
|
|
|
552 |
|
|
function time uvm_transaction::get_accept_time ();
|
553 |
|
|
return accept_time;
|
554 |
|
|
endfunction
|
555 |
|
|
|
556 |
|
|
|
557 |
|
|
// do_accept_tr
|
558 |
|
|
// -------------
|
559 |
|
|
|
560 |
|
|
function void uvm_transaction::do_accept_tr();
|
561 |
|
|
return;
|
562 |
|
|
endfunction
|
563 |
|
|
|
564 |
|
|
|
565 |
|
|
// do_begin_tr
|
566 |
|
|
// ------------
|
567 |
|
|
|
568 |
|
|
function void uvm_transaction::do_begin_tr();
|
569 |
|
|
return;
|
570 |
|
|
endfunction
|
571 |
|
|
|
572 |
|
|
|
573 |
|
|
// do_end_tr
|
574 |
|
|
// ----------
|
575 |
|
|
|
576 |
|
|
function void uvm_transaction::do_end_tr();
|
577 |
|
|
return;
|
578 |
|
|
endfunction
|
579 |
|
|
|
580 |
|
|
// do_print
|
581 |
|
|
// --------
|
582 |
|
|
|
583 |
|
|
function void uvm_transaction::do_print (uvm_printer printer);
|
584 |
|
|
string str;
|
585 |
|
|
uvm_component tmp_initiator; //work around $swrite bug
|
586 |
|
|
super.do_print(printer);
|
587 |
|
|
if(accept_time != -1)
|
588 |
|
|
printer.print_time("accept_time", accept_time);
|
589 |
|
|
if(begin_time != -1)
|
590 |
|
|
printer.print_time("begin_time", begin_time);
|
591 |
|
|
if(end_time != -1)
|
592 |
|
|
printer.print_time("end_time", end_time);
|
593 |
|
|
if(initiator != null) begin
|
594 |
|
|
tmp_initiator = initiator;
|
595 |
|
|
$swrite(str,"@%0d", tmp_initiator.get_inst_id());
|
596 |
|
|
printer.print_generic("initiator", initiator.get_type_name(), -1, str);
|
597 |
|
|
end
|
598 |
|
|
endfunction
|
599 |
|
|
|
600 |
|
|
function void uvm_transaction::do_copy (uvm_object rhs);
|
601 |
|
|
uvm_transaction txn;
|
602 |
|
|
super.do_copy(rhs);
|
603 |
|
|
if(rhs == null) return;
|
604 |
|
|
if(!$cast(txn, rhs) ) return;
|
605 |
|
|
|
606 |
|
|
accept_time = txn.accept_time;
|
607 |
|
|
begin_time = txn.begin_time;
|
608 |
|
|
end_time = txn.end_time;
|
609 |
|
|
initiator = txn.initiator;
|
610 |
|
|
stream_handle = txn.stream_handle;
|
611 |
|
|
tr_recorder = txn.tr_recorder;
|
612 |
|
|
endfunction
|
613 |
|
|
|
614 |
|
|
// do_record
|
615 |
|
|
// ---------
|
616 |
|
|
|
617 |
|
|
function void uvm_transaction::do_record (uvm_recorder recorder);
|
618 |
|
|
string s;
|
619 |
|
|
super.do_record(recorder);
|
620 |
|
|
if(accept_time != -1)
|
621 |
|
|
recorder.record_field("accept_time", accept_time, $bits(accept_time), UVM_TIME);
|
622 |
|
|
if(initiator != null) begin
|
623 |
|
|
uvm_recursion_policy_enum p = recorder.policy;
|
624 |
|
|
recorder.policy = UVM_REFERENCE;
|
625 |
|
|
recorder.record_object("initiator", initiator);
|
626 |
|
|
recorder.policy = p;
|
627 |
|
|
end
|
628 |
|
|
endfunction
|
629 |
|
|
|
630 |
|
|
// get_tr_handle
|
631 |
|
|
// ---------
|
632 |
|
|
|
633 |
|
|
function integer uvm_transaction::get_tr_handle ();
|
634 |
|
|
if (tr_recorder != null)
|
635 |
|
|
return tr_recorder.get_handle();
|
636 |
|
|
else
|
637 |
|
|
return 0;
|
638 |
|
|
endfunction
|
639 |
|
|
|
640 |
|
|
|
641 |
|
|
// disable_recording
|
642 |
|
|
// -----------------
|
643 |
|
|
|
644 |
|
|
function void uvm_transaction::disable_recording ();
|
645 |
|
|
this.stream_handle = null;
|
646 |
|
|
endfunction
|
647 |
|
|
|
648 |
|
|
|
649 |
|
|
// enable_recording
|
650 |
|
|
// ----------------
|
651 |
|
|
|
652 |
|
|
function void uvm_transaction::enable_recording (uvm_tr_stream stream);
|
653 |
|
|
this.stream_handle = stream;
|
654 |
|
|
endfunction : enable_recording
|
655 |
|
|
|
656 |
|
|
// is_recording_enabled
|
657 |
|
|
// --------------------
|
658 |
|
|
|
659 |
|
|
function bit uvm_transaction::is_recording_enabled ();
|
660 |
|
|
return (this.stream_handle != null);
|
661 |
|
|
endfunction
|
662 |
|
|
|
663 |
|
|
|
664 |
|
|
// accept_tr
|
665 |
|
|
// ---------
|
666 |
|
|
|
667 |
|
|
function void uvm_transaction::accept_tr (time accept_time = 0);
|
668 |
|
|
uvm_event#(uvm_object) e;
|
669 |
|
|
|
670 |
|
|
if(accept_time != 0)
|
671 |
|
|
this.accept_time = accept_time;
|
672 |
|
|
else
|
673 |
|
|
this.accept_time = $realtime;
|
674 |
|
|
|
675 |
|
|
do_accept_tr();
|
676 |
|
|
e = events.get("accept");
|
677 |
|
|
|
678 |
|
|
if(e!=null)
|
679 |
|
|
e.trigger();
|
680 |
|
|
endfunction
|
681 |
|
|
|
682 |
|
|
// begin_tr
|
683 |
|
|
// -----------
|
684 |
|
|
|
685 |
|
|
function integer uvm_transaction::begin_tr (time begin_time=0);
|
686 |
|
|
return m_begin_tr(begin_time);
|
687 |
|
|
endfunction
|
688 |
|
|
|
689 |
|
|
// begin_child_tr
|
690 |
|
|
// --------------
|
691 |
|
|
|
692 |
|
|
//Use a parent handle of zero to link to the parent after begin
|
693 |
|
|
function integer uvm_transaction::begin_child_tr (time begin_time=0,
|
694 |
|
|
integer parent_handle=0);
|
695 |
|
|
return m_begin_tr(begin_time, parent_handle);
|
696 |
|
|
endfunction
|
697 |
|
|
|
698 |
|
|
// m_begin_tr
|
699 |
|
|
// -----------
|
700 |
|
|
|
701 |
|
|
function integer uvm_transaction::m_begin_tr (time begin_time=0,
|
702 |
|
|
integer parent_handle=0);
|
703 |
|
|
time tmp_time = (begin_time == 0) ? $realtime : begin_time;
|
704 |
|
|
uvm_recorder parent_recorder;
|
705 |
|
|
|
706 |
|
|
if (parent_handle != 0)
|
707 |
|
|
parent_recorder = uvm_recorder::get_recorder_from_handle(parent_handle);
|
708 |
|
|
|
709 |
|
|
// If we haven't ended the previous record, end it.
|
710 |
|
|
if (tr_recorder != null)
|
711 |
|
|
// Don't free the handle, someone else may be using it...
|
712 |
|
|
end_tr(tmp_time);
|
713 |
|
|
|
714 |
|
|
// May want to establish predecessor/successor relation
|
715 |
|
|
// (don't free handle until then)
|
716 |
|
|
if(is_recording_enabled()) begin
|
717 |
|
|
uvm_tr_database db = stream_handle.get_db();
|
718 |
|
|
|
719 |
|
|
this.end_time = -1;
|
720 |
|
|
this.begin_time = tmp_time;
|
721 |
|
|
|
722 |
|
|
if(parent_recorder == null)
|
723 |
|
|
tr_recorder = stream_handle.open_recorder(get_type_name(),
|
724 |
|
|
this.begin_time,
|
725 |
|
|
"Begin_No_Parent, Link");
|
726 |
|
|
else begin
|
727 |
|
|
tr_recorder = stream_handle.open_recorder(get_type_name(),
|
728 |
|
|
this.begin_time,
|
729 |
|
|
"Begin_End, Link");
|
730 |
|
|
|
731 |
|
|
if (tr_recorder != null)
|
732 |
|
|
db.establish_link(uvm_parent_child_link::get_link(parent_recorder, tr_recorder));
|
733 |
|
|
end
|
734 |
|
|
|
735 |
|
|
if (tr_recorder != null)
|
736 |
|
|
m_begin_tr = tr_recorder.get_handle();
|
737 |
|
|
else
|
738 |
|
|
m_begin_tr = 0;
|
739 |
|
|
end
|
740 |
|
|
else begin
|
741 |
|
|
tr_recorder = null;
|
742 |
|
|
this.end_time = -1;
|
743 |
|
|
this.begin_time = tmp_time;
|
744 |
|
|
|
745 |
|
|
m_begin_tr = 0;
|
746 |
|
|
end
|
747 |
|
|
|
748 |
|
|
do_begin_tr(); //execute callback before event trigger
|
749 |
|
|
|
750 |
|
|
begin_event.trigger();
|
751 |
|
|
|
752 |
|
|
endfunction
|
753 |
|
|
|
754 |
|
|
|
755 |
|
|
// end_tr
|
756 |
|
|
// ------
|
757 |
|
|
|
758 |
|
|
function void uvm_transaction::end_tr (time end_time=0, bit free_handle=1);
|
759 |
|
|
this.end_time = (end_time == 0) ? $realtime : end_time;
|
760 |
|
|
|
761 |
|
|
do_end_tr(); // Callback prior to actual ending of transaction
|
762 |
|
|
|
763 |
|
|
if(is_recording_enabled() && (tr_recorder != null)) begin
|
764 |
|
|
record(tr_recorder);
|
765 |
|
|
|
766 |
|
|
tr_recorder.close(this.end_time);
|
767 |
|
|
|
768 |
|
|
if(free_handle)
|
769 |
|
|
begin
|
770 |
|
|
// once freed, can no longer link to
|
771 |
|
|
tr_recorder.free();
|
772 |
|
|
end
|
773 |
|
|
end // if (is_active())
|
774 |
|
|
|
775 |
|
|
tr_recorder = null;
|
776 |
|
|
|
777 |
|
|
end_event.trigger();
|
778 |
|
|
endfunction
|
779 |
|
|
|
780 |
|
|
|