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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [or1ksim/] [or1ksim-0.4.0rc2/] [cpu/] [or32/] [generate.c] - Diff between revs 19 and 82

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

Rev 19 Rev 82
Line 73... Line 73...
    return 1;
    return 1;
  }
  }
 
 
  while (!feof (fi)) {
  while (!feof (fi)) {
    char line[10000], *str = line;
    char line[10000], *str = line;
    fgets (str, sizeof (line), fi);
    char *res;
 
 
 
    res = fgets (str, sizeof (line), fi);
 
 
 
    if (NULL == res)
 
      {
 
        return  1;
 
      }
 
 
    line[sizeof (line) - 1] = 0;
    line[sizeof (line) - 1] = 0;
    line_num++;
    line_num++;
    if (strncmp (str, "INSTRUCTION (", 13) == 0) {
    if (strncmp (str, "INSTRUCTION (", 13) == 0) {
      char *s;
      char *s;
      str += 13;
      str += 13;
Line 98... Line 106...
        *s = 0;
        *s = 0;
        /*shift_fprintf (level, fo, "#line %i \"%s\"\n", line_num, in_file);*/
        /*shift_fprintf (level, fo, "#line %i \"%s\"\n", line_num, in_file);*/
        shift_fprintf (level, fo, "%s", str);
        shift_fprintf (level, fo, "%s", str);
        shift_fprintf (level, fo, "   /* \"%s\" */\n", func_name);
        shift_fprintf (level, fo, "   /* \"%s\" */\n", func_name);
        do {
        do {
          fgets (line, sizeof (line), fi);
          res = fgets (line, sizeof (line), fi);
 
 
 
          if (NULL == res)
 
            {
 
              return  1;
 
            }
 
 
          line[sizeof(line) - 1] = 0;
          line[sizeof(line) - 1] = 0;
          for (str = line; *str; str++) {
          for (str = line; *str; str++) {
            if (*str == '{') olevel++;
            if (*str == '{') olevel++;
            else if (*str == '}') olevel--;
            else if (*str == '}') olevel--;
          }
          }
Line 310... Line 324...
  fprintf (fo, "}\n");
  fprintf (fo, "}\n");
  return 0;
  return 0;
}
}
 
 
/* Decodes all instructions and generates code for that.  This function
/* Decodes all instructions and generates code for that.  This function
   is similar to insn_decode, except it decodes all instructions. */
   is similar to insn_decode, except it decodes all instructions.
 
 
 
   JPB: Added code to generate an illegal instruction exception for invalid
 
   instructions. */
static int generate_body (FILE *fo, unsigned long *a, unsigned long cur_mask, int level)
static int generate_body (FILE *fo, unsigned long *a, unsigned long cur_mask, int level)
{
{
  unsigned long shift = *a;
  unsigned long shift = *a;
  unsigned long mask;
  unsigned long mask;
  int i;
  int i;
Line 340... Line 357...
        prev_inv = 0;
        prev_inv = 0;
      }
      }
    }
    }
    if (prev_inv) {
    if (prev_inv) {
      shift_fprintf (++level, fo, "/* Invalid instruction(s) */\n");
      shift_fprintf (++level, fo, "/* Invalid instruction(s) */\n");
 
      shift_fprintf (level, fo,
 
                     "except_handle (EXCEPT_ILLEGAL, cpu_state.pc);\n");
      shift_fprintf (level--, fo, "break;\n");
      shift_fprintf (level--, fo, "break;\n");
    }
    }
    shift_fprintf (level, fo, "}\n");
    shift_fprintf (level, fo, "}\n");
  } else {
  } else {
    i = *a & ~LEAF_FLAG;
    i = *a & ~LEAF_FLAG;

powered by: WebSVN 2.1.0

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