OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [sysc/] [src/] [OrpsocAccess.cpp] - Blame information for rev 862

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 julius
// ----------------------------------------------------------------------------
2
 
3
// Access functions for the ORPSoC Verilator model: implementation
4
 
5
// Copyright (C) 2008  Embecosm Limited <info@embecosm.com>
6
 
7
// Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
8 44 julius
// Contributor Julius Baxter <jb@orsoc.se>
9 6 julius
 
10
// This file is part of the cycle accurate model of the OpenRISC 1000 based
11
// system-on-chip, ORPSoC, built using Verilator.
12
 
13
// This program is free software: you can redistribute it and/or modify it
14
// under the terms of the GNU Lesser General Public License as published by
15
// the Free Software Foundation, either version 3 of the License, or (at your
16
// option) any later version.
17
 
18
// This program is distributed in the hope that it will be useful, but WITHOUT
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
21
// License for more details.
22
 
23
// You should have received a copy of the GNU Lesser General Public License
24
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
25
 
26
// ----------------------------------------------------------------------------
27
 
28
// $Id: OrpsocAccess.cpp 303 2009-02-16 11:20:17Z jeremy $
29
 
30
#include "OrpsocAccess.h"
31
 
32 862 stekern
#include "Vorpsoc_top__Syms.h"
33
 
34 6 julius
#include "Vorpsoc_top.h"
35
#include "Vorpsoc_top_orpsoc_top.h"
36
#include "Vorpsoc_top_or1200_top.h"
37
#include "Vorpsoc_top_or1200_cpu.h"
38
#include "Vorpsoc_top_or1200_ctrl.h"
39 44 julius
#include "Vorpsoc_top_or1200_except.h"
40
#include "Vorpsoc_top_or1200_sprs.h"
41 6 julius
#include "Vorpsoc_top_or1200_rf.h"
42
#include "Vorpsoc_top_or1200_dpram.h"
43
 
44
//! Constructor for the ORPSoC access class
45
 
46
//! Initializes the pointers to the various module instances of interest
47
//! within the Verilator model.
48
 
49
//! @param[in] orpsoc  The SystemC Verilated ORPSoC instance
50
 
51 462 julius
OrpsocAccess::OrpsocAccess(Vorpsoc_top * orpsoc_top)
52 6 julius
{
53 462 julius
        // Assign processor accessor objects
54
        or1200_ctrl = orpsoc_top->v->or1200_top0->or1200_cpu->or1200_ctrl;
55
        or1200_except = orpsoc_top->v->or1200_top0->or1200_cpu->or1200_except;
56
        or1200_sprs = orpsoc_top->v->or1200_top0->or1200_cpu->or1200_sprs;
57
        rf_a = orpsoc_top->v->or1200_top0->or1200_cpu->or1200_rf->rf_a;
58 353 julius
 
59 862 stekern
        this->orpsoc_top = orpsoc_top;
60 6 julius
 
61 462 julius
}                               // OrpsocAccess ()
62 6 julius
 
63 51 julius
//! Access for the ex_freeze signal
64 6 julius
 
65 51 julius
//! @return  The value of the or1200_ctrl.ex_freeze signal
66
 
67 462 julius
bool OrpsocAccess::getExFreeze()
68 51 julius
{
69 462 julius
        return or1200_ctrl->ex_freeze;
70 51 julius
 
71 462 julius
}                               // getExFreeze ()
72 51 julius
 
73 6 julius
//! Access for the wb_freeze signal
74
 
75
//! @return  The value of the or1200_ctrl.wb_freeze signal
76
 
77 462 julius
bool OrpsocAccess::getWbFreeze()
78 6 julius
{
79 462 julius
        return or1200_ctrl->wb_freeze;
80 6 julius
 
81 462 julius
}                               // getWbFreeze ()
82 6 julius
 
83 44 julius
//! Access for the except_flushpipe signal
84 6 julius
 
85 44 julius
//! @return  The value of the or1200_except.except_flushpipe signal
86
 
87 462 julius
bool OrpsocAccess::getExceptFlushpipe()
88 44 julius
{
89 462 julius
        return or1200_except->except_flushpipe;
90 44 julius
 
91 462 julius
}                               // getExceptFlushpipe ()
92 44 julius
 
93
//! Access for the ex_dslot signal
94
 
95
//! @return  The value of the or1200_except.ex_dslot signalfac
96
 
97 462 julius
bool OrpsocAccess::getExDslot()
98 44 julius
{
99 462 julius
        return or1200_except->ex_dslot;
100 44 julius
 
101 462 julius
}                               // getExDslot ()
102 44 julius
 
103 51 julius
//! Access for the except_type value
104
 
105
//! @return  The value of the or1200_except.except_type register
106
 
107 462 julius
uint32_t OrpsocAccess::getExceptType()
108 51 julius
{
109 462 julius
        return (or1200_except->get_except_type) ();
110 51 julius
 
111 462 julius
}                               // getExceptType ()
112 51 julius
 
113 49 julius
//! Access for the id_pc register
114
 
115
//! @return  The value of the or1200_except.id_pc register
116
 
117 462 julius
uint32_t OrpsocAccess::getIdPC()
118 49 julius
{
119 462 julius
        return (or1200_except->get_id_pc) ();
120 49 julius
 
121 462 julius
}                               // getIdPC ()
122 49 julius
 
123 51 julius
//! Access for the ex_pc register
124
 
125
//! @return  The value of the or1200_except.id_ex register
126
 
127 462 julius
uint32_t OrpsocAccess::getExPC()
128 51 julius
{
129 462 julius
        return (or1200_except->get_ex_pc) ();
130 51 julius
 
131 462 julius
}                               // getExPC ()
132 51 julius
 
133 44 julius
//! Access for the wb_pc register
134
 
135 49 julius
//! @return  The value of the or1200_except.wb_pc register
136 44 julius
 
137 462 julius
uint32_t OrpsocAccess::getWbPC()
138 44 julius
{
139 462 julius
        return (or1200_except->get_wb_pc) ();
140 44 julius
 
141 462 julius
}                               // getWbPC ()
142 44 julius
 
143 51 julius
//! Access for the id_insn register
144
 
145
//! @return  The value of the or1200_ctrl.wb_insn register
146
 
147 462 julius
uint32_t OrpsocAccess::getIdInsn()
148 51 julius
{
149 462 julius
        return (or1200_ctrl->get_id_insn) ();
150 51 julius
 
151 462 julius
}                               // getIdInsn ()
152 51 julius
 
153
//! Access for the ex_insn register
154
 
155
//! @return  The value of the or1200_ctrl.ex_insn register
156
 
157 462 julius
uint32_t OrpsocAccess::getExInsn()
158 51 julius
{
159 462 julius
        return (or1200_ctrl->get_ex_insn) ();
160 51 julius
 
161 462 julius
}                               // getExInsn ()
162 51 julius
 
163 6 julius
//! Access for the wb_insn register
164
 
165
//! @return  The value of the or1200_ctrl.wb_insn register
166
 
167 462 julius
uint32_t OrpsocAccess::getWbInsn()
168 6 julius
{
169 462 julius
        return (or1200_ctrl->get_wb_insn) ();
170 6 julius
 
171 462 julius
}                               // getWbInsn ()
172 6 julius
 
173 51 julius
//! Access the Wishbone SRAM memory
174 6 julius
 
175 66 julius
//! @return  The value of the 32-bit memory word at addr
176 49 julius
 
177 462 julius
uint32_t OrpsocAccess::get_mem32(uint32_t addr)
178 49 julius
{
179 462 julius
        return (wishbone_ram->get_mem32) (addr / 4);
180 49 julius
 
181 462 julius
}                               // get_mem32 ()
182 49 julius
 
183 66 julius
//! Access a byte from the Wishbone SRAM memory
184
 
185
//! @return  The value of the memory byte at addr
186
 
187 462 julius
uint8_t OrpsocAccess::get_mem8(uint32_t addr)
188 66 julius
{
189
 
190 462 julius
        uint32_t word;
191
        static uint32_t cached_word;
192
        static uint32_t cached_word_addr = 0xffffffff;
193
        int sel = addr & 0x3;   // Remember which byte we want
194
        addr = addr / 4;
195
        if (addr != cached_word_addr) {
196
                cached_word_addr = addr;
197
                // Convert address to word number here
198
                word = (wishbone_ram->get_mem8) (addr);
199
                cached_word = word;
200
        } else
201
                word = cached_word;
202 66 julius
 
203 462 julius
        switch (sel) {
204
                /* Big endian word expected */
205
        case 0:
206
                return ((word >> 24) & 0xff);
207
                break;
208
        case 1:
209
                return ((word >> 16) & 0xff);
210
                break;
211
        case 2:
212
                return ((word >> 8) & 0xff);
213
                break;
214
        case 3:
215
                return ((word >> 0) & 0xff);
216
                break;
217
        default:
218
                return 0;
219
        }
220 66 julius
 
221 462 julius
}                               // get_mem8 ()
222 66 julius
 
223 51 julius
//! Write value to the Wishbone SRAM memory
224
 
225 462 julius
void OrpsocAccess::set_mem32(uint32_t addr, uint32_t data)
226 51 julius
{
227 462 julius
        (wishbone_ram->set_mem32) (addr / 4, data);
228 51 julius
 
229 462 julius
}                               // set_mem32 ()
230 51 julius
 
231
//! Trigger the $readmemh() system call
232
 
233 462 julius
void OrpsocAccess::do_ram_readmemh(void)
234 51 julius
{
235 462 julius
        (wishbone_ram->do_readmemh) ();
236 51 julius
 
237 462 julius
}                               // do_ram_readmemh ()
238 51 julius
 
239 6 julius
//! Access for the OR1200 GPRs
240
 
241
//! These are extracted from memory using the Verilog function
242
 
243
//! @param[in] regNum  The GPR whose value is wanted
244
 
245
//! @return            The value of the GPR
246
 
247 462 julius
uint32_t OrpsocAccess::getGpr(uint32_t regNum)
248 6 julius
{
249 462 julius
        return (rf_a->get_gpr) (regNum);
250 6 julius
 
251 462 julius
}                               // getGpr ()
252 44 julius
 
253 462 julius
//! Access for the OR1200 GPRs
254 44 julius
 
255 462 julius
//! These are extracted from memory using the Verilog function
256
 
257
//! @param[in] regNum  The GPR whose value is wanted
258
//! @param[in] value   The value of GPR to write
259
 
260
void OrpsocAccess::setGpr(uint32_t regNum, uint32_t value)
261
{
262
        (rf_a->set_gpr) (regNum, value);
263
 
264
}                               // getGpr ()
265
 
266 44 julius
//! Access for the sr register
267
 
268
//! @return  The value of the or1200_sprs.sr register
269
 
270 462 julius
uint32_t OrpsocAccess::getSprSr()
271 44 julius
{
272 462 julius
        return (or1200_sprs->get_sr) ();
273 44 julius
 
274 462 julius
}                               // getSprSr ()
275 44 julius
 
276
//! Access for the epcr register
277
 
278
//! @return  The value of the or1200_sprs.epcr register
279
 
280 462 julius
uint32_t OrpsocAccess::getSprEpcr()
281 44 julius
{
282 462 julius
        return (or1200_sprs->get_epcr) ();
283 44 julius
 
284 462 julius
}                               // getSprEpcr ()
285 44 julius
 
286
//! Access for the eear register
287
 
288
//! @return  The value of the or1200_sprs.eear register
289
 
290 462 julius
uint32_t OrpsocAccess::getSprEear()
291 44 julius
{
292 462 julius
        return (or1200_sprs->get_eear) ();
293 44 julius
 
294 462 julius
}                               // getSprEear ()
295 44 julius
 
296
//! Access for the esr register
297
 
298
//! @return  The value of the or1200_sprs.esr register
299
 
300 462 julius
uint32_t OrpsocAccess::getSprEsr()
301 44 julius
{
302 462 julius
        return (or1200_sprs->get_esr) ();
303 44 julius
 
304 462 julius
}                               // getSprEsr ()
305 44 julius
 
306 353 julius
/*
307 63 julius
//! Access for the arbiter's grant signal
308
 
309
//! @return  The value of the wb_conmax_top.arb signal
310
 
311
uint8_t
312
OrpsocAccess::getWbArbGrant ()
313
{
314
  return  (wb_arbiter->get_gnt) ();
315
 
316
}       // getWbArbGrant ()
317
 
318
//! Arbiter master[mast_num] access functions
319
 
320
//! Access for the arbiter's master[mast_num] data in signal
321
 
322
//! @return  The value of the wb_conmax_top.m_dat_i[mast_num]
323
 
324
uint32_t
325
OrpsocAccess::getWbArbMastDatI (uint32_t mast_num)
326
{
327
  return  (wb_arbiter->get_m_dat_i) (mast_num);
328
 
329
}       // getWbArbMastDatI ()
330
 
331
//! Access for the arbiter's master[mast_num] data out signal
332
 
333
//! @return  The value of the wb_conmax_top.m_dat_o[mast_num]
334
 
335
uint32_t
336
OrpsocAccess::getWbArbMastDatO (uint32_t mast_num)
337
{
338
  return  (wb_arbiter->get_m_dat_o) (mast_num);
339
 
340
}       // getWbArbMastDatO ()
341
 
342
//! Access for the arbiter's master[mast_num] data out
343
 
344
//! @return  The value of the wb_conmax_top.m_adr_i[mast_num]
345
 
346
uint32_t
347
OrpsocAccess::getWbArbMastAdrI (uint32_t mast_num)
348
{
349
  return  (wb_arbiter->get_m_adr_i) (mast_num);
350
 
351
}       // getWbArbMastAdrI ()
352
 
353
//! Access for the arbiter's master[mast_num] select signal
354
 
355
//! @return  The value of the wb_conmax_top.m_sel_i[mast_num]
356
 
357
uint8_t
358
OrpsocAccess::getWbArbMastSelI (uint32_t mast_num)
359
{
360
  return  (wb_arbiter->get_m_sel_i) (mast_num);
361
 
362
}       // getWbArbMastSelI ()
363
 
364
//! Access for the arbiter's master[mast_num] decoded slave select signal
365
 
366
//! @return  The value of the wb_conmax_top.m_ssel_dec[mast_num]
367
 
368
uint8_t
369
OrpsocAccess::getWbArbMastSlaveSelDecoded (uint32_t mast_num)
370
{
371
  return  (wb_arbiter->get_m_ssel_dec) (mast_num);
372
 
373
}       // getWbArbMastSlaveSelDecoded ()
374
 
375
//! Access for the arbiter's master[mast_num] write enable signal
376
 
377
//! @return  The value of the wb_conmax_top.m_we_i[mast_num]
378
 
379
bool
380
OrpsocAccess::getWbArbMastWeI (uint32_t mast_num)
381
{
382
  return  (wb_arbiter->get_m_we_i) (mast_num);
383
 
384
}       // getWbArbMastWeI ()
385
 
386
//! Access for the arbiter's master[mast_num] cycle input signal
387
 
388
//! @return  The value of the wb_conmax_top.m_cyc_i[mast_num]
389
 
390
bool
391
OrpsocAccess::getWbArbMastCycI (uint32_t mast_num)
392
{
393
  return  (wb_arbiter->get_m_cyc_i) (mast_num);
394
 
395
}       // getWbArbMastCycI ()
396
 
397
//! Access for the arbiter's master[mast_num] strobe input signal
398
 
399
//! @return  The value of the wb_conmax_top.m_stb_i[mast_num]
400
 
401
bool
402
OrpsocAccess::getWbArbMastStbI (uint32_t mast_num)
403
{
404
  return  (wb_arbiter->get_m_stb_i) (mast_num);
405
 
406
}       // getWbArbMastStbI ()
407
 
408
//! Access for the arbiter's master[mast_num] ACK output signal
409
 
410
//! @return  The value of the wb_conmax_top.m_ack_o[mast_num]
411
 
412
bool
413
OrpsocAccess::getWbArbMastAckO (uint32_t mast_num)
414
{
415
  return  (wb_arbiter->get_m_ack_o) (mast_num);
416
 
417
}       // getWbArbMastAckO ()
418
 
419
//! Access for the arbiter's master[mast_num] error input signal
420
 
421
//! @return  The value of the wb_conmax_top.m_err_o[mast_num]
422
 
423
bool
424
OrpsocAccess::getWbArbMastErrO (uint32_t mast_num)
425
{
426
  return  (wb_arbiter->get_m_err_o) (mast_num);
427
 
428
}       // getWbArbMastErrO ()
429
 
430 353 julius
*/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.