Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: ilupeuContextBase.vr | |
4 | // Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
5 | // 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
6 | // | |
7 | // * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
8 | // | |
9 | // This program is free software; you can redistribute it and/or modify | |
10 | // it under the terms of the GNU General Public License as published by | |
11 | // the Free Software Foundation; version 2 of the License. | |
12 | // | |
13 | // This program is distributed in the hope that it will be useful, | |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // GNU General Public License for more details. | |
17 | // | |
18 | // You should have received a copy of the GNU General Public License | |
19 | // along with this program; if not, write to the Free Software | |
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | // | |
22 | // For the avoidance of doubt, and except that if any non-GPL license | |
23 | // choice is available it will apply instead, Sun elects to use only | |
24 | // the General Public License version 2 (GPLv2) at this time for any | |
25 | // software where a choice of GPL license versions is made | |
26 | // available with the language indicating that GPLv2 or any later version | |
27 | // may be used, or where a choice of which version of the GPL is applied is | |
28 | // otherwise unspecified. | |
29 | // | |
30 | // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
31 | // CA 95054 USA or visit www.sun.com if you need additional information or | |
32 | // have any questions. | |
33 | // | |
34 | // ========== Copyright Header End ============================================ | |
35 | #include "CTContextBase.vrh" | |
36 | ||
37 | virtual class ilupeuContextBase extends CTContextBase { | |
38 | ||
39 | // -------------------------------------------------------- | |
40 | // Public Parameters | |
41 | // -------------------------------------------------------- | |
42 | //Number of strategies for each type | |
43 | integer tlpNumStrat, tlpStratDone, tlpStratNum; | |
44 | integer dllpNumStrat, dllpStratDone, dllpStratNum; | |
45 | ||
46 | //Min and ax issue delay values | |
47 | integer tlpMinDelay; | |
48 | integer tlpMaxDelay; | |
49 | integer dllpMinDelay; | |
50 | integer dllpMaxDelay; | |
51 | ||
52 | //Min and ax active strats values | |
53 | integer tlpMinActiveStrats; | |
54 | integer tlpMaxActiveStrats; | |
55 | integer dllpMinActiveStrats; | |
56 | integer dllpMaxActiveStrats; | |
57 | ||
58 | integer tlpHangDetect = 0; | |
59 | integer tlpWaitCount = 0; | |
60 | integer dllpHangDetect = 0; | |
61 | integer dllpWaitCount = 0; | |
62 | ||
63 | // -------------------------------------------------------- | |
64 | // Protected Members | |
65 | // -------------------------------------------------------- | |
66 | ||
67 | protected CSRCollection CSR; | |
68 | protected ReportClass Report; | |
69 | protected ilupeuPodClass Pod; | |
70 | protected ilupeuScenario Scenario; | |
71 | ||
72 | //Random Utilities | |
73 | FNXRandomUtil RandUtil; | |
74 | ||
75 | ||
76 | ||
77 | // -------------------------------------------------------- | |
78 | // Local Members | |
79 | // -------------------------------------------------------- | |
80 | ||
81 | ||
82 | // -------------------------------------------------------- | |
83 | // Methods | |
84 | // -------------------------------------------------------- | |
85 | ||
86 | // Constructor | |
87 | task new ( ReportClass _Report, | |
88 | CSRCollection _CSR, | |
89 | ilupeuPodClass _Pod , //Xactors | |
90 | ilupeuScenario _Scenario, //Test Parameters | |
91 | string Name = "" ); | |
92 | ||
93 | // Public Methods | |
94 | task ExecuteTlp(); | |
95 | task ExecuteDllp(); | |
96 | virtual function CTStrategyBase ProvideTlpStrategy(); | |
97 | virtual function CTStrategyBase ProvideDllpStrategy(); | |
98 | virtual function CTStrategyBase FinalizeTlpParms(CTStrategyBase FinalStrategy); | |
99 | virtual function CTStrategyBase FinalizeDllpParms(CTStrategyBase FinalStrategy); | |
100 | ||
101 | // Protected Methods | |
102 | protected task DelayIssueTlp(); | |
103 | protected task DelayIssueDllp(); | |
104 | } | |
105 | ||
106 | // Constructor | |
107 | task ilupeuContextBase::new ( ReportClass _Report, | |
108 | CSRCollection _CSR, | |
109 | ilupeuPodClass _Pod, | |
110 | ilupeuScenario _Scenario, | |
111 | string Name = "" ) | |
112 | { | |
113 | super.new( Name ); | |
114 | Report = _Report; | |
115 | CSR = _CSR; | |
116 | Pod = _Pod; | |
117 | Scenario = _Scenario; | |
118 | RandUtil = new( Report ); | |
119 | ||
120 | } | |
121 | ||
122 | function CTStrategyBase ilupeuContextBase::ProvideTlpStrategy() {} | |
123 | function CTStrategyBase ilupeuContextBase::ProvideDllpStrategy() {} | |
124 | function CTStrategyBase ilupeuContextBase::FinalizeTlpParms(CTStrategyBase FinalStrategy) {} | |
125 | function CTStrategyBase ilupeuContextBase::FinalizeDllpParms(CTStrategyBase FinalStrategy) {} | |
126 | ||
127 | ||
128 | task ilupeuContextBase::ExecuteTlp() { | |
129 | ||
130 | CTStrategyBase FinalTlpStrategy; | |
131 | ||
132 | ||
133 | for (tlpStratDone = 0, tlpStratNum=1; tlpStratNum<=tlpNumStrat; ++tlpStratNum) { | |
134 | ||
135 | // There are five distinct steps in setting up and launching a strategy thread. | |
136 | ||
137 | //Wait for a user-defined synchronization event | |
138 | DelayIssueTlp(); | |
139 | ||
140 | fork | |
141 | { | |
142 | // Step 1: | |
143 | FinalTlpStrategy = ProvideTlpStrategy(); | |
144 | ||
145 | // Step 2: | |
146 | FinalTlpStrategy = FinalizeTlpParms(FinalTlpStrategy); | |
147 | ||
148 | // Step 3: Not needed at this time | |
149 | //CheckParms(FinalTlpStrategy); | |
150 | ||
151 | // Step 4: | |
152 | // If it made it this far, give the strategy a unique identifier. | |
153 | FinalTlpStrategy.SetID({(ID.GetContextID()*10) + 0 }, tlpStratNum ); | |
154 | ||
155 | // Step 5: | |
156 | // Kick it off. | |
157 | FinalTlpStrategy.RunThread(); | |
158 | ++tlpStratDone; | |
159 | QuickReport( Report, | |
160 | RTYP_INFO, | |
161 | "%s ilupeuContextBase::ExecuteTlp() FinalTlpStrategy.RunThread() complete! tlpStratDone=%0d tlpNumStrat=%0d ",ID.GetString(),tlpStratDone,tlpNumStrat ); | |
162 | ||
163 | } | |
164 | join none | |
165 | } | |
166 | ||
167 | // This loop works like a breakable wait_child() and causes Execute | |
168 | // to block until all its strategies are complete. | |
169 | while ( tlpStratDone < tlpNumStrat ) { | |
170 | ||
171 | if (tlpHangDetect) { | |
172 | --tlpWaitCount; | |
173 | if (tlpWaitCount <= 0) | |
174 | error("Hang Detected In Context %s ExecuteTlp ID = %0d\n", Name, ID.GetContextID()); | |
175 | } | |
176 | ||
177 | @(posedge CLOCK); | |
178 | } | |
179 | ||
180 | QuickReport( Report,RTYP_INFO, "Context %s ID = %0d ExecuteTlp() complete!", | |
181 | Name, ID.GetContextID() ); | |
182 | } //End ExecuteTlp | |
183 | ||
184 | task ilupeuContextBase::DelayIssueTlp() | |
185 | { | |
186 | repeat (RandUtil.Rand32(tlpMinDelay,tlpMaxDelay)) @(posedge CLOCK); | |
187 | ||
188 | // Wait For ILUPEU TLP Stratey Threads to Free Up | |
189 | if ( tlpNumStrat != 0 ) { | |
190 | if ( (tlpStratNum - tlpStratDone) >= tlpMaxActiveStrats ) { | |
191 | while ( (tlpStratNum - tlpStratDone) > tlpMinActiveStrats) { | |
192 | @(posedge CLOCK); | |
193 | QuickReport(Report, RTYP_DEBUG_3, | |
194 | "%s: Context ID=%0d DelayIssueTlp()>WAITING tlpMinActiveStrats=%0d tlpMaxActiveStrats=%0d #TLP Strats Outstanding=%0d", | |
195 | Name, ID.GetContextID(), tlpMinActiveStrats, tlpMaxActiveStrats, | |
196 | (tlpStratNum - tlpStratDone) ); | |
197 | } | |
198 | } | |
199 | } | |
200 | } //End DelayIssueTlp | |
201 | ||
202 | ||
203 | ||
204 | task ilupeuContextBase::ExecuteDllp() { | |
205 | ||
206 | integer dllpStratDone, dllpStratNum; | |
207 | CTStrategyBase FinalDllpStrategy; | |
208 | ||
209 | ||
210 | for (dllpStratDone = 0, dllpStratNum=1; dllpStratNum<=dllpNumStrat; ++dllpStratNum) { | |
211 | ||
212 | // There are five distinct steps in setting up and launching a strategy thread. | |
213 | ||
214 | //Wait for a user-defined synchronization event | |
215 | DelayIssueDllp(); | |
216 | ||
217 | fork | |
218 | { | |
219 | // Step 1: | |
220 | FinalDllpStrategy = ProvideDllpStrategy(); | |
221 | ||
222 | // Step 2: | |
223 | FinalDllpStrategy = FinalizeDllpParms(FinalDllpStrategy); | |
224 | ||
225 | // Step 3: Not needed at this time | |
226 | //CheckParms(FinalDllpStrategy); | |
227 | ||
228 | // Step 4: | |
229 | // If it made it this far, give the strategy a unique identifier. | |
230 | FinalDllpStrategy.SetID({(ID.GetContextID()*10) + 1 }, dllpStratNum ); | |
231 | ||
232 | // Step 5: | |
233 | // Kick it off. | |
234 | FinalDllpStrategy.RunThread(); | |
235 | ++dllpStratDone; | |
236 | QuickReport( Report, | |
237 | RTYP_INFO, | |
238 | "%s ilupeuContextBase::ExecuteDllp() FinalDllpStrategy.RunThread() complete! dllpStratDone=%0d dllpNumStrat=%0d ",ID.GetString(),dllpStratDone,dllpNumStrat ); | |
239 | ||
240 | } | |
241 | join none | |
242 | } | |
243 | ||
244 | // This loop works like a breakable wait_child() and causes Execute | |
245 | // to block until all its strategies are complete. | |
246 | while ( dllpStratDone < dllpNumStrat ) { | |
247 | ||
248 | if (dllpHangDetect) { | |
249 | --dllpWaitCount; | |
250 | if (dllpWaitCount <= 0) | |
251 | error("Hang Detected In Context %s ExecuteDllp ID = %0d\n", Name, ID.GetContextID()); | |
252 | } | |
253 | ||
254 | @(posedge CLOCK); | |
255 | } | |
256 | ||
257 | QuickReport( Report,RTYP_INFO, "Context %s ID = %0d ExecuteDllp() complete!", | |
258 | Name, ID.GetContextID() ); | |
259 | } //End ExecuteDllp | |
260 | ||
261 | task ilupeuContextBase::DelayIssueDllp() | |
262 | { | |
263 | repeat (RandUtil.Rand32(dllpMinDelay,dllpMaxDelay)) @(posedge CLOCK); | |
264 | ||
265 | // Wait For ILUPEU DLLP Stratey Threads to Free Up | |
266 | if ( dllpNumStrat != 0 ) { | |
267 | if ( (dllpStratNum - dllpStratDone) >= dllpMaxActiveStrats ) { | |
268 | while ( (dllpStratNum - dllpStratDone) > dllpMinActiveStrats) { | |
269 | @(posedge CLOCK); | |
270 | QuickReport(Report, RTYP_DEBUG_3, | |
271 | "%s: Context ID=%0d DelayIssueDllp()>WAITING dllpMinActiveStrats=%0d dllpMaxActiveStrats=%0d #DLLP Strats Outstanding=%0d", | |
272 | Name, ID.GetContextID(), dllpMinActiveStrats, dllpMaxActiveStrats, | |
273 | (dllpStratNum - dllpStratDone) ); | |
274 | } | |
275 | } | |
276 | } | |
277 | } //End DelayIssueDllp |