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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_59/] [or1ksim/] [toplevel.c] - Diff between revs 883 and 884

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

Rev 883 Rev 884
Line 58... Line 58...
#include "mprofiler.h"
#include "mprofiler.h"
#include "mc.h"
#include "mc.h"
#include "atahost.h"
#include "atahost.h"
 
 
/* CVS revision number. */
/* CVS revision number. */
const char rcsrev[] = "$Revision: 1.88 $";
const char rcsrev[] = "$Revision: 1.89 $";
 
 
/* Continuos run versus single step tracing switch. */
 
int cont_run;
 
 
 
/* History of execution */
/* History of execution */
int histexec[HISTEXEC_LEN];
int histexec[HISTEXEC_LEN];
 
 
char *sim_commands [] = {
char *sim_commands [] = {
Line 107... Line 104...
}
}
 
 
void ctrl_c(signum)
void ctrl_c(signum)
     int signum;
     int signum;
{
{
  cont_run = cpu_stalled ? 0 : 1;
  runtime.sim.cont_run = runtime.cpu.stalled ? 0 : 1;
  runtime.sim.iprompt = 1;
  runtime.sim.iprompt = 1;
  set_stall_state (0);
  set_stall_state (0);
  signal(SIGINT, ctrl_c);
  signal(SIGINT, ctrl_c);
}
}
 
 
Line 202... Line 199...
    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);
    } else
    } else
      fprintf(runtime.sim.fprof, "+00000000 FFFFFFFF FFFFFFFF total\n");
      fprintf(runtime.sim.fprof, "+00000000 FFFFFFFF FFFFFFFF [outside functions]\n");
  }
  }
 
 
  if (config.sim.mprofile) {
  if (config.sim.mprofile) {
    runtime.sim.fmprof = fopen(config.sim.mprof_fn, "wb+");
    runtime.sim.fmprof = fopen(config.sim.mprof_fn, "wb+");
    if(!runtime.sim.fmprof) {
    if(!runtime.sim.fmprof) {
Line 357... Line 354...
 
 
/* Cleanup */
/* Cleanup */
void sim_done ()
void sim_done ()
{
{
  if (config.sim.profile) {
  if (config.sim.profile) {
    extern int cycles;
    fprintf(runtime.sim.fprof,"-%08X FFFFFFFF\n", runtime.sim.cycles);
    fprintf(runtime.sim.fprof,"-%08X FFFFFFFF\n", cycles);
 
    fclose(runtime.sim.fprof);
    fclose(runtime.sim.fprof);
  }
  }
 
 
  if (config.sim.mprofile) fclose(runtime.sim.fmprof);
  if (config.sim.mprofile) fclose(runtime.sim.fmprof);
  if (config.sim.exe_log)   fclose(runtime.sim.fexe_log);
  if (config.sim.exe_log)   fclose(runtime.sim.fexe_log);
Line 381... Line 377...
  do {
  do {
    func = SCHED_PEEK().func;
    func = SCHED_PEEK().func;
    param = SCHED_PEEK().param;
    param = SCHED_PEEK().param;
    SCHED_REMOVE();
    SCHED_REMOVE();
    func (param);
    func (param);
  } while (cycles >= SCHED_PEEK().time);
  } while (runtime.sim.cycles >= SCHED_PEEK().time);
}
}
 
 
/* Main function */
/* Main function */
int main(argc, argv)
int main(argc, argv)
     int argc;
     int argc;
Line 444... Line 440...
  }
  }
  print_config();
  print_config();
  sim_init ();
  sim_init ();
  signal(SIGINT, ctrl_c);
  signal(SIGINT, ctrl_c);
 
 
#warning REMOVE ME!
 
    main_cuc (runtime.sim.filename);
 
 
 
  while(1) {
  while(1) {
    if (runtime.sim.iprompt) {
    if (runtime.sim.iprompt) {
      if (config.debug.gdb_enabled)
      if (config.debug.gdb_enabled)
        {
        {
          printf ("(sim) ");
          printf ("(sim) ");
Line 513... Line 506...
    } else
    } else
    if (strcmp(item1, "help") == 0) /* help */
    if (strcmp(item1, "help") == 0) /* help */
      help();
      help();
    else
    else
    if (strcmp(item1, "t") == 0) {  /* trace */
    if (strcmp(item1, "t") == 0) {  /* trace */
      cont_run = 1;
      runtime.sim.cont_run = 1;
    } else
    } else
    if (strcmp(item1, "dm") == 0) { /* dump memory */
    if (strcmp(item1, "dm") == 0) { /* dump memory */
      char item2[20];
      char item2[20];
      char item3[20];
      char item3[20];
      static int from = 0, to = 0;
      static int from = 0, to = 0;
Line 661... Line 654...
      strtoken(linestr, item3, 3);
      strtoken(linestr, item3, 3);
      if (strcmp(item3, "hush") == 0)
      if (strcmp(item3, "hush") == 0)
        hush = 1;
        hush = 1;
      else
      else
        hush = 0;
        hush = 0;
      cont_run = strtol(item2, NULL, 0);
      runtime.sim.cont_run = strtol(item2, NULL, 0);
    } else
    } else
    if(!strcmp(item1, "stall")) { /* Added by CZ 210801 */
    if(!strcmp(item1, "stall")) { /* Added by CZ 210801 */
      set_stall_state (1);
      set_stall_state (1);
      runtime.sim.iprompt = 0;
      runtime.sim.iprompt = 0;
      cont_run = -1;
      runtime.sim.cont_run = -1;
      hush = 1;
      hush = 1;
    } else
    } else
    if (strcmp(item1, "stats") == 0) { /* stats */
    if (strcmp(item1, "stats") == 0) { /* stats */
      char item2[20];
      char item2[20];
      int i = 0;
      int i = 0;
Line 717... Line 710...
      do_stats = config.cpu.dependstats || config.cpu.superscalar || config.cpu.dependstats
      do_stats = config.cpu.dependstats || config.cpu.superscalar || config.cpu.dependstats
              || 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(cont_run) {
    while(runtime.sim.cont_run) {
      extern int mem_cycles;
 
 
 
      IFF (config.debug.enabled) {
      IFF (config.debug.enabled) {
        if (cpu_stalled) {
        if (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.");
            cont_run = 0;
            runtime.sim.cont_run = 0;
          }
          }
          continue;
          continue;
        }
        }
      }
      }
 
 
      /* 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. */
      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 (cont_run > 0) cont_run--;
        if (runtime.sim.cont_run > 0) runtime.sim.cont_run--;
        pic_clock ();
        pic_clock ();
        if (cpu_clock ()) break;
        if (cpu_clock ()) break;
        if (config.dc.enabled) dc_clock();
        if (config.dc.enabled) dc_clock();
        if (config.ic.enabled) ic_clock();
        if (config.ic.enabled) ic_clock();
      }
      }
Line 753... Line 744...
      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 */
      IFF(config.debug.enabled)
      IFF(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);
 
 
      cycles += mem_cycles;
      runtime.sim.cycles += runtime.sim.mem_cycles;
      if (cycles >= SCHED_PEEK().time) do_scheduler ();
      if (runtime.sim.cycles >= SCHED_PEEK().time) do_scheduler ();
      if (!hush) dumpreg();
      if (!hush) dumpreg();
    }
    }
    hush = 0;
    hush = 0;
    fflush(stdout);
    fflush(stdout);
    freopen("/dev/fd/0", "w+", stdout);
    freopen("/dev/fd/0", "w+", stdout);

powered by: WebSVN 2.1.0

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