1 |
16 |
HanySalah |
//
|
2 |
|
|
//----------------------------------------------------------------------
|
3 |
|
|
// Copyright 2007-2011 Mentor Graphics Corporation
|
4 |
|
|
// Copyright 2007-2010 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 |
|
|
`ifndef UVM_TLM_IMPS_SVH
|
24 |
|
|
`define UVM_TLM_IMPS_SVH
|
25 |
|
|
|
26 |
|
|
//
|
27 |
|
|
// These IMP macros define implementations of the uvm_*_port, uvm_*_export,
|
28 |
|
|
// and uvm_*_imp ports.
|
29 |
|
|
//
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
//---------------------------------------------------------------
|
33 |
|
|
// Macros for implementations of UVM ports and exports
|
34 |
|
|
|
35 |
|
|
/*
|
36 |
|
|
`define UVM_BLOCKING_PUT_IMP(imp, TYPE, arg) \
|
37 |
|
|
task put (TYPE arg); \
|
38 |
|
|
if (m_imp_list.size()) == 0) begin \
|
39 |
|
|
uvm_report_error("Port Not Bound","Blocking put to unbound port will wait forever.", UVM_NONE);
|
40 |
|
|
@imp;
|
41 |
|
|
end
|
42 |
|
|
if (bcast_mode) begin \
|
43 |
|
|
if (m_imp_list.size()) > 1) \
|
44 |
|
|
fork
|
45 |
|
|
begin
|
46 |
|
|
foreach (m_imp_list[index]) \
|
47 |
|
|
fork \
|
48 |
|
|
automatic int i = index; \
|
49 |
|
|
begin m_imp_list[i].put(arg); end \
|
50 |
|
|
join_none \
|
51 |
|
|
wait fork; \
|
52 |
|
|
end \
|
53 |
|
|
join \
|
54 |
|
|
else \
|
55 |
|
|
m_imp_list[0].put(arg); \
|
56 |
|
|
end \
|
57 |
|
|
else \
|
58 |
|
|
if (imp != null) \
|
59 |
|
|
imp.put(arg); \
|
60 |
|
|
endtask \
|
61 |
|
|
|
62 |
|
|
`define UVM_NONBLOCKING_PUT_IMP(imp, TYPE, arg) \
|
63 |
|
|
function bit try_put(input TYPE arg); \
|
64 |
|
|
if (bcast_mode) begin \
|
65 |
|
|
if (!can_put()) \
|
66 |
|
|
return 0; \
|
67 |
|
|
foreach (m_imp_list[index]) \
|
68 |
|
|
void'(m_imp_list[index].try_put(arg)); \
|
69 |
|
|
return 1; \
|
70 |
|
|
end \
|
71 |
|
|
if (imp != null) \
|
72 |
|
|
return imp.try_put(arg)); \
|
73 |
|
|
return 0; \
|
74 |
|
|
endfunction \
|
75 |
|
|
\
|
76 |
|
|
function bit can_put(); \
|
77 |
|
|
if (bcast_mode) begin \
|
78 |
|
|
if (m_imp_list.size()) begin \
|
79 |
|
|
foreach (m_imp_list[index]) begin \
|
80 |
|
|
if (!m_imp_list[index].can_put() \
|
81 |
|
|
return 0; \
|
82 |
|
|
end \
|
83 |
|
|
return 1; \
|
84 |
|
|
end \
|
85 |
|
|
return 0; \
|
86 |
|
|
end \
|
87 |
|
|
if (imp != null) \
|
88 |
|
|
return imp.can_put(); \
|
89 |
|
|
return 0; \
|
90 |
|
|
endfunction
|
91 |
|
|
|
92 |
|
|
*/
|
93 |
|
|
|
94 |
|
|
//-----------------------------------------------------------------------
|
95 |
|
|
// TLM imp implementations
|
96 |
|
|
|
97 |
|
|
`define UVM_BLOCKING_PUT_IMP(imp, TYPE, arg) \
|
98 |
|
|
task put (TYPE arg); \
|
99 |
|
|
imp.put(arg); \
|
100 |
|
|
endtask
|
101 |
|
|
|
102 |
|
|
`define UVM_NONBLOCKING_PUT_IMP(imp, TYPE, arg) \
|
103 |
|
|
function bit try_put (TYPE arg); \
|
104 |
|
|
return imp.try_put(arg); \
|
105 |
|
|
endfunction \
|
106 |
|
|
function bit can_put(); \
|
107 |
|
|
return imp.can_put(); \
|
108 |
|
|
endfunction
|
109 |
|
|
|
110 |
|
|
`define UVM_BLOCKING_GET_IMP(imp, TYPE, arg) \
|
111 |
|
|
task get (output TYPE arg); \
|
112 |
|
|
imp.get(arg); \
|
113 |
|
|
endtask
|
114 |
|
|
|
115 |
|
|
`define UVM_NONBLOCKING_GET_IMP(imp, TYPE, arg) \
|
116 |
|
|
function bit try_get (output TYPE arg); \
|
117 |
|
|
return imp.try_get(arg); \
|
118 |
|
|
endfunction \
|
119 |
|
|
function bit can_get(); \
|
120 |
|
|
return imp.can_get(); \
|
121 |
|
|
endfunction
|
122 |
|
|
|
123 |
|
|
`define UVM_BLOCKING_PEEK_IMP(imp, TYPE, arg) \
|
124 |
|
|
task peek (output TYPE arg); \
|
125 |
|
|
imp.peek(arg); \
|
126 |
|
|
endtask
|
127 |
|
|
|
128 |
|
|
`define UVM_NONBLOCKING_PEEK_IMP(imp, TYPE, arg) \
|
129 |
|
|
function bit try_peek (output TYPE arg); \
|
130 |
|
|
return imp.try_peek(arg); \
|
131 |
|
|
endfunction \
|
132 |
|
|
function bit can_peek(); \
|
133 |
|
|
return imp.can_peek(); \
|
134 |
|
|
endfunction
|
135 |
|
|
|
136 |
|
|
`define UVM_BLOCKING_TRANSPORT_IMP(imp, REQ, RSP, req_arg, rsp_arg) \
|
137 |
|
|
task transport (REQ req_arg, output RSP rsp_arg); \
|
138 |
|
|
imp.transport(req_arg, rsp_arg); \
|
139 |
|
|
endtask
|
140 |
|
|
|
141 |
|
|
`define UVM_NONBLOCKING_TRANSPORT_IMP(imp, REQ, RSP, req_arg, rsp_arg) \
|
142 |
|
|
function bit nb_transport (REQ req_arg, output RSP rsp_arg); \
|
143 |
|
|
return imp.nb_transport(req_arg, rsp_arg); \
|
144 |
|
|
endfunction
|
145 |
|
|
|
146 |
|
|
`define UVM_PUT_IMP(imp, TYPE, arg) \
|
147 |
|
|
`UVM_BLOCKING_PUT_IMP(imp, TYPE, arg) \
|
148 |
|
|
`UVM_NONBLOCKING_PUT_IMP(imp, TYPE, arg)
|
149 |
|
|
|
150 |
|
|
`define UVM_GET_IMP(imp, TYPE, arg) \
|
151 |
|
|
`UVM_BLOCKING_GET_IMP(imp, TYPE, arg) \
|
152 |
|
|
`UVM_NONBLOCKING_GET_IMP(imp, TYPE, arg)
|
153 |
|
|
|
154 |
|
|
`define UVM_PEEK_IMP(imp, TYPE, arg) \
|
155 |
|
|
`UVM_BLOCKING_PEEK_IMP(imp, TYPE, arg) \
|
156 |
|
|
`UVM_NONBLOCKING_PEEK_IMP(imp, TYPE, arg)
|
157 |
|
|
|
158 |
|
|
`define UVM_BLOCKING_GET_PEEK_IMP(imp, TYPE, arg) \
|
159 |
|
|
`UVM_BLOCKING_GET_IMP(imp, TYPE, arg) \
|
160 |
|
|
`UVM_BLOCKING_PEEK_IMP(imp, TYPE, arg)
|
161 |
|
|
|
162 |
|
|
`define UVM_NONBLOCKING_GET_PEEK_IMP(imp, TYPE, arg) \
|
163 |
|
|
`UVM_NONBLOCKING_GET_IMP(imp, TYPE, arg) \
|
164 |
|
|
`UVM_NONBLOCKING_PEEK_IMP(imp, TYPE, arg)
|
165 |
|
|
|
166 |
|
|
`define UVM_GET_PEEK_IMP(imp, TYPE, arg) \
|
167 |
|
|
`UVM_BLOCKING_GET_PEEK_IMP(imp, TYPE, arg) \
|
168 |
|
|
`UVM_NONBLOCKING_GET_PEEK_IMP(imp, TYPE, arg)
|
169 |
|
|
|
170 |
|
|
`define UVM_TRANSPORT_IMP(imp, REQ, RSP, req_arg, rsp_arg) \
|
171 |
|
|
`UVM_BLOCKING_TRANSPORT_IMP(imp, REQ, RSP, req_arg, rsp_arg) \
|
172 |
|
|
`UVM_NONBLOCKING_TRANSPORT_IMP(imp, REQ, RSP, req_arg, rsp_arg)
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
`define UVM_TLM_GET_TYPE_NAME(NAME) \
|
177 |
|
|
virtual function string get_type_name(); \
|
178 |
|
|
return NAME; \
|
179 |
|
|
endfunction
|
180 |
|
|
|
181 |
|
|
`define UVM_PORT_COMMON(MASK,TYPE_NAME) \
|
182 |
|
|
function new (string name, uvm_component parent, \
|
183 |
|
|
int min_size=1, int max_size=1); \
|
184 |
|
|
super.new (name, parent, UVM_PORT, min_size, max_size); \
|
185 |
|
|
m_if_mask = MASK; \
|
186 |
|
|
endfunction \
|
187 |
|
|
`UVM_TLM_GET_TYPE_NAME(TYPE_NAME)
|
188 |
|
|
|
189 |
|
|
`define UVM_SEQ_PORT(MASK,TYPE_NAME) \
|
190 |
|
|
function new (string name, uvm_component parent, \
|
191 |
|
|
int min_size=0, int max_size=1); \
|
192 |
|
|
super.new (name, parent, UVM_PORT, min_size, max_size); \
|
193 |
|
|
m_if_mask = MASK; \
|
194 |
|
|
endfunction \
|
195 |
|
|
`UVM_TLM_GET_TYPE_NAME(TYPE_NAME)
|
196 |
|
|
|
197 |
|
|
`define UVM_EXPORT_COMMON(MASK,TYPE_NAME) \
|
198 |
|
|
function new (string name, uvm_component parent, \
|
199 |
|
|
int min_size=1, int max_size=1); \
|
200 |
|
|
super.new (name, parent, UVM_EXPORT, min_size, max_size); \
|
201 |
|
|
m_if_mask = MASK; \
|
202 |
|
|
endfunction \
|
203 |
|
|
`UVM_TLM_GET_TYPE_NAME(TYPE_NAME)
|
204 |
|
|
|
205 |
|
|
`define UVM_IMP_COMMON(MASK,TYPE_NAME,IMP) \
|
206 |
|
|
local IMP m_imp; \
|
207 |
|
|
function new (string name, IMP imp); \
|
208 |
|
|
super.new (name, imp, UVM_IMPLEMENTATION, 1, 1); \
|
209 |
|
|
m_imp = imp; \
|
210 |
|
|
m_if_mask = MASK; \
|
211 |
|
|
endfunction \
|
212 |
|
|
`UVM_TLM_GET_TYPE_NAME(TYPE_NAME)
|
213 |
|
|
|
214 |
|
|
`define UVM_MS_IMP_COMMON(MASK,TYPE_NAME) \
|
215 |
|
|
local this_req_type m_req_imp; \
|
216 |
|
|
local this_rsp_type m_rsp_imp; \
|
217 |
|
|
function new (string name, this_imp_type imp, \
|
218 |
|
|
this_req_type req_imp = null, this_rsp_type rsp_imp = null); \
|
219 |
|
|
super.new (name, imp, UVM_IMPLEMENTATION, 1, 1); \
|
220 |
|
|
if(req_imp==null) $cast(req_imp, imp); \
|
221 |
|
|
if(rsp_imp==null) $cast(rsp_imp, imp); \
|
222 |
|
|
m_req_imp = req_imp; \
|
223 |
|
|
m_rsp_imp = rsp_imp; \
|
224 |
|
|
m_if_mask = MASK; \
|
225 |
|
|
endfunction \
|
226 |
|
|
`UVM_TLM_GET_TYPE_NAME(TYPE_NAME)
|
227 |
|
|
|
228 |
|
|
`endif
|