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

Subversion Repositories or1k_old

[/] [or1k_old/] [tags/] [stable_0_2_0_rc3/] [or1ksim/] [toplevel.c] - Diff between revs 1455 and 1471

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

Rev 1455 Rev 1471
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.124 $";
const char rcsrev[] = "$Revision: 1.125 $";
 
 
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 99... Line 99...
}
}
 
 
void ctrl_c(signum)
void ctrl_c(signum)
     int signum;
     int signum;
{
{
  runtime.sim.cont_run = runtime.cpu.stalled ? 0 : 1;
 
  runtime.sim.iprompt = 1;
  runtime.sim.iprompt = 1;
  set_stall_state (0);
 
  signal(SIGINT, ctrl_c);
  signal(SIGINT, ctrl_c);
}
}
 
 
void version()
/* Periodically checks runtime.sim.iprompt to see if ctrl_c has been pressed */
 
void check_int(void *dat)
 
{
 
  if(runtime.sim.iprompt) {
 
    set_stall_state (0);
 
    handle_sim_command();
 
  }
 
  SCHED_ADD(check_int, NULL, CHECK_INT_TIME);
 
}
 
 
 
void version(void)
{
{
  PRINTF ("\n");
  PRINTF ("\n");
  PRINTF ("OpenRISC 1000 (OR32) Architectural Simulator, %s\n", rcsrev);
  PRINTF ("OpenRISC 1000 (OR32) Architectural Simulator, %s\n", rcsrev);
  PRINTF ("Copyright (C) 1999 Damjan Lampret, lampret@opencores.org\n");
  PRINTF ("Copyright (C) 1999 Damjan Lampret, lampret@opencores.org\n");
  PRINTF ("Copyright (C) 2000 Damjan Lampret, lampret@opencores.org\n");
  PRINTF ("Copyright (C) 2000 Damjan Lampret, lampret@opencores.org\n");
Line 168... Line 176...
  tick_reset();
  tick_reset();
  pm_reset();
  pm_reset();
  pic_reset();
  pic_reset();
  du_reset ();
  du_reset ();
 
 
 
  /* Make sure that runtime.sim.iprompt is the first thing to get checked */
 
  SCHED_ADD(check_int, NULL, 0);
 
 
  lock_memory_table ();
  lock_memory_table ();
 
 
  /* FIXME: Lame-ass way to get runtime.sim.mem_cycles not going into overly
  /* FIXME: Lame-ass way to get runtime.sim.mem_cycles not going into overly
   * negative numbers.  This happens because parse.c uses setsim_mem32 to load
   * negative numbers.  This happens because parse.c uses setsim_mem32 to load
   * the program but set_mem32 calls dc_simulate_write, which inturn calls
   * the program but set_mem32 calls dc_simulate_write, which inturn calls
Line 365... Line 376...
 
 
    tmp->func (tmp->param);
    tmp->func (tmp->param);
  } while (scheduler.job_queue->time <= 0);
  } while (scheduler.job_queue->time <= 0);
}
}
 
 
 
void recalc_do_stats(void)
 
{
 
  extern int do_stats;
 
  do_stats = config.cpu.dependstats || config.cpu.superscalar ||
 
             config.cpu.dependstats || config.sim.history || config.sim.exe_log;
 
}
 
 
/* Main function */
/* Main function */
int main(argc, argv)
int main(argc, argv)
     int argc;
     int argc;
     char *argv[];
     char *argv[];
{
{
Line 401... Line 419...
  if (runtime.simcmd.mprofile) config.sim.mprofile = 1;
  if (runtime.simcmd.mprofile) config.sim.mprofile = 1;
 
 
  if (!runtime.sim.script_file_specified && config.sim.verbose)
  if (!runtime.sim.script_file_specified && config.sim.verbose)
    fprintf (stderr, "WARNING: No config file read, assuming default configuration.\n");
    fprintf (stderr, "WARNING: No config file read, assuming default configuration.\n");
  print_config();
  print_config();
  sim_init ();
 
  signal(SIGINT, ctrl_c);
  signal(SIGINT, ctrl_c);
 
 
  runtime.sim.hush = 1;
  runtime.sim.hush = 1;
  runtime.sim.cont_run = -1;
  recalc_do_stats();
 
 
  while(1) {
  sim_init ();
    if (runtime.sim.iprompt)
 
        handle_sim_command();
 
 
 
    { /* Needed by execution */
 
      extern int do_stats;
 
      do_stats = config.cpu.dependstats || config.cpu.superscalar || config.cpu.dependstats
 
              || config.sim.history || config.sim.exe_log;
 
    }
 
 
 
    /* MM: 'run -1' means endless execution.  */
  while(1) {
    while(runtime.sim.cont_run) {
 
      long long time_start = runtime.sim.cycles;
      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) {
      while (runtime.cpu.stalled) {
          if(config.debug.gdb_enabled) {
          if(config.debug.gdb_enabled) {
            BlockJTAG();
            BlockJTAG();
            HandleServerSocket(false);
            HandleServerSocket(false);
          } else {
          } else {
            fprintf (stderr, "WARNING: CPU stalled and gdb connection not enabled.");
          fprintf (stderr, "WARNING: CPU stalled and gdb connection not enabled.\n");
            runtime.sim.cont_run = 0;
          /* Dump the user into interactive mode.  From there he can decide what
 
           * to do. */
 
          handle_sim_command();
 
          sim_done();
          }
          }
          continue;
        if(runtime.sim.iprompt)
 
          handle_sim_command();
        }
        }
      }
      }
 
 
      /* Each cycle has counter of mem_cycles; this value is joined with cycles
      /* Each cycle has counter of mem_cycles; this value is joined with cycles
         at the end of the cycle; no sim originated memory accesses should be
         at the end of the cycle; no sim originated memory accesses should be
         performed inbetween. */
         performed inbetween. */
      runtime.sim.mem_cycles = 0;
      runtime.sim.mem_cycles = 0;
      if (!config.pm.enabled || !testsprbits(SPR_PMR, SPR_PMR_DME | SPR_PMR_SME)) {
    if (!config.pm.enabled || !testsprbits(SPR_PMR, SPR_PMR_DME | SPR_PMR_SME))
        if (runtime.sim.cont_run > 0) runtime.sim.cont_run--;
      if (cpu_clock ())
        if (cpu_clock ()) break;
        /* A breakpoint has been hit, drop to interactive mode */
      }
        handle_sim_command();
 
 
      if (config.vapi.enabled && runtime.vapi.enabled) vapi_check();
      if (config.vapi.enabled && runtime.vapi.enabled) vapi_check();
      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;
      scheduler.job_queue->time -= runtime.sim.cycles - time_start;
      scheduler.job_queue->time -= runtime.sim.cycles - time_start;
      if (scheduler.job_queue->time <= 0) do_scheduler ();
      if (scheduler.job_queue->time <= 0) do_scheduler ();
      if (!runtime.sim.hush) dumpreg();
 
    }
 
    runtime.sim.hush = 0;
 
    fflush(stdout);
 
    runtime.sim.fout = stdout;
 
 
 
    if (!runtime.sim.iprompt)  /* non-interactive quit */
 
      sim_done();
 
  }
  }
  sim_done();
  sim_done();
}
}
 
 
 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.