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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [sim/] [cpu.c] - Diff between revs 8 and 25

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

Rev 8 Rev 25
Line 40... Line 40...
 
 
static Word pc;                 /* program counter */
static Word pc;                 /* program counter */
static Word psw;                /* processor status word */
static Word psw;                /* processor status word */
static Word r[32];              /* general purpose registers */
static Word r[32];              /* general purpose registers */
 
 
static int instrCount;          /* counts instrs for timer tick */
 
static unsigned irqPending;     /* one bit for each pending IRQ */
static unsigned irqPending;     /* one bit for each pending IRQ */
 
 
static Bool breakSet;           /* breakpoint set if true */
static Bool breakSet;           /* breakpoint set if true */
static Word breakAddr;          /* if breakSet, this is where */
static Word breakAddr;          /* if breakSet, this is where */
 
 
Line 57... Line 56...
 
 
 
 
/**************************************************************/
/**************************************************************/
 
 
 
 
static void handleRealTimeTasks(void) {
 
  /* handle 'real-time' tasks */
 
  if (++instrCount == INSTRS_PER_MSEC) {
 
    instrCount = 0;
 
    timerTick();
 
  }
 
}
 
 
 
 
 
static void handleInterrupts(void) {
static void handleInterrupts(void) {
  unsigned irqMask;
  unsigned irqMask;
  unsigned irqSeen;
  unsigned irqSeen;
  int priority;
  int priority;
 
 
Line 570... Line 560...
 
 
  exception = setjmp(myEnvironment);
  exception = setjmp(myEnvironment);
  if (exception == 0) {
  if (exception == 0) {
    /* initialization */
    /* initialization */
    pushEnvironment(&myEnvironment);
    pushEnvironment(&myEnvironment);
    handleRealTimeTasks();
    timerTick();
    execNextInstruction();
    execNextInstruction();
    handleInterrupts();
    handleInterrupts();
  } else {
  } else {
    /* an exception was thrown */
    /* an exception was thrown */
    cpuSetInterrupt(exception);
    cpuSetInterrupt(exception);
Line 600... Line 590...
    if (breakSet && pc == breakAddr) {
    if (breakSet && pc == breakAddr) {
      run = false;
      run = false;
    }
    }
  }
  }
  while (run) {
  while (run) {
    handleRealTimeTasks();
    timerTick();
    execNextInstruction();
    execNextInstruction();
    handleInterrupts();
    handleInterrupts();
    if (breakSet && pc == breakAddr) {
    if (breakSet && pc == breakAddr) {
      run = false;
      run = false;
    }
    }
Line 639... Line 629...
  /* but not all */
  /* but not all */
  pc = startAddr;
  pc = startAddr;
  r[0] = 0;
  r[0] = 0;
  psw = 0;
  psw = 0;
  /* reset simulator control variables */
  /* reset simulator control variables */
  instrCount = 0;
 
  irqPending = 0;
  irqPending = 0;
  total = 0;
  total = 0;
}
}
 
 
 
 

powered by: WebSVN 2.1.0

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