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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_34/] [or1ksim/] [cpu/] [or1k/] [sprs.c] - Diff between revs 123 and 133

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

Rev 123 Rev 133
Line 22... Line 22...
#include <string.h>
#include <string.h>
 
 
#include "arch.h"
#include "arch.h"
#include "sprs.h"
#include "sprs.h"
 
 
extern int cont_run;
extern int cont_run;   /* defined in toplevel.c */
 
extern int tt_stopped; /* defined in tick.c */
 
 
static sprword sprs[MAX_SPRS];
static sprword sprs[MAX_SPRS];
 
 
int temp_disable_except = 0;
int temp_disable_except = 0;
 
int audio_cnt = 0;
 
 
 
static FILE *fo = 0;
/* Set a specific SPR with a value. */
/* Set a specific SPR with a value. */
void mtspr(int regno, sprword value)
void mtspr(int regno, sprword value)
{
{
        int ofs = regno % MAX_SPRS_PER_GRP;
        int ofs = regno % MAX_SPRS_PER_GRP;
 
 
        if (regno == 0x1234)
  /* MM: Register hooks.  */
 
  switch (regno) {
 
  case 0xFFFD:
 
    fo = fopen ("audiosim.pcm", "wb+");
 
    if (!fo) printf("Cannot open audiosim.pcm\n");
 
    printf("Audio opened.\n");
 
    return;
 
  case 0xFFFE:
 
    if (!fo) printf("audiosim.pcm not opened\n");
 
    fputc (value & 0xFF, fo);
 
    if ((audio_cnt % 1024) == 0)
 
      printf("%i\n", audio_cnt);
 
    audio_cnt++;
 
    return;
 
  case 0xFFFF:
 
    fclose(fo);
 
    printf("Audio closed.\n");
 
    cont_run = 0;
 
    return;
 
  case SPR_TTMR:
 
    if (value & SPR_TTMR_M == 2) break;
 
  case SPR_TTCR:
 
    tt_stopped = 0;
 
    break;
 
  case 0x1234:
                printf("MTSPR(0x1234, %x);\n", value);
                printf("MTSPR(0x1234, %x);\n", value);
 
    break;
 
  }
        regno /= MAX_SPRS_PER_GRP;
        regno /= MAX_SPRS_PER_GRP;
        regno += ofs;
        regno += ofs;
 
 
/*      printf("mtspr(%x, %x)\n", regno, value);
/*      printf("mtspr(%x, %x)\n", regno, value);
*/      if (regno < MAX_SPRS)
*/      if (regno < MAX_SPRS)
                sprs[regno] = value;
                sprs[regno] = value;
        else {
        else {
                printf("\nABORT: write out of SPR range\n");
                printf("\nABORT: write out of SPR range\n");
                cont_run = 0;
                cont_run = 0;
        }
        }
 
 
        return;
 
}
}
 
 
/* Get a specific SPR. */
/* Get a specific SPR. */
sprword mfspr(int regno)
sprword mfspr(int regno)
{
{
Line 61... Line 87...
        regno += ofs;
        regno += ofs;
 
 
        /* MM: l.rfe, for example, temporarly disables
        /* MM: l.rfe, for example, temporarly disables
           exceptions.  We will make it appear as SR bit
           exceptions.  We will make it appear as SR bit
           is set.  */
           is set.  */
        /*if (regno == SPR_SR && temp_disable_except > 0)
  if (regno == SPR_SR && temp_disable_except > 0)
          return sprs[regno] | SPR_SR_EXR;*/
    return sprs[regno] | SPR_SR_EXR;
/*      printf("mfspr(%x)%x\n", regno, sprs[regno]);
  /*  printf("mfspr(%x)%x\n", regno, sprs[regno]); */
*/      if (regno < MAX_SPRS)
 
 
  if (regno < MAX_SPRS)
                return sprs[regno];
                return sprs[regno];
        else {
        else {
                printf("\nABORT: read out of SPR range\n");
                printf("\nABORT: read out of SPR range\n");
                cont_run = 0;
                cont_run = 0;
        }
        }

powered by: WebSVN 2.1.0

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