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

Subversion Repositories openrisc

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

Go to most recent revision | 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
#include "Vorpsoc_top.h"
33
#include "Vorpsoc_top_orpsoc_top.h"
34
#include "Vorpsoc_top_or1k_top.h"
35
#include "Vorpsoc_top_or1200_top.h"
36
#include "Vorpsoc_top_or1200_cpu.h"
37
#include "Vorpsoc_top_or1200_ctrl.h"
38 44 julius
#include "Vorpsoc_top_or1200_except.h"
39
#include "Vorpsoc_top_or1200_sprs.h"
40 6 julius
#include "Vorpsoc_top_or1200_rf.h"
41
#include "Vorpsoc_top_or1200_dpram.h"
42 51 julius
//#include "Vorpsoc_top_ram_wb.h"
43
//#include "Vorpsoc_top_ram_wb_sc_sw.h"
44 63 julius
#include "Vorpsoc_top_ram_wb__D20_A19_M800000.h"
45
#include "Vorpsoc_top_ram_wb_sc_sw__D20_A19_M800000.h"
46
#include "Vorpsoc_top_wb_conbus_top__pi1.h"
47 6 julius
 
48
//! Constructor for the ORPSoC access class
49
 
50
//! Initializes the pointers to the various module instances of interest
51
//! within the Verilator model.
52
 
53
//! @param[in] orpsoc  The SystemC Verilated ORPSoC instance
54
 
55
OrpsocAccess::OrpsocAccess (Vorpsoc_top *orpsoc_top)
56
{
57 63 julius
  // Assign processor accessor objects
58 6 julius
  or1200_ctrl = orpsoc_top->v->i_or1k->i_or1200_top->or1200_cpu->or1200_ctrl;
59 44 julius
  or1200_except = orpsoc_top->v->i_or1k->i_or1200_top->or1200_cpu->or1200_except;
60
  or1200_sprs = orpsoc_top->v->i_or1k->i_or1200_top->or1200_cpu->or1200_sprs;
61 6 julius
  rf_a        = orpsoc_top->v->i_or1k->i_or1200_top->or1200_cpu->or1200_rf->rf_a;
62 63 julius
  // Assign main memory accessor objects
63 51 julius
  ram_wb_sc_sw = orpsoc_top->v->ram_wb0->ram0;
64 63 julius
  // Assign arbiter accessor object
65
  wb_arbiter = orpsoc_top->v->wb_conbus;
66 6 julius
 
67
}       // OrpsocAccess ()
68
 
69 51 julius
//! Access for the ex_freeze signal
70 6 julius
 
71 51 julius
//! @return  The value of the or1200_ctrl.ex_freeze signal
72
 
73
bool
74
OrpsocAccess::getExFreeze ()
75
{
76
  return  or1200_ctrl->ex_freeze;
77
 
78
}       // getExFreeze ()
79
 
80 6 julius
//! Access for the wb_freeze signal
81
 
82
//! @return  The value of the or1200_ctrl.wb_freeze signal
83
 
84
bool
85
OrpsocAccess::getWbFreeze ()
86
{
87
  return  or1200_ctrl->wb_freeze;
88
 
89
}       // getWbFreeze ()
90
 
91 44 julius
//! Access for the except_flushpipe signal
92 6 julius
 
93 44 julius
//! @return  The value of the or1200_except.except_flushpipe signal
94
 
95
bool
96
OrpsocAccess::getExceptFlushpipe ()
97
{
98
  return  or1200_except->except_flushpipe;
99
 
100
}       // getExceptFlushpipe ()
101
 
102
//! Access for the ex_dslot signal
103
 
104
//! @return  The value of the or1200_except.ex_dslot signalfac
105
 
106
bool
107
OrpsocAccess::getExDslot ()
108
{
109
  return  or1200_except->ex_dslot;
110
 
111
}       // getExDslot ()
112
 
113 51 julius
//! Access for the except_type value
114
 
115
//! @return  The value of the or1200_except.except_type register
116
 
117
uint32_t
118
OrpsocAccess::getExceptType ()
119
{
120
  return  (or1200_except->get_except_type) ();
121
 
122
}       // getExceptType ()
123
 
124
 
125 49 julius
//! Access for the id_pc register
126
 
127
//! @return  The value of the or1200_except.id_pc register
128
 
129
uint32_t
130
OrpsocAccess::getIdPC ()
131
{
132
  return  (or1200_except->get_id_pc) ();
133
 
134
}       // getIdPC ()
135
 
136 51 julius
//! Access for the ex_pc register
137
 
138
//! @return  The value of the or1200_except.id_ex register
139
 
140
uint32_t
141
OrpsocAccess::getExPC ()
142
{
143
  return  (or1200_except->get_ex_pc) ();
144
 
145
}       // getExPC ()
146
 
147 44 julius
//! Access for the wb_pc register
148
 
149 49 julius
//! @return  The value of the or1200_except.wb_pc register
150 44 julius
 
151
uint32_t
152
OrpsocAccess::getWbPC ()
153
{
154
  return  (or1200_except->get_wb_pc) ();
155
 
156
}       // getWbPC ()
157
 
158 51 julius
//! Access for the id_insn register
159
 
160
//! @return  The value of the or1200_ctrl.wb_insn register
161
 
162
uint32_t
163
OrpsocAccess::getIdInsn ()
164
{
165
  return  (or1200_ctrl->get_id_insn) ();
166
 
167
}       // getIdInsn ()
168
 
169
//! Access for the ex_insn register
170
 
171
//! @return  The value of the or1200_ctrl.ex_insn register
172
 
173
uint32_t
174
OrpsocAccess::getExInsn ()
175
{
176
  return  (or1200_ctrl->get_ex_insn) ();
177
 
178
}       // getExInsn ()
179
 
180
 
181 6 julius
//! Access for the wb_insn register
182
 
183
//! @return  The value of the or1200_ctrl.wb_insn register
184
 
185
uint32_t
186
OrpsocAccess::getWbInsn ()
187
{
188
  return  (or1200_ctrl->get_wb_insn) ();
189
 
190
}       // getWbInsn ()
191
 
192 51 julius
//! Access the Wishbone SRAM memory
193 6 julius
 
194 66 julius
//! @return  The value of the 32-bit memory word at addr
195 49 julius
 
196
uint32_t
197 66 julius
OrpsocAccess::get_mem32 (uint32_t addr)
198 49 julius
{
199 66 julius
  return  (ram_wb_sc_sw->get_mem) (addr/4);
200 49 julius
 
201 66 julius
}       // get_mem32 ()
202 49 julius
 
203 66 julius
 
204
//! Access a byte from the Wishbone SRAM memory
205
 
206
//! @return  The value of the memory byte at addr
207
 
208
uint8_t
209
OrpsocAccess::get_mem8 (uint32_t addr)
210
{
211
 
212
  uint32_t word;
213
  static uint32_t cached_word;
214
  static uint32_t cached_word_addr = 0xffffffff;
215
  int sel = addr & 0x3; // Remember which byte we want
216
  addr = addr / 4;
217
  if (addr != cached_word_addr)
218
    {
219
      cached_word_addr = addr;
220
      // Convert address to word number here
221
      word = (ram_wb_sc_sw->get_mem) (addr);
222
      cached_word = word;
223
    }
224
  else
225
    word = cached_word;
226
 
227
  switch(sel)
228
    {
229
      /* Big endian word expected */
230
    case 0:
231
      return ((word >> 24) & 0xff);
232
      break;
233
    case 1:
234
      return ((word >> 16) & 0xff);
235
      break;
236
    case 2:
237
      return ((word >> 8) & 0xff);
238
      break;
239
    case 3:
240
      return ((word >> 0) & 0xff);
241
      break;
242
    default:
243
      return 0;
244
    }
245
 
246
}       // get_mem8 ()
247
 
248
 
249 51 julius
//! Write value to the Wishbone SRAM memory
250
 
251
void
252 66 julius
OrpsocAccess::set_mem32 (uint32_t addr, uint32_t data)
253 51 julius
{
254 66 julius
  (ram_wb_sc_sw->set_mem) (addr/4, data);
255 51 julius
 
256 66 julius
}       // set_mem32 ()
257 51 julius
 
258
//! Trigger the $readmemh() system call
259
 
260
void
261
OrpsocAccess::do_ram_readmemh (void)
262
{
263
  (ram_wb_sc_sw->do_readmemh) ();
264
 
265
}       // do_ram_readmemh ()
266
 
267 6 julius
//! Access for the OR1200 GPRs
268
 
269
//! These are extracted from memory using the Verilog function
270
 
271
//! @param[in] regNum  The GPR whose value is wanted
272
 
273
//! @return            The value of the GPR
274
 
275
uint32_t
276
OrpsocAccess::getGpr (uint32_t  regNum)
277
{
278
  return  (rf_a->get_gpr) (regNum);
279
 
280
}       // getGpr ()
281 44 julius
 
282
 
283
//! Access for the sr register
284
 
285
//! @return  The value of the or1200_sprs.sr register
286
 
287
uint32_t
288
OrpsocAccess::getSprSr ()
289
{
290
  return  (or1200_sprs->get_sr) ();
291
 
292
}       // getSprSr ()
293
 
294
//! Access for the epcr register
295
 
296
//! @return  The value of the or1200_sprs.epcr register
297
 
298
uint32_t
299
OrpsocAccess::getSprEpcr ()
300
{
301
  return  (or1200_sprs->get_epcr) ();
302
 
303
}       // getSprEpcr ()
304
 
305
//! Access for the eear register
306
 
307
//! @return  The value of the or1200_sprs.eear register
308
 
309
uint32_t
310
OrpsocAccess::getSprEear ()
311
{
312
  return  (or1200_sprs->get_eear) ();
313
 
314
}       // getSprEear ()
315
 
316
//! Access for the esr register
317
 
318
//! @return  The value of the or1200_sprs.esr register
319
 
320
uint32_t
321
OrpsocAccess::getSprEsr ()
322
{
323
  return  (or1200_sprs->get_esr) ();
324
 
325
}       // getSprEsr ()
326
 
327 63 julius
 
328
//! Access for the arbiter's grant signal
329
 
330
//! @return  The value of the wb_conmax_top.arb signal
331
 
332
uint8_t
333
OrpsocAccess::getWbArbGrant ()
334
{
335
  return  (wb_arbiter->get_gnt) ();
336
 
337
}       // getWbArbGrant ()
338
 
339
 
340
//! Arbiter master[mast_num] access functions
341
 
342
//! Access for the arbiter's master[mast_num] data in signal
343
 
344
//! @return  The value of the wb_conmax_top.m_dat_i[mast_num]
345
 
346
uint32_t
347
OrpsocAccess::getWbArbMastDatI (uint32_t mast_num)
348
{
349
  return  (wb_arbiter->get_m_dat_i) (mast_num);
350
 
351
}       // getWbArbMastDatI ()
352
 
353
//! Access for the arbiter's master[mast_num] data out signal
354
 
355
//! @return  The value of the wb_conmax_top.m_dat_o[mast_num]
356
 
357
uint32_t
358
OrpsocAccess::getWbArbMastDatO (uint32_t mast_num)
359
{
360
  return  (wb_arbiter->get_m_dat_o) (mast_num);
361
 
362
}       // getWbArbMastDatO ()
363
 
364
//! Access for the arbiter's master[mast_num] data out
365
 
366
//! @return  The value of the wb_conmax_top.m_adr_i[mast_num]
367
 
368
uint32_t
369
OrpsocAccess::getWbArbMastAdrI (uint32_t mast_num)
370
{
371
  return  (wb_arbiter->get_m_adr_i) (mast_num);
372
 
373
}       // getWbArbMastAdrI ()
374
 
375
 
376
//! Access for the arbiter's master[mast_num] select signal
377
 
378
//! @return  The value of the wb_conmax_top.m_sel_i[mast_num]
379
 
380
uint8_t
381
OrpsocAccess::getWbArbMastSelI (uint32_t mast_num)
382
{
383
  return  (wb_arbiter->get_m_sel_i) (mast_num);
384
 
385
}       // getWbArbMastSelI ()
386
 
387
//! Access for the arbiter's master[mast_num] decoded slave select signal
388
 
389
//! @return  The value of the wb_conmax_top.m_ssel_dec[mast_num]
390
 
391
uint8_t
392
OrpsocAccess::getWbArbMastSlaveSelDecoded (uint32_t mast_num)
393
{
394
  return  (wb_arbiter->get_m_ssel_dec) (mast_num);
395
 
396
}       // getWbArbMastSlaveSelDecoded ()
397
 
398
//! Access for the arbiter's master[mast_num] write enable signal
399
 
400
//! @return  The value of the wb_conmax_top.m_we_i[mast_num]
401
 
402
bool
403
OrpsocAccess::getWbArbMastWeI (uint32_t mast_num)
404
{
405
  return  (wb_arbiter->get_m_we_i) (mast_num);
406
 
407
}       // getWbArbMastWeI ()
408
 
409
//! Access for the arbiter's master[mast_num] cycle input signal
410
 
411
//! @return  The value of the wb_conmax_top.m_cyc_i[mast_num]
412
 
413
bool
414
OrpsocAccess::getWbArbMastCycI (uint32_t mast_num)
415
{
416
  return  (wb_arbiter->get_m_cyc_i) (mast_num);
417
 
418
}       // getWbArbMastCycI ()
419
 
420
//! Access for the arbiter's master[mast_num] strobe input signal
421
 
422
//! @return  The value of the wb_conmax_top.m_stb_i[mast_num]
423
 
424
bool
425
OrpsocAccess::getWbArbMastStbI (uint32_t mast_num)
426
{
427
  return  (wb_arbiter->get_m_stb_i) (mast_num);
428
 
429
}       // getWbArbMastStbI ()
430
 
431
//! Access for the arbiter's master[mast_num] ACK output signal
432
 
433
//! @return  The value of the wb_conmax_top.m_ack_o[mast_num]
434
 
435
bool
436
OrpsocAccess::getWbArbMastAckO (uint32_t mast_num)
437
{
438
  return  (wb_arbiter->get_m_ack_o) (mast_num);
439
 
440
}       // getWbArbMastAckO ()
441
 
442
//! Access for the arbiter's master[mast_num] error input signal
443
 
444
//! @return  The value of the wb_conmax_top.m_err_o[mast_num]
445
 
446
bool
447
OrpsocAccess::getWbArbMastErrO (uint32_t mast_num)
448
{
449
  return  (wb_arbiter->get_m_err_o) (mast_num);
450
 
451
}       // getWbArbMastErrO ()
452
 

powered by: WebSVN 2.1.0

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