Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: N2PEUCtxBase.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 | class PEUCtxBase extends CTContextBase | |
36 | { | |
37 | PEUTestEnv f_env; // Our test environment | |
38 | integer StratMax; // How many strategies in parallel, 32? | |
39 | bit StratStop; // Set this to one to drain the strats | |
40 | bit StratPause; // Set this to pause the context | |
41 | integer _stratNum; // The number of strategies launched | |
42 | ||
43 | public PECParamMode _IPDelay_mode = e_random; | |
44 | public integer _IPDelay_fixed = 1; | |
45 | public integer _IPDelay_min = 1; | |
46 | public integer _IPDelay_max = 15; | |
47 | ||
48 | task new( string a_name, PEUTestEnv a_env ) | |
49 | { | |
50 | super.new(a_name); | |
51 | f_env = a_env; | |
52 | _stratNum = 0; | |
53 | StratMax = 32; | |
54 | StratStop = 0; | |
55 | StratPause = 0; | |
56 | } | |
57 | ||
58 | task Execute() | |
59 | { | |
60 | super.Execute(); | |
61 | //Delay to allow death spiral to finish if needed | |
62 | repeat( 20 ) @(posedge CLOCK); | |
63 | } | |
64 | ||
65 | virtual protected function CTStrategyBase ProvideStrategy() | |
66 | { | |
67 | error( "PEUCtxBase/ProvideStrategy has been called?!?\n" ); | |
68 | ProvideStrategy = null; | |
69 | } | |
70 | ||
71 | virtual protected function CTStrategyBase FinalizeParms( CTStrategyBase a_strategy ) | |
72 | { | |
73 | FinalizeParms = a_strategy; | |
74 | } | |
75 | ||
76 | ||
77 | protected task DelayIssue() | |
78 | { | |
79 | integer IPDelay; | |
80 | ||
81 | // ****************************************************************** | |
82 | // Gotta wait if we already have enough strategies | |
83 | // ****************************************************************** | |
84 | while (((( this._stratNum + 1 ) - this.StratDone) > this.StratMax ) || | |
85 | (this.StratPause == 1)) { | |
86 | ||
87 | @(posedge CLOCK); | |
88 | } | |
89 | ||
90 | ||
91 | // ****************************************************************** | |
92 | // Determine the IP Delay. | |
93 | // ****************************************************************** | |
94 | if (this._IPDelay_mode === e_random) | |
95 | IPDelay = urandom_range(this._IPDelay_max, this._IPDelay_min); | |
96 | ||
97 | else /* if (this._IPDelay_mode === e_fixed) */ | |
98 | IPDelay = this._IPDelay_fixed; | |
99 | ||
100 | ||
101 | // ****************************************************************** | |
102 | // Wait the number of cycles specified by the IP Delay. | |
103 | // ****************************************************************** | |
104 | if (this.StratStop === 1'b0) | |
105 | repeat (IPDelay) @(posedge CLOCK); | |
106 | ||
107 | this._stratNum = this._stratNum + 1; | |
108 | } | |
109 | ||
110 | ||
111 | public task pause() | |
112 | { | |
113 | this.StratPause = 1; | |
114 | } | |
115 | ||
116 | public task unpause() | |
117 | { | |
118 | this.StratPause = 0; | |
119 | } | |
120 | ||
121 | public task waitUntilIdle() | |
122 | { | |
123 | integer i; | |
124 | i = 1; | |
125 | while (this._stratNum > this.StratDone) { | |
126 | if ( (i % 100) == 0 ) | |
127 | printf("PEUCtxBase::waitUntilIdle this._stratNum=%0d this.StratDone=%0d\n", this._stratNum, this.StratDone); | |
128 | @(posedge CLOCK); | |
129 | i = i + 1; | |
130 | } | |
131 | } | |
132 | } |