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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [or1ksim/] [support/] [dumpverilog.c] - Blame information for rev 1484

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 55 lampret
/* dumpverilog.c -- Dumps memory region as Verilog representation
2 85 lampret
   or as hex code
3 55 lampret
   Copyright (C) 2000 Damjan Lampret, lampret@opencores.org
4
 
5
This file is part of OpenRISC 1000 Architectural Simulator.
6
 
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
11
 
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20 237 erez
 
21 55 lampret
/* Verilog dump can be used for stimulating OpenRISC Verilog RTL models. */
22
 
23
#include <stdio.h>
24
#include <ctype.h>
25
#include <string.h>
26
 
27
#include "config.h"
28 1350 nogj
 
29
#ifdef HAVE_INTTYPES_H
30
#include <inttypes.h>
31
#endif
32
 
33
#include "port.h"
34 1358 nogj
#include "arch.h"
35 55 lampret
#include "sim-config.h"
36
#include "parse.h"
37
#include "abstract.h"
38 1344 nogj
#include "opcode/or32.h"
39 1432 nogj
#include "spr_defs.h"
40 261 markom
#include "labels.h"
41 55 lampret
#include "execute.h"
42
#include "sprs.h"
43
#include "stats.h"
44
#include "except.h"
45
#include "dumpverilog.h"
46
 
47
extern char rcsrev[];
48 138 markom
extern char *disassembled;
49 55 lampret
 
50
void dumpverilog(char *verilog_modname, unsigned int from, unsigned int to)
51
{
52 138 markom
  unsigned int i, done = 0;
53
  struct label_entry *tmp;
54 221 markom
  char dis[DISWIDTH + 100];
55 1484 nogj
  int breakpoint;
56 997 markom
  PRINTF("// This file was generated by or1ksim %s\n", rcsrev);
57
  PRINTF(OR1K_MEM_VERILOG_HEADER(verilog_modname, from/DWQ, to/DWQ, (DISWIDTH*8)));
58 138 markom
 
59 221 markom
  for(i = from; i < to; i++)
60
    {
61 1484 nogj
      unsigned int _insn = eval_direct32 (i, &breakpoint, 0, 0);
62 138 markom
      int index = insn_decode(_insn);
63
      if (index >= 0)
64 237 erez
        {
65 261 markom
          if (verify_memoryarea(i) && (tmp = get_label(i)))
66
          if (tmp)
67 997 markom
            PRINTF("\n//\t%s%s", tmp->name, LABELEND_CHAR);
68 138 markom
 
69 1484 nogj
          PRINTF("\n\tmem['h%x] = %d'h%.8"PRIx32";", i/DWQ, DW,
70
                 eval_direct32(i, &breakpoint, 0, 0));
71 138 markom
 
72 237 erez
          disassemble_insn (_insn);
73
          strcpy (dis, disassembled);
74 138 markom
 
75 237 erez
          if (strlen(dis) < DISWIDTH)
76
            memset(dis + strlen(dis), ' ', DISWIDTH);
77
          dis[DISWIDTH] = '\0';
78 997 markom
          PRINTF("\n\tdis['h%x] = {\"%s\"};", i/DWQ, dis);
79 237 erez
          dis[0] = '\0';
80
          i += insn_len(index) - 1;
81
        } else {
82
          if (i % 64 == 0)
83 997 markom
            PRINTF("\n");
84 138 markom
 
85 1484 nogj
          PRINTF("\n\tmem['h%x] = 'h%.2x;", i/DWQ,
86
                 eval_direct8(i, &breakpoint, 0, 0));
87 237 erez
        }
88 138 markom
      done = 1;
89
    }
90
 
91
  if (done)
92
    {
93 997 markom
      PRINTF(OR1K_MEM_VERILOG_FOOTER);
94 138 markom
      return;
95
    }
96
 
97
  /* this needs to be fixed */
98
 
99
  for(i = from; i < to; i++)
100
    {
101
      if (i % 8 == 0)
102 997 markom
        PRINTF("\n%.8x:  ", i);
103 138 markom
 
104
      /* don't print ascii chars below 0x20. */
105 1484 nogj
      if (eval_direct32(i, &breakpoint, 0, 0) < 0x20)
106
        PRINTF("0x%.2x     ", (uint8_t)eval_direct32(i, &breakpoint, 0, 0));
107 138 markom
      else
108 1484 nogj
        PRINTF("0x%.2x'%c'  ", (uint8_t)eval_direct32(i, &breakpoint, 0, 0),
109
               (char)eval_direct32(i, &breakpoint, 0, 0));
110 138 markom
    }
111 997 markom
  PRINTF(OR1K_MEM_VERILOG_FOOTER);
112 55 lampret
}
113 85 lampret
 
114
void dumphex(unsigned int from, unsigned int to)
115
{
116 1308 phoenix
  unsigned int i;
117 1484 nogj
  int breakpoint;
118 138 markom
 
119 221 markom
  for(i = from; i < to; i++) {
120 1484 nogj
    unsigned int _insn = eval_direct32 (i, &breakpoint, 0, 0);
121 138 markom
    int index = insn_decode(_insn);
122
    if (index >= 0)
123 221 markom
      {
124 1484 nogj
              PRINTF("%.8"PRIx32"\n", eval_direct32(i, &breakpoint, 0, 0));
125 221 markom
 
126
              i += insn_len(index) - 1;
127 138 markom
      }
128
    else
129 1484 nogj
      PRINTF("%.2x\n", eval_direct8(i, &breakpoint, 0, 0));
130 138 markom
  }
131 85 lampret
}

powered by: WebSVN 2.1.0

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