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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_34/] [or1ksim/] [tick/] [tick.c] - Diff between revs 102 and 133

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

Rev 102 Rev 133
Line 27... Line 27...
 
 
#include "tick.h"
#include "tick.h"
#include "../cpu/or1k/spr_defs.h"
#include "../cpu/or1k/spr_defs.h"
#include "pic.h"
#include "pic.h"
 
 
 
/* For mode 10 only: timer stops until we write into TTCR.  */
 
int tt_stopped = 0;
 
 
/* Reset. It initializes TTCR register. */
/* Reset. It initializes TTCR register. */
void tick_reset()
void tick_reset()
{
{
        printf("Resetting Tick Timer.\n");
        printf("Resetting Tick Timer.\n");
        mtspr(SPR_TTCR, 0);
        mtspr(SPR_TTCR, 0);
        mtspr(SPR_TTIR, 0);
  mtspr(SPR_TTMR, 0);
 
  tt_stopped = 0;
}
}
 
 
/* Simulation hook. Must be called every clock cycle to simulate tick
/* Simulation hook. Must be called every clock cycle to simulate tick
   timer. It does internal functional tick timer simulation. */
   timer. It does internal functional tick timer simulation. */
void tick_clock()
void tick_clock()
{
{
        unsigned long ttcr;
        unsigned long ttcr;
        unsigned long ttir;
  unsigned long ttmr;
 
 
        ttcr = mfspr(SPR_TTCR);
        ttcr = mfspr(SPR_TTCR);
        ttir = mfspr(SPR_TTIR);
  ttmr = mfspr(SPR_TTMR);
 
 
        if (!(ttcr & SPR_TTCR_TTE))
  if (!(ttmr & SPR_TTMR_M) || tt_stopped)
                return;
                return;
 
 
        if ((ttir & SPR_TTCR_PERIOD) == (ttcr & SPR_TTCR_PERIOD)) {
  if ((ttcr & SPR_TTCR_PERIOD) == (ttmr & SPR_TTMR_PERIOD)) {
                if (ttcr & SPR_TTCR_IE) {
    if (ttmr & SPR_TTMR_IE) {
                        setsprbits(SPR_TTCR, SPR_TTCR_IP, 1);
      setsprbits(SPR_TTMR, SPR_TTMR_IP, 1);
                        report_interrupt(INT_TICK);
                        report_interrupt(INT_TICK);
                }
                }
                if (ttcr & SPR_TTCR_SR)
 
 
    if (ttmr & SPR_TTMR_M == 1) {
 
      /* Mode 01: Restart timer.  */
 
      ttcr = 0;
 
      mtspr(SPR_TTCR, ttcr);
 
      return;
 
    } else if (ttmr & SPR_TTMR_M == 2) {
 
      /* Mode 10: Temporarly stop timer.  */
 
      tt_stopped = 1;
                        return;
                        return;
        }
        }
        ttir++;
  }
        mtspr(SPR_TTIR, ttir);
  if (!tt_stopped)
 
    ttcr++;
 
  mtspr(SPR_TTCR, ttcr);
}
}
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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