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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [or1ksim/] [cpu/] [or1k/] [sprs.h] - Diff between revs 600 and 624

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 600 Rev 624
Line 40... Line 40...
static inline int getsprbit(const int regno, const int bitnum);
static inline int getsprbit(const int regno, const int bitnum);
void sprs_status();
void sprs_status();
 
 
#include "sim-config.h"
#include "sim-config.h"
 
 
 
#ifdef OLD_MFSPR
/* Ugly, but fast */
/* Ugly, but fast */
/* Get a specific SPR. */
/* Get a specific SPR. */
static inline sprword
static inline sprword
mfspr_(const int regno)
mfspr_(const int regno)
{
{
  extern unsigned long reg[32];
  extern unsigned long reg[32];
  extern unsigned long pc;
  extern unsigned long pc;
  extern unsigned long pcprev;
  extern unsigned long pcprev;
  extern sprword sprs[MAX_SPRS];
  extern sprword sprs[MAX_SPRS];
 
  sprword val;
 
 
  switch (regno) {
  switch (regno) {
  case SPR_NPC:
  case SPR_NPC:
    return pc;
    return pc;
  case SPR_PPC:
  case SPR_PPC:
Line 67... Line 69...
  if (config.sim.verbose)
  if (config.sim.verbose)
    printf ("WARNING: read out of SPR range %08X\n", regno);
    printf ("WARNING: read out of SPR range %08X\n", regno);
  return 0;
  return 0;
}
}
 
 
 
#else
 
 
 
static inline sprword
 
mfspr_(const int regno)
 
{
 
  extern unsigned long reg[32];
 
  extern unsigned long pc;
 
  extern unsigned long pcprev;
 
  extern sprword sprs[MAX_SPRS];
 
  sprword val;
 
 
 
  switch (regno) {
 
  case SPR_NPC:
 
    val = pc;
 
    break;
 
  case SPR_PPC:
 
    val = pcprev;
 
    break;
 
  default:
 
    /* Links to GPRS */
 
    if(regno >= 0x0400 && regno < 0x0420)
 
      val = reg[regno - 0x0400];
 
    else if (regno < MAX_SPRS)
 
      val = sprs[regno];
 
  }
 
 
 
  if (regno < MAX_SPRS) {
 
    if (runtime.sim.fspr_log) {
 
      fprintf(runtime.sim.fspr_log, "Read from SPR : [%08lX] -> [%08lX]\n", regno, val);
 
    }
 
    return val;
 
  }
 
 
 
  if (config.sim.verbose) {
 
    printf ("WARNING: read out of SPR range %08X\n", regno);
 
  }
 
 
 
  return 0;
 
}
 
#endif
 
 
/* Set specific SPR bit(s) identified by mask. */
/* Set specific SPR bit(s) identified by mask. */
static inline void
static inline void
setsprbits(const int regno, const unsigned long mask, const unsigned long value)
setsprbits(const int regno, const unsigned long mask, const unsigned long value)
{
{
  sprword regvalue = mfspr(regno);
  sprword regvalue = mfspr(regno);

powered by: WebSVN 2.1.0

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