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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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