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 7 and 16

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

Rev 7 Rev 16
Line 18... Line 18...
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
/* Simulator commands. Help and version output. SIGINT processing.
/* Simulator commands. Help and version output. SIGINT processing.
Stdout redirection is specific to linux (I need to fix this). */
Stdout redirection is specific to linux (I need to fix this). */
 
 
 
#include "config.h"
 
 
#include <stdio.h>
#include <stdio.h>
#include <ctype.h>
#include <ctype.h>
#include <string.h>
#include <string.h>
#include <stdlib.h>
#include <stdlib.h>
#include <signal.h>
#include <signal.h>
#include <stdarg.h>
#include <stdarg.h>
 
 
 
#ifdef HAVE_LIBREADLINE
#include <readline/readline.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <readline/history.h>
 
#endif /* HAVE_LIBREADLINE */
 
 
#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"
 
 
/* CVS revision number. */
/* CVS revision number. */
static const char rcsrev[] = "$Revision: 1.3 $";
static const char rcsrev[] = "$Revision: 1.4 $";
 
 
/* 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",
  "t",
  "help",
  "help",
  "dm",
  "dm",
Line 125... Line 128...
main(argc, argv)
main(argc, argv)
     int argc;
     int argc;
     char *argv[];
     char *argv[];
{
{
        char *linestr;
        char *linestr;
        char item1[500];
        char item1[500], b2[500];
        char *redirstr;
        char *redirstr;
        int hush;
        int hush;
 
 
        if (argc != 2)
        if (argc != 2)
    {
    {
      printf("Usage: %s <filename>\n", argv[0]);
      printf("Usage: %s <filename>\n", argv[0]);
      exit(-1);
      exit(-1);
    }
    }
 
 
 
#ifdef HAVE_LIBREADLINE
  initialize_readline ();       /* Bind our completer. */
  initialize_readline ();       /* Bind our completer. */
 
#endif  
 
 
        version();
        version();
        init_defconfig();
        init_defconfig();
        signal(SIGINT, ctrl_c);
        signal(SIGINT, ctrl_c);
        initstats();
        initstats();
        loadcode(argv[1]);
        loadcode(argv[1]);
        reset();
        reset();
 
 
        while(1)
        while(1)
    {
    {
 
#ifdef HAVE_LIBREADLINE
      linestr = readline("(sim) ");
      linestr = readline("(sim) ");
 
#else
 
      printf ("(sim) ");
 
      linestr = fgets(b2, sizeof b2, stdin);
 
#endif
 
 
      if (!linestr)
      if (!linestr)
        {
        {
          break;
          break;
        }
        }
      linestr = stripwhite (linestr);
      linestr = stripwhite (linestr);
 
 
 
#ifdef HAVE_LIBREADLINE
      if (strlen(linestr) == 0)
      if (strlen(linestr) == 0)
        {
        {
          char *l = repeat_last_command ();
          char *l = repeat_last_command ();
 
 
          if (l)
          if (l)
Line 169... Line 180...
 
 
      if (*linestr)
      if (*linestr)
        {
        {
          add_history (linestr);
          add_history (linestr);
        }
        }
 
#endif /* HAVE_LIBREADLINE */
 
 
      if (redirstr = strstr(linestr, ">"))
      if (redirstr = strstr(linestr, ">"))
        {
        {
          *redirstr = '\0';
          *redirstr = '\0';
          strtoken(&redirstr[1], item1, 1);
          strtoken(&redirstr[1], item1, 1);
Line 296... Line 308...
 
 
                hush = 0;
                hush = 0;
                fflush(stdout);
                fflush(stdout);
                freopen("/dev/fd/0", "w+", stdout);
                freopen("/dev/fd/0", "w+", stdout);
 
 
 
#ifdef HAVE_LIBREADLINE
    if (linestr)
    if (linestr)
      free (linestr);
      free (linestr);
 
#endif
 
 
        }
        }
        exit(0);
        exit(0);
}
}
 
 
 
#ifdef HAVE_LIBREADLINE
char *command_generator ();
char *command_generator ();
char **sim_completion ();
char **sim_completion ();
 
 
/* Tell the GNU readline library how to complete.  We want to try to complete
/* Tell the GNU readline library how to complete.  We want to try to complete
   on command names if this is the first word in the line, or on filenames
   on command names if this is the first word in the line, or on filenames
Line 374... Line 389...
 
 
  /* If no names matched, then return NULL. */
  /* If no names matched, then return NULL. */
  return ((char *)NULL);
  return ((char *)NULL);
}
}
 
 
 
 
/* Strip whitespace from the start and end of STRING.  Return a pointer
 
   into STRING. */
 
char *
 
stripwhite (string)
 
     char *string;
 
{
 
  register char *s, *t;
 
 
 
  for (s = string; whitespace (*s); s++)
 
    ;
 
 
 
  if (*s == 0)
 
    return (s);
 
 
 
  t = s + strlen (s) - 1;
 
  while (t > s && whitespace (*t))
 
    t--;
 
  *++t = '\0';
 
 
 
  return s;
 
}
 
 
 
char *
char *
dupstr (s)
dupstr (s)
     char *s;
     char *s;
{
{
  char *r;
  char *r;
Line 422... Line 414...
      return dupstr (hist->line);
      return dupstr (hist->line);
    }
    }
  return 0;
  return 0;
}
}
 
 
 No newline at end of file
 No newline at end of file
 
#endif
 
 
 
/* Strip whitespace from the start and end of STRING.  Return a pointer
 
   into STRING. */
 
#ifndef whitespace
 
#define whitespace(a)   ((a) == '\t' ? 1 : ((a) == ' '? 1 : 0))
 
#endif
 
 
 
char *
 
stripwhite (string)
 
     char *string;
 
{
 
  register char *s, *t;
 
 
 
  for (s = string; whitespace (*s); s++)
 
    ;
 
 
 
  if (*s == 0)
 
    return (s);
 
 
 
  t = s + strlen (s) - 1;
 
  while (t > s && whitespace (*t))
 
    t--;
 
  *++t = '\0';
 
 
 
  return s;
 
}
 
 
 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.