Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: CCCAccessMethod.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 "general_csr_defines.vri" | |
36 | #include "report_macros.vri" | |
37 | #include "cReport.vrh" | |
38 | #include "CSRFmwork.vrh" | |
39 | //#include "CCCXactor.vrh" | |
40 | ||
41 | ||
42 | //------------------------------------------------------------------------------ | |
43 | // Class Definition | |
44 | // | |
45 | // | |
46 | // | |
47 | //------------------------------------------------------------------------------ | |
48 | ||
49 | ||
50 | class CCCAccessMethod extends CSRAccessMethod { | |
51 | ||
52 | CCCXactor ringXactor; | |
53 | protected ReportClass report; | |
54 | protected integer timeout; | |
55 | protected integer min_timeout; | |
56 | protected integer src_bus_id; | |
57 | protected integer CSRSbusSema; | |
58 | protected string myName; | |
59 | ||
60 | //*************************************************************** | |
61 | // Constructor | |
62 | // | |
63 | // - Must pass in a handle to | |
64 | // - pre-existing CCCXactor | |
65 | // - Report Class | |
66 | // | |
67 | // - Pass in Source Bus ID | |
68 | // - Transaction Timeout value | |
69 | // | |
70 | //*************************************************************** | |
71 | ||
72 | task new (ReportClass report, CCCXactor ringXactor, integer src_bus_id, integer timeout, integer min_timeout = 0) { | |
73 | ||
74 | this.report = report; | |
75 | this.ringXactor = ringXactor; | |
76 | this.timeout = timeout; | |
77 | this.min_timeout = min_timeout; | |
78 | this.src_bus_id = src_bus_id; | |
79 | ||
80 | myName = "CCCAccessMethod"; | |
81 | ||
82 | //----------------------------------- | |
83 | // Create the Semaphore | |
84 | //----------------------------------- | |
85 | ||
86 | CSRSbusSema = alloc(SEMAPHORE,0,1,1); | |
87 | ||
88 | if (CSRSbusSema == 0) | |
89 | error("%0s: Out of semaphore space.\n", myName); | |
90 | ||
91 | } | |
92 | ||
93 | //*************************************************************** | |
94 | // READ FUNCTION | |
95 | // | |
96 | // - Returns 64 bit Read Data | |
97 | // - Pass in 64 Bit address | |
98 | // - Pass in Error bit | |
99 | // | |
100 | //*************************************************************** | |
101 | ||
102 | function bit [CSRT_DATA_WIDTH-1:0] read (bit [CSRT_ADDR_OFFSET_WIDTH-1:0] addr) { | |
103 | ||
104 | ||
105 | CCCXactorTransaction ringXaction = new; | |
106 | ||
107 | semaphore_get (WAIT, CSRSbusSema, 1); | |
108 | ||
109 | // Align address | |
110 | ||
111 | //-------------------------------------------- | |
112 | // Set up a read | |
113 | //-------------------------------------------- | |
114 | ||
115 | ringXaction.wr_rd_cmd = CCC_XACTOR_RD_CMD; | |
116 | ringXaction.address = addr; | |
117 | ringXaction.src_bus_id = src_bus_id; | |
118 | ringXaction.csr_data = CSRT_DATA_WIDTH'bx; | |
119 | ringXaction.error = 1'b0; | |
120 | ||
121 | ||
122 | //------------------------------------------- | |
123 | // Print out the transaction | |
124 | //------------------------------------------- | |
125 | ||
126 | QuickReport(report, RTYP_DEBUG_1, "%0s: Reading: src_bus_id: 2'b%b, addr: 'h%h", | |
127 | myName, src_bus_id, addr); | |
128 | ||
129 | //------------------------------------------- | |
130 | // Execute the transaction | |
131 | //------------------------------------------- | |
132 | ||
133 | ringXactor.ExecuteTrans(ringXaction, timeout, min_timeout); | |
134 | ||
135 | //------------------------------------------- | |
136 | // Get the Read Return Data | |
137 | //------------------------------------------- | |
138 | read = ringXaction.csr_data; | |
139 | ||
140 | semaphore_put (CSRSbusSema, 1); | |
141 | ||
142 | } | |
143 | ||
144 | //*************************************************************** | |
145 | // READ FUNCTION | |
146 | // | |
147 | // - Returns 64 bit Read Data | |
148 | // - Pass in 64 Bit address | |
149 | // - Pass in Error bit | |
150 | // | |
151 | //*************************************************************** | |
152 | ||
153 | function bit [CSRT_DATA_WIDTH-1:0] read_error (bit [CSRT_ADDR_OFFSET_WIDTH-1:0] addr) { | |
154 | ||
155 | ||
156 | CCCXactorTransaction ringXaction = new; | |
157 | ||
158 | semaphore_get (WAIT, CSRSbusSema, 1); | |
159 | ||
160 | // Align address | |
161 | ||
162 | //-------------------------------------------- | |
163 | // Set up a read | |
164 | //-------------------------------------------- | |
165 | ||
166 | ringXaction.wr_rd_cmd = CCC_XACTOR_RD_CMD; | |
167 | ringXaction.address = addr; | |
168 | ringXaction.src_bus_id = src_bus_id; | |
169 | ringXaction.csr_data = CSRT_DATA_WIDTH'bx; | |
170 | ringXaction.error = 1'b1; | |
171 | ||
172 | ||
173 | //------------------------------------------- | |
174 | // Print out the transaction | |
175 | //------------------------------------------- | |
176 | ||
177 | QuickReport(report, RTYP_DEBUG_1, "%0s: Reading: src_bus_id: 2'b%b, addr: 'h%h", | |
178 | myName, src_bus_id, addr); | |
179 | ||
180 | //------------------------------------------- | |
181 | // Execute the transaction | |
182 | //------------------------------------------- | |
183 | ||
184 | ringXactor.ExecuteTrans(ringXaction, timeout, min_timeout); | |
185 | ||
186 | //------------------------------------------- | |
187 | // Get the Read Return Data | |
188 | //------------------------------------------- | |
189 | read_error = ringXaction.csr_data; | |
190 | ||
191 | semaphore_put (CSRSbusSema, 1); | |
192 | ||
193 | } | |
194 | ||
195 | ||
196 | //*************************************************************** | |
197 | // Write FUNCTION | |
198 | // | |
199 | // - Pass in 64 bit Write Data | |
200 | // - Pass in 64 Bit address | |
201 | // | |
202 | //*************************************************************** | |
203 | ||
204 | task write (bit [CSRT_ADDR_OFFSET_WIDTH-1:0] addr, bit [CSRT_DATA_WIDTH-1:0] data) { | |
205 | ||
206 | CCCXactorTransaction ringXaction = new; | |
207 | ||
208 | semaphore_get (WAIT, CSRSbusSema, 1); | |
209 | ||
210 | // Align address | |
211 | //addr <<= 3; +++review+++ do we need this? | |
212 | ||
213 | //-------------------------------------------- | |
214 | // Set up a Write | |
215 | //-------------------------------------------- | |
216 | ||
217 | ringXaction.wr_rd_cmd = CCC_XACTOR_WR_CMD; | |
218 | ringXaction.src_bus_id = src_bus_id; | |
219 | ringXaction.address = addr; | |
220 | ringXaction.csr_data = data; | |
221 | ringXaction.error = 1'b0; | |
222 | ||
223 | //------------------------------------------- | |
224 | // Print out the transaction | |
225 | //------------------------------------------- | |
226 | ||
227 | ||
228 | QuickReport(report, RTYP_DEBUG_1, "%0s: Writing: src_bus_id: 2'b%0b, addr: 'h%h, data: 'h%h", | |
229 | myName, src_bus_id, addr, data); | |
230 | ||
231 | //------------------------------------------- | |
232 | // Execute the transaction | |
233 | //------------------------------------------- | |
234 | ||
235 | ringXactor.ExecuteTrans(ringXaction, timeout, min_timeout); | |
236 | ||
237 | semaphore_put (CSRSbusSema, 1); | |
238 | } | |
239 | ||
240 | //*************************************************************** | |
241 | // Write FUNCTION | |
242 | // | |
243 | // - Pass in 64 bit Write Data | |
244 | // - Pass in 64 Bit address | |
245 | // | |
246 | //*************************************************************** | |
247 | ||
248 | task write_error (bit [CSRT_ADDR_OFFSET_WIDTH-1:0] addr, bit [CSRT_DATA_WIDTH-1:0] data) { | |
249 | ||
250 | CCCXactorTransaction ringXaction = new; | |
251 | ||
252 | semaphore_get (WAIT, CSRSbusSema, 1); | |
253 | ||
254 | // Align address | |
255 | //addr <<= 3; +++review+++ do we need this? | |
256 | ||
257 | //-------------------------------------------- | |
258 | // Set up a Write | |
259 | //-------------------------------------------- | |
260 | ||
261 | ringXaction.wr_rd_cmd = CCC_XACTOR_WR_CMD; | |
262 | ringXaction.src_bus_id = src_bus_id; | |
263 | ringXaction.address = addr; | |
264 | ringXaction.csr_data = data; | |
265 | ringXaction.error = 1'b1; | |
266 | ||
267 | //------------------------------------------- | |
268 | // Print out the transaction | |
269 | //------------------------------------------- | |
270 | ||
271 | ||
272 | QuickReport(report, RTYP_DEBUG_1, "%0s: Writing: src_bus_id: 2'b%0b, addr: 'h%h, data: 'h%h", | |
273 | myName, src_bus_id, addr, data); | |
274 | ||
275 | //------------------------------------------- | |
276 | // Execute the transaction | |
277 | //------------------------------------------- | |
278 | ||
279 | ringXactor.ExecuteTrans(ringXaction, timeout, min_timeout); | |
280 | ||
281 | semaphore_put (CSRSbusSema, 1); | |
282 | } | |
283 | ||
284 | ||
285 | } |