1 |
16 |
HanySalah |
//----------------------------------------------------------------------
|
2 |
|
|
// Copyright 2007-2011 Mentor Graphics Corporation
|
3 |
|
|
// Copyright 2007-2010 Cadence Design Systems, Inc.
|
4 |
|
|
// Copyright 2010 Synopsys, Inc.
|
5 |
|
|
// Copyright 2013 Cisco Systems, 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 |
|
|
//
|
26 |
|
|
// CLASS: uvm_sequence #(REQ,RSP)
|
27 |
|
|
//
|
28 |
|
|
// The uvm_sequence class provides the interfaces necessary in order to create
|
29 |
|
|
// streams of sequence items and/or other sequences.
|
30 |
|
|
//
|
31 |
|
|
//------------------------------------------------------------------------------
|
32 |
|
|
|
33 |
|
|
virtual class uvm_sequence #(type REQ = uvm_sequence_item,
|
34 |
|
|
type RSP = REQ) extends uvm_sequence_base;
|
35 |
|
|
|
36 |
|
|
typedef uvm_sequencer_param_base #(REQ, RSP) sequencer_t;
|
37 |
|
|
|
38 |
|
|
sequencer_t param_sequencer;
|
39 |
|
|
|
40 |
|
|
// Variable: req
|
41 |
|
|
//
|
42 |
|
|
// The sequence contains a field of the request type called req. The user
|
43 |
|
|
// can use this field, if desired, or create another field to use. The
|
44 |
|
|
// default ~do_print~ will print this field.
|
45 |
|
|
REQ req;
|
46 |
|
|
|
47 |
|
|
// Variable: rsp
|
48 |
|
|
//
|
49 |
|
|
// The sequence contains a field of the response type called rsp. The user
|
50 |
|
|
// can use this field, if desired, or create another field to use. The
|
51 |
|
|
// default ~do_print~ will print this field.
|
52 |
|
|
RSP rsp;
|
53 |
|
|
|
54 |
|
|
// Function: new
|
55 |
|
|
//
|
56 |
|
|
// Creates and initializes a new sequence object.
|
57 |
|
|
|
58 |
|
|
function new (string name = "uvm_sequence");
|
59 |
|
|
super.new(name);
|
60 |
|
|
endfunction
|
61 |
|
|
|
62 |
|
|
// Function: send_request
|
63 |
|
|
//
|
64 |
|
|
// This method will send the request item to the sequencer, which will forward
|
65 |
|
|
// it to the driver. If the rerandomize bit is set, the item will be
|
66 |
|
|
// randomized before being sent to the driver. The send_request function may
|
67 |
|
|
// only be called after returns.
|
68 |
|
|
|
69 |
|
|
function void send_request(uvm_sequence_item request, bit rerandomize = 0);
|
70 |
|
|
REQ m_request;
|
71 |
|
|
|
72 |
|
|
if (m_sequencer == null) begin
|
73 |
|
|
uvm_report_fatal("SSENDREQ", "Null m_sequencer reference", UVM_NONE);
|
74 |
|
|
end
|
75 |
|
|
if (!$cast(m_request, request)) begin
|
76 |
|
|
uvm_report_fatal("SSENDREQ", "Failure to cast uvm_sequence_item to request", UVM_NONE);
|
77 |
|
|
end
|
78 |
|
|
m_sequencer.send_request(this, m_request, rerandomize);
|
79 |
|
|
endfunction
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
// Function: get_current_item
|
83 |
|
|
//
|
84 |
|
|
// Returns the request item currently being executed by the sequencer. If the
|
85 |
|
|
// sequencer is not currently executing an item, this method will return ~null~.
|
86 |
|
|
//
|
87 |
|
|
// The sequencer is executing an item from the time that get_next_item or peek
|
88 |
|
|
// is called until the time that get or item_done is called.
|
89 |
|
|
//
|
90 |
|
|
// Note that a driver that only calls get will never show a current item,
|
91 |
|
|
// since the item is completed at the same time as it is requested.
|
92 |
|
|
|
93 |
|
|
function REQ get_current_item();
|
94 |
|
|
if (!$cast(param_sequencer, m_sequencer))
|
95 |
|
|
uvm_report_fatal("SGTCURR", "Failure to cast m_sequencer to the parameterized sequencer", UVM_NONE);
|
96 |
|
|
return (param_sequencer.get_current_item());
|
97 |
|
|
endfunction
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
// Task: get_response
|
101 |
|
|
//
|
102 |
|
|
// By default, sequences must retrieve responses by calling get_response.
|
103 |
|
|
// If no transaction_id is specified, this task will return the next response
|
104 |
|
|
// sent to this sequence. If no response is available in the response queue,
|
105 |
|
|
// the method will block until a response is received.
|
106 |
|
|
//
|
107 |
|
|
// If a transaction_id is parameter is specified, the task will block until
|
108 |
|
|
// a response with that transaction_id is received in the response queue.
|
109 |
|
|
//
|
110 |
|
|
// The default size of the response queue is 8. The get_response method must
|
111 |
|
|
// be called soon enough to avoid an overflow of the response queue to prevent
|
112 |
|
|
// responses from being dropped.
|
113 |
|
|
//
|
114 |
|
|
// If a response is dropped in the response queue, an error will be reported
|
115 |
|
|
// unless the error reporting is disabled via
|
116 |
|
|
// set_response_queue_error_report_disabled.
|
117 |
|
|
|
118 |
|
|
virtual task get_response(output RSP response, input int transaction_id = -1);
|
119 |
|
|
uvm_sequence_item rsp;
|
120 |
|
|
get_base_response( rsp, transaction_id);
|
121 |
|
|
$cast(response,rsp);
|
122 |
|
|
endtask
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
// Function- put_response
|
127 |
|
|
//
|
128 |
|
|
// Internal method.
|
129 |
|
|
|
130 |
|
|
virtual function void put_response(uvm_sequence_item response_item);
|
131 |
|
|
RSP response;
|
132 |
|
|
if (!$cast(response, response_item)) begin
|
133 |
|
|
uvm_report_fatal("PUTRSP", "Failure to cast response in put_response", UVM_NONE);
|
134 |
|
|
end
|
135 |
|
|
put_base_response(response_item);
|
136 |
|
|
endfunction
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
// Function- do_print
|
140 |
|
|
//
|
141 |
|
|
function void do_print (uvm_printer printer);
|
142 |
|
|
super.do_print(printer);
|
143 |
|
|
printer.print_object("req", req);
|
144 |
|
|
printer.print_object("rsp", rsp);
|
145 |
|
|
endfunction
|
146 |
|
|
|
147 |
|
|
endclass
|