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

Subversion Repositories or1k

[/] [or1k/] [tags/] [tn_m001/] [or1ksim/] [toplevel.c] - Diff between revs 344 and 361

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

Rev 344 Rev 361
Line 50... Line 50...
#include "coff.h"
#include "coff.h"
 
 
#include "gdbcomm.h"
#include "gdbcomm.h"
 
 
/* CVS revision number. */
/* CVS revision number. */
const char rcsrev[] = "$Revision: 1.45 $";
const char rcsrev[] = "$Revision: 1.46 $";
 
 
/* Continuos run versus single step tracing switch. */
/* Continuos run versus single step tracing switch. */
int cont_run;
int cont_run;
 
 
/* History of execution */
/* History of execution */
int histexec[HISTEXEC_LEN];
int histexec[HISTEXEC_LEN];
 
 
char *sim_commands [] = {
char *sim_commands [] = {
  "q",
  "q", "t", "help", "de", "dm", "run", "pr", "pm", "pc",
  "t",
  "reset", "break", "hist", "stats", "stall" "info",
  "help",
  "r", "dv", "set", 0
  "de",
 
  "dm",
 
  "run",
 
  "pr",
 
  "pm",
 
  "pc",
 
  "reset",
 
  "break",
 
  "hist",
 
  "stats",
 
  "stall"
 
  "info",
 
  "r",
 
  "dv",
 
  0
 
};
};
 
 
inline void debug(int level, const char *format, ...)
inline void debug(int level, const char *format, ...)
{
{
  char *p;
  char *p;
Line 156... Line 141...
        printf("stall                    - stalls the processor and gives control to the debugger\n");
        printf("stall                    - stalls the processor and gives control to the debugger\n");
        printf("stats <num|clear>        - execution statistics num or clear it.\n");
        printf("stats <num|clear>        - execution statistics num or clear it.\n");
        printf("info                     - configuration info (caches etc.)\n");
        printf("info                     - configuration info (caches etc.)\n");
        printf("dv <fromaddr> [<toaddr>] [<modname>] - dumps memory as verilog (use redirect)\n");
        printf("dv <fromaddr> [<toaddr>] [<modname>] - dumps memory as verilog (use redirect)\n");
        printf("dh <fromaddr> [<toaddr>] - dumps memory as hex code (use redirect)\n");
        printf("dh <fromaddr> [<toaddr>] - dumps memory as hex code (use redirect)\n");
 
  printf("set <section> <item> = <param>  - set configuration.  See sim.cfg for more information.\n");
        printf("<cmd> > <filename>       - redirect simulator stdout to <filename> (and not emulated printf)\n");
        printf("<cmd> > <filename>       - redirect simulator stdout to <filename> (and not emulated printf)\n");
        printf("debug                    - toggles simulator debug mode\n");
        printf("debug                    - toggles simulator debug mode\n");
        printf("help                     - available commands (this list)\n");
        printf("help                     - available commands (this list)\n");
}
}
 
 
Line 175... Line 161...
 
 
  if (GDB_ENABLED)
  if (GDB_ENABLED)
    gdbcomm_init ();
    gdbcomm_init ();
 
 
  if (config.sim.profile) {
  if (config.sim.profile) {
    config.sim.fprof = fopen(config.sim.prof_fn, "wt+");
    runtime.sim.fprof = fopen(config.sim.prof_fn, "wt+");
    if(!config.sim.fprof) {
    if(!runtime.sim.fprof) {
      config.sim.profile = 0;
      config.sim.profile = 0;
      fprintf(stderr, "WARNING: Problems opening profile file. Profiling disabled. \n");
      fprintf(stderr, "WARNING: Problems opening profile file. Profiling disabled. \n");
    } else
    } else
      fprintf(config.sim.fprof, "+00000000 FFFFFFFF FFFFFFFF main\n");
      fprintf(runtime.sim.fprof, "+00000000 FFFFFFFF FFFFFFFF main\n");
  }
  }
 
 
  if (config.sim.exe_log) {
  if (config.sim.exe_log) {
    config.sim.fexe_log = fopen(config.sim.exe_log_fn, "wt+");
    runtime.sim.fexe_log = fopen(config.sim.exe_log_fn, "wt+");
    if(!config.sim.fexe_log) {
    if(!runtime.sim.fexe_log) {
      config.sim.exe_log = 0;
      config.sim.exe_log = 0;
      printf("WARNING: Problems opening exe_log file. Execution logging disabled. \n");
      printf("WARNING: Problems opening exe_log file. Execution logging disabled. \n");
    }
    }
  }
  }
 
 
Line 220... Line 206...
      fprintf(stderr, "Invalid memory configuration type.\n");
      fprintf(stderr, "Invalid memory configuration type.\n");
            exit(1);
            exit(1);
    }
    }
  }
  }
 
 
        if(config.filename) {
  if(runtime.sim.filename) {
          unsigned long endaddr = 0xFFFFFFFF;
          unsigned long endaddr = 0xFFFFFFFF;
          endaddr = loadcode(config.filename, 0, 0); /* MM170901 always load at address zero.  */
    endaddr = loadcode(runtime.sim.filename, 0, 0); /* MM170901 always load at address zero.  */
          if (endaddr == -1) {
          if (endaddr == -1) {
            fprintf(stderr, "Problems loading boot code.\n");
            fprintf(stderr, "Problems loading boot code.\n");
            exit(1);
            exit(1);
          }
          }
        }
        }
Line 281... Line 267...
            }
            }
            printf ("\n");
            printf ("\n");
          }
          }
          printf ("All devices connected                         \n");
          printf ("All devices connected                         \n");
        }
        }
 
  /* simulator is initialized */
 
  runtime.sim.init = 0;
}
}
 
 
/* Display info about various modules */
/* Display info about various modules */
void sim_info () {
void sim_info () {
  itlb_status(-1);
  itlb_status(-1);
Line 303... Line 291...
/* Cleanup */
/* Cleanup */
void sim_done ()
void sim_done ()
{
{
  if (config.sim.profile) {
  if (config.sim.profile) {
    extern int cycles;
    extern int cycles;
    fprintf(config.sim.fprof,"-%08X FFFFFFFF\n", cycles);
    fprintf(runtime.sim.fprof,"-%08X FFFFFFFF\n", cycles);
    fclose(config.sim.fprof);
    fclose(runtime.sim.fprof);
  }
  }
  if (config.sim.exe_log)   fclose(config.sim.fexe_log);
  if (config.sim.exe_log)   fclose(runtime.sim.fexe_log);
  if (config.vapi.enabled)  vapi_done ();
  if (config.vapi.enabled)  vapi_done ();
  exit(0);
  exit(0);
}
}
 
 
int main(argc, argv)
int main(argc, argv)
Line 329... Line 317...
        if (parse_args(argc, argv)) {
        if (parse_args(argc, argv)) {
                printf("Usage: %s [options] <filename>\n", argv[0]);
                printf("Usage: %s [options] <filename>\n", argv[0]);
                printf("Options:\n");
                printf("Options:\n");
                printf(" -v                 version and copyright note\n");
                printf(" -v                 version and copyright note\n");
                printf(" -i                 enable interactive command prompt\n");
                printf(" -i                 enable interactive command prompt\n");
                printf(" -f or --file       change script file [sim.cfg]\n");
    printf(" -f or --file       load script file [sim.cfg]\n");
                printf(" --nosrv            do not launch JTAG proxy server\n"); /* (CZ) */
                printf(" --nosrv            do not launch JTAG proxy server\n"); /* (CZ) */
                printf(" --srv <n>          launch JTAG proxy server on port <n>; [random]\n"); /* (CZ) */
                printf(" --srv <n>          launch JTAG proxy server on port <n>; [random]\n"); /* (CZ) */
                printf(" --profile          enable profiling\n");
                printf(" --profile          enable profiling\n");
                exit(-1);
                exit(-1);
        }
        }
Line 341... Line 329...
#ifdef HAVE_LIBREADLINE
#ifdef HAVE_LIBREADLINE
  initialize_readline ();       /* Bind our completer. */
  initialize_readline ();       /* Bind our completer. */
#endif
#endif
 
 
  /* Read configuration file.  */
  /* Read configuration file.  */
  read_script_file (config.script_file);
  if (!runtime.sim.script_file_specified)
 
    read_script_file ("sim.cfg");
  print_config();
  print_config();
  sim_init ();
  sim_init ();
  signal(SIGINT, ctrl_c);
  signal(SIGINT, ctrl_c);
 
 
        while(1) {
        while(1) {
Line 577... Line 566...
                } else
                } else
                if (!strcmp(item1, "trace")) { /* Added by CZ 210801 */
                if (!strcmp(item1, "trace")) { /* Added by CZ 210801 */
                  char item2[256];
                  char item2[256];
 
 
                  strtoken(linestr, item2, 2);
                  strtoken(linestr, item2, 2);
                  if(trace_fd)
      if(trace_fd) {
                    {
 
                      close(trace_fd);
                      close(trace_fd);
                      trace_fd = 0;
                      trace_fd = 0;
                    }
                    }
                  if(strcmp(item2,"off")) /* if we're not being turned off */
                  if(strcmp(item2,"off")) /* if we're not being turned off */
                    {
                    {
                      if(item2[0])
                      if(item2[0])
                        trace_fd = open(item2,O_CREAT | O_NOCTTY |
                        trace_fd = open(item2,O_CREAT | O_NOCTTY |
                                        O_TRUNC | O_WRONLY, 0644);
                                        O_TRUNC | O_WRONLY, 0644);
                      else
                      else
                        trace_fd = dup(1);
                        trace_fd = dup(1);
                      if(trace_fd < 0)
          if(trace_fd < 0) {
                        {
 
                          perror(item2[0]?item2:"stdout");
                          perror(item2[0]?item2:"stdout");
                          trace_fd = 0;
                          trace_fd = 0;
                        }
                        }
                    }
                    }
                } else
                } else
Line 612... Line 599...
                        }
                        }
                } else
                } else
                if (strcmp(item1, "info") == 0) /* configuration info */
                if (strcmp(item1, "info") == 0) /* configuration info */
                        sim_info ();
                        sim_info ();
                else
                else
 
    if (strcmp(item1, "set") == 0) { /* configuration info */
 
      char *s = linestr;
 
      int i;
 
      extern section;
 
      extern struct section sections[];
 
      while (*s != ' ' && *s) s++;
 
      set_config_command (s);
 
    } else
                        printf("%s: Unknown command.\n", linestr);
                        printf("%s: Unknown command.\n", linestr);
 
 
 
 
                /* MM: 'run -1' means endless execution.  */
                /* MM: 'run -1' means endless execution.  */
                while(cont_run != 0) {
                while(cont_run != 0) {

powered by: WebSVN 2.1.0

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