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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_67/] [or1ksim/] [toplevel.c] - Diff between revs 1387 and 1390

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

Rev 1387 Rev 1390
Line 66... Line 66...
#include "dumpverilog.h"
#include "dumpverilog.h"
#include "trace.h"
#include "trace.h"
#include "cuc.h"
#include "cuc.h"
 
 
/* CVS revision number. */
/* CVS revision number. */
const char rcsrev[] = "$Revision: 1.117 $";
const char rcsrev[] = "$Revision: 1.118 $";
 
 
inline void debug(int level, const char *format, ...)
inline void debug(int level, const char *format, ...)
{
{
  char *p;
  char *p;
  va_list ap;
  va_list ap;
Line 155... Line 155...
/* Resets all subunits */
/* Resets all subunits */
void sim_reset (void)
void sim_reset (void)
{
{
  struct sim_reset_hook *cur_reset = sim_reset_hooks;
  struct sim_reset_hook *cur_reset = sim_reset_hooks;
 
 
  SCHED_INIT();
  /* We absolutely MUST reset the scheduler first */
 
  sched_reset();
 
 
  while(cur_reset) {
  while(cur_reset) {
    cur_reset->reset_hook(cur_reset->dat);
    cur_reset->reset_hook(cur_reset->dat);
    cur_reset = cur_reset->next;
    cur_reset = cur_reset->next;
  }
  }
Line 178... Line 179...
  init_labels();
  init_labels();
  init_breakpoints();
  init_breakpoints();
  initstats();
  initstats();
  build_automata();
  build_automata();
 
 
 
  sched_init();
 
 
  if (config.sim.profile) {
  if (config.sim.profile) {
    runtime.sim.fprof = fopen(config.sim.prof_fn, "wt+");
    runtime.sim.fprof = fopen(config.sim.prof_fn, "wt+");
    if(!runtime.sim.fprof) {
    if(!runtime.sim.fprof) {
      fprintf(stderr, "ERROR: Problems opening profile file.\n");
      fprintf(stderr, "ERROR: Problems opening profile file.\n");
      exit (1);
      exit (1);
Line 325... Line 328...
}
}
 
 
/* Executes jobs in time queue */
/* Executes jobs in time queue */
static inline void do_scheduler ()
static inline void do_scheduler ()
{
{
  void (*func)(void *);
  struct sched_entry *tmp;
  void *param;
 
 
 
  /* Execute all jobs till now */
  /* Execute all jobs till now */
  do {
  do {
    func = SCHED_PEEK().func;
    tmp = scheduler.job_queue;
    param = SCHED_PEEK().param;
    scheduler.job_queue = tmp->next;
    SCHED_REMOVE();
    tmp->next = scheduler.free_job_queue;
    func (param);
    scheduler.free_job_queue = tmp;
  } while (runtime.sim.cycles >= SCHED_PEEK().time);
 
 
    tmp->func (tmp->param);
 
  } while (scheduler.job_queue->time <= 0);
}
}
 
 
/* Main function */
/* Main function */
int main(argc, argv)
int main(argc, argv)
     int argc;
     int argc;
Line 397... Line 401...
              || config.sim.history || config.sim.exe_log;
              || config.sim.history || config.sim.exe_log;
    }
    }
 
 
    /* MM: 'run -1' means endless execution.  */
    /* MM: 'run -1' means endless execution.  */
    while(runtime.sim.cont_run) {
    while(runtime.sim.cont_run) {
 
      long long time_start = runtime.sim.cycles;
      if (config.debug.enabled) {
      if (config.debug.enabled) {
        du_clock(); // reset watchpoints
        du_clock(); // reset watchpoints
        if (runtime.cpu.stalled) {
        if (runtime.cpu.stalled) {
          if(config.debug.gdb_enabled) {
          if(config.debug.gdb_enabled) {
            BlockJTAG();
            BlockJTAG();
Line 428... Line 433...
      if (config.debug.gdb_enabled) HandleServerSocket(false); /* block & check_stdin = false */
      if (config.debug.gdb_enabled) HandleServerSocket(false); /* block & check_stdin = false */
      if(config.debug.enabled)
      if(config.debug.enabled)
        if (testsprbits(SPR_DMR1, SPR_DMR1_ST)) set_stall_state (1);
        if (testsprbits(SPR_DMR1, SPR_DMR1_ST)) set_stall_state (1);
 
 
      runtime.sim.cycles += runtime.sim.mem_cycles;
      runtime.sim.cycles += runtime.sim.mem_cycles;
      if (runtime.sim.cycles >= SCHED_PEEK().time) do_scheduler ();
      scheduler.job_queue->time -= runtime.sim.cycles - time_start;
 
      if (scheduler.job_queue->time <= 0) do_scheduler ();
      if (!runtime.sim.hush) dumpreg();
      if (!runtime.sim.hush) dumpreg();
    }
    }
    runtime.sim.hush = 0;
    runtime.sim.hush = 0;
    fflush(stdout);
    fflush(stdout);
    runtime.sim.fout = stdout;
    runtime.sim.fout = stdout;

powered by: WebSVN 2.1.0

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