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

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc2/] [or1ksim/] [toplevel.c] - Diff between revs 54 and 69

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

Rev 54 Rev 69
Line 38... Line 38...
#include "arch.h"
#include "arch.h"
#include "parse.h"
#include "parse.h"
#include "abstract.h"
#include "abstract.h"
#include "trace.h"
#include "trace.h"
#include "execute.h"
#include "execute.h"
 
#include "sim-config.h"
 
 
#include "coff.h"
#include "coff.h"
 
 
/* CVS revision number. */
/* CVS revision number. */
const char rcsrev[] = "$Revision: 1.10 $";
const char rcsrev[] = "$Revision: 1.11 $";
 
 
/* 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 */
Line 72... Line 73...
  0
  0
};
};
 
 
void debug(const char *format, ...)
void debug(const char *format, ...)
{
{
#if DEBUG
 
  char *p;
  char *p;
  va_list ap;
  va_list ap;
 
 
 
  if (config.simdebug) {
 
    if ((p = malloc(1000)) == NULL)
 
      return;
 
    va_start(ap, format);
 
    (void) vsnprintf(p, 1000, format, ap);
 
    va_end(ap);
 
    printf("%s\n", p);
 
    fflush(stdout);
 
    free(p);
 
  } else {
 
#if DEBUG
  if ((p = malloc(1000)) == NULL)
  if ((p = malloc(1000)) == NULL)
    return;
    return;
  va_start(ap, format);
  va_start(ap, format);
  (void) vsnprintf(p, 1000, format, ap);
  (void) vsnprintf(p, 1000, format, ap);
  va_end(ap);
  va_end(ap);
  printf("%s\n", p);
  printf("%s\n", p);
  fflush(stdout);
  fflush(stdout);
  free(p);
  free(p);
#endif
#endif
 
  }
  return;
  return;
}
}
 
 
/* Strip whitespace from the start and end of STRING.  Return a pointer
/* Strip whitespace from the start and end of STRING.  Return a pointer
   into STRING. */
   into STRING. */
Line 158... Line 170...
        printf("hist                     - execution history\n");
        printf("hist                     - execution history\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("<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("help                     - available commands (this list)\n");
        printf("help                     - available commands (this list)\n");
}
}
 
 
void debugmem();
void debugmem();
 
 
Line 171... Line 184...
{
{
        char *linestr;
        char *linestr;
        char item1[500], b2[500];
        char item1[500], b2[500];
        char *redirstr;
        char *redirstr;
        int hush;
        int hush;
 
        unsigned long endaddr;
 
 
        if (argc != 2)
        if (argc != 2)
    {
    {
      printf("Usage: %s <filename>\n", argv[0]);
      printf("Usage: %s <filename>\n", argv[0]);
      exit(-1);
      exit(-1);
Line 187... Line 201...
        srand(getpid());
        srand(getpid());
        version();
        version();
        init_defconfig();
        init_defconfig();
        signal(SIGINT, ctrl_c);
        signal(SIGINT, ctrl_c);
        initstats();
        initstats();
        loadcode(argv[1]);
        memset(mem, 0, sizeof(mem));
 
        endaddr = loadcode(argv[1], MEMORY_START, 0);
 
        if (endaddr == -1) {
 
                printf("Problems loading boot code.\n");
 
                exit(1);
 
        }
        uart_reset();
        uart_reset();
        reset();
        reset();
 
        set_reg32("r3", endaddr);
 
 
        while(1)
        while(1)
    {
    {
#ifdef HAVE_LIBREADLINE
#ifdef HAVE_LIBREADLINE
      linestr = readline("(sim) ");
      linestr = readline("(sim) ");
Line 329... Line 349...
                } else
                } else
                if (strcmp(item1, "reset") == 0) {       /* reset simulator */
                if (strcmp(item1, "reset") == 0) {       /* reset simulator */
                        uart_reset();
                        uart_reset();
                        reset();
                        reset();
                } else
                } else
 
                if (strcmp(item1, "debug") == 0) {       /* debug mode */
 
                        config.simdebug ^= 1;
 
                } else
                if (strcmp(item1, "hist") == 0) {        /* dump history */
                if (strcmp(item1, "hist") == 0) {        /* dump history */
                        int i;
                        int i;
                        for(i = HISTEXEC_LEN; i; i--)
                        for(i = HISTEXEC_LEN; i; i--)
                                dumpmemory(histexec[i - 1], histexec[i - 1] + 4);
                                dumpmemory(histexec[i - 1], histexec[i - 1] + 4);
                        printf("\n");
                        printf("\n");
Line 367... Line 390...
                        btic_info();
                        btic_info();
                        ic_info();
                        ic_info();
                        dc_info();
                        dc_info();
                        uart_status();
                        uart_status();
                        sprs_status();
                        sprs_status();
 
                        dtlb_status(-1);
                } else {
                } else {
      printf("%s: Unknown command.\n", linestr);
      printf("%s: Unknown command.\n", linestr);
    }
    }
 
 
                while(cont_run) {
                while(cont_run) {

powered by: WebSVN 2.1.0

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