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 |
|
|
// Copyright 2013 NVIDIA Corporation
|
7 |
|
|
// All Rights Reserved Worldwide
|
8 |
|
|
//
|
9 |
|
|
// Licensed under the Apache License, Version 2.0 (the
|
10 |
|
|
// "License"); you may not use this file except in
|
11 |
|
|
// compliance with the License. You may obtain a copy of
|
12 |
|
|
// the License at
|
13 |
|
|
//
|
14 |
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
15 |
|
|
//
|
16 |
|
|
// Unless required by applicable law or agreed to in
|
17 |
|
|
// writing, software distributed under the License is
|
18 |
|
|
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
19 |
|
|
// CONDITIONS OF ANY KIND, either express or implied. See
|
20 |
|
|
// the License for the specific language governing
|
21 |
|
|
// permissions and limitations under the License.
|
22 |
|
|
//----------------------------------------------------------------------
|
23 |
|
|
|
24 |
|
|
//------------------------------------------------------------------------------
|
25 |
|
|
//
|
26 |
|
|
// Class: uvm_task_phase
|
27 |
|
|
//
|
28 |
|
|
//------------------------------------------------------------------------------
|
29 |
|
|
// Base class for all task phases.
|
30 |
|
|
// It forks a call to
|
31 |
|
|
// for each component in the hierarchy.
|
32 |
|
|
//
|
33 |
|
|
// The completion of the task does not imply, nor is it required for,
|
34 |
|
|
// the end of phase. Once the phase completes, any remaining forked
|
35 |
|
|
// threads are forcibly and immediately killed.
|
36 |
|
|
//
|
37 |
|
|
// By default, the way for a task phase to extend over time is if there is
|
38 |
|
|
// at least one component that raises an objection.
|
39 |
|
|
//| class my_comp extends uvm_component;
|
40 |
|
|
//| task main_phase(uvm_phase phase);
|
41 |
|
|
//| phase.raise_objection(this, "Applying stimulus")
|
42 |
|
|
//| ...
|
43 |
|
|
//| phase.drop_objection(this, "Applied enough stimulus")
|
44 |
|
|
//| endtask
|
45 |
|
|
//| endclass
|
46 |
|
|
//
|
47 |
|
|
//
|
48 |
|
|
// There is however one scenario wherein time advances within a task-based phase
|
49 |
|
|
// without any objections to the phase being raised. If two (or more) phases
|
50 |
|
|
// share a common successor, such as the and the
|
51 |
|
|
// sharing the as a successor,
|
52 |
|
|
// then phase advancement is delayed until all predecessors of the common
|
53 |
|
|
// successor are ready to proceed. Because of this, it is possible for time to
|
54 |
|
|
// advance between and
|
55 |
|
|
// of a task phase without any participants in the phase raising an objection.
|
56 |
|
|
//
|
57 |
|
|
|
58 |
|
|
virtual class uvm_task_phase extends uvm_phase;
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
// Function: new
|
62 |
|
|
//
|
63 |
|
|
// Create a new instance of a task-based phase
|
64 |
|
|
//
|
65 |
|
|
function new(string name);
|
66 |
|
|
super.new(name,UVM_PHASE_IMP);
|
67 |
|
|
endfunction
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
// Function: traverse
|
71 |
|
|
//
|
72 |
|
|
// Traverses the component tree in bottom-up order, calling for
|
73 |
|
|
// each component. The actual order for task-based phases doesn't really
|
74 |
|
|
// matter, as each component task is executed in a separate process whose
|
75 |
|
|
// starting order is not deterministic.
|
76 |
|
|
//
|
77 |
|
|
virtual function void traverse(uvm_component comp,
|
78 |
|
|
uvm_phase phase,
|
79 |
|
|
uvm_phase_state state);
|
80 |
|
|
phase.m_num_procs_not_yet_returned = 0;
|
81 |
|
|
m_traverse(comp, phase, state);
|
82 |
|
|
endfunction
|
83 |
|
|
|
84 |
|
|
function void m_traverse(uvm_component comp,
|
85 |
|
|
uvm_phase phase,
|
86 |
|
|
uvm_phase_state state);
|
87 |
|
|
string name;
|
88 |
|
|
uvm_domain phase_domain =phase.get_domain();
|
89 |
|
|
uvm_domain comp_domain = comp.get_domain();
|
90 |
|
|
uvm_sequencer_base seqr;
|
91 |
|
|
|
92 |
|
|
if (comp.get_first_child(name))
|
93 |
|
|
do
|
94 |
|
|
m_traverse(comp.get_child(name), phase, state);
|
95 |
|
|
while(comp.get_next_child(name));
|
96 |
|
|
|
97 |
|
|
if (m_phase_trace)
|
98 |
|
|
`uvm_info("PH_TRACE",$sformatf("topdown-phase phase=%s state=%s comp=%s comp.domain=%s phase.domain=%s",
|
99 |
|
|
phase.get_name(), state.name(), comp.get_full_name(),comp_domain.get_name(),phase_domain.get_name()),
|
100 |
|
|
UVM_DEBUG)
|
101 |
|
|
|
102 |
|
|
if (phase_domain == uvm_domain::get_common_domain() ||
|
103 |
|
|
phase_domain == comp_domain) begin
|
104 |
|
|
case (state)
|
105 |
|
|
UVM_PHASE_STARTED: begin
|
106 |
|
|
comp.m_current_phase = phase;
|
107 |
|
|
comp.m_apply_verbosity_settings(phase);
|
108 |
|
|
comp.phase_started(phase);
|
109 |
|
|
if ($cast(seqr, comp))
|
110 |
|
|
seqr.start_phase_sequence(phase);
|
111 |
|
|
end
|
112 |
|
|
UVM_PHASE_EXECUTING: begin
|
113 |
|
|
uvm_phase ph = this;
|
114 |
|
|
if (comp.m_phase_imps.exists(this))
|
115 |
|
|
ph = comp.m_phase_imps[this];
|
116 |
|
|
ph.execute(comp, phase);
|
117 |
|
|
end
|
118 |
|
|
UVM_PHASE_READY_TO_END: begin
|
119 |
|
|
comp.phase_ready_to_end(phase);
|
120 |
|
|
end
|
121 |
|
|
UVM_PHASE_ENDED: begin
|
122 |
|
|
if ($cast(seqr, comp))
|
123 |
|
|
seqr.stop_phase_sequence(phase);
|
124 |
|
|
comp.phase_ended(phase);
|
125 |
|
|
comp.m_current_phase = null;
|
126 |
|
|
end
|
127 |
|
|
default:
|
128 |
|
|
`uvm_fatal("PH_BADEXEC","task phase traverse internal error")
|
129 |
|
|
endcase
|
130 |
|
|
end
|
131 |
|
|
|
132 |
|
|
endfunction
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
// Function: execute
|
136 |
|
|
//
|
137 |
|
|
// Fork the task-based phase ~phase~ for the component ~comp~.
|
138 |
|
|
//
|
139 |
|
|
virtual function void execute(uvm_component comp,
|
140 |
|
|
uvm_phase phase);
|
141 |
|
|
|
142 |
|
|
fork
|
143 |
|
|
begin
|
144 |
|
|
process proc;
|
145 |
|
|
|
146 |
|
|
// reseed this process for random stability
|
147 |
|
|
proc = process::self();
|
148 |
|
|
proc.srandom(uvm_create_random_seed(phase.get_type_name(), comp.get_full_name()));
|
149 |
|
|
|
150 |
|
|
phase.m_num_procs_not_yet_returned++;
|
151 |
|
|
|
152 |
|
|
exec_task(comp,phase);
|
153 |
|
|
|
154 |
|
|
phase.m_num_procs_not_yet_returned--;
|
155 |
|
|
|
156 |
|
|
end
|
157 |
|
|
join_none
|
158 |
|
|
|
159 |
|
|
endfunction
|
160 |
|
|
endclass
|
161 |
|
|
|