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

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc2/] [or1ksim/] [support/] [dumpverilog.c] - Blame information for rev 1780

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 1557 nogj
extern char *or1ksim_ver;
48 138 markom
extern char *disassembled;
49 55 lampret
 
50 1604 nogj
void dumpverilog(char *verilog_modname, oraddr_t from, oraddr_t to)
51 55 lampret
{
52 138 markom
  unsigned int i, done = 0;
53
  struct label_entry *tmp;
54 221 markom
  char dis[DISWIDTH + 100];
55 1604 nogj
  uint32_t insn;
56
  int index;
57 1557 nogj
  PRINTF("// This file was generated by or1ksim version %s\n", or1ksim_ver);
58 997 markom
  PRINTF(OR1K_MEM_VERILOG_HEADER(verilog_modname, from/DWQ, to/DWQ, (DISWIDTH*8)));
59 138 markom
 
60 1604 nogj
  for(i = from; i < to; i++) {
61
    if(!(i & 3)) {
62
      insn = eval_direct32(i, 0, 0);
63
      index = insn_decode(insn);
64
      if (index >= 0) {
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 1487 nogj
                 eval_direct32(i, 0, 0));
71 138 markom
 
72 1604 nogj
          disassemble_insn (insn);
73 237 erez
          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 1604 nogj
          done = 1;
82
          continue;
83
      }
84 138 markom
    }
85 1604 nogj
 
86
    if (i % 64 == 0)
87
      PRINTF("\n");
88 138 markom
 
89 1604 nogj
    PRINTF("\n\tmem['h%x] = 'h%.2x;", i/DWQ, eval_direct8(i, 0, 0));
90
    done = 1;
91
  }
92
 
93 138 markom
  if (done)
94
    {
95 997 markom
      PRINTF(OR1K_MEM_VERILOG_FOOTER);
96 138 markom
      return;
97
    }
98
 
99
  /* this needs to be fixed */
100
 
101
  for(i = from; i < to; i++)
102
    {
103
      if (i % 8 == 0)
104 997 markom
        PRINTF("\n%.8x:  ", i);
105 138 markom
 
106
      /* don't print ascii chars below 0x20. */
107 1487 nogj
      if (eval_direct32(i, 0, 0) < 0x20)
108
        PRINTF("0x%.2x     ", (uint8_t)eval_direct32(i, 0, 0));
109 138 markom
      else
110 1487 nogj
        PRINTF("0x%.2x'%c'  ", (uint8_t)eval_direct32(i, 0, 0),
111
               (char)eval_direct32(i, 0, 0));
112 138 markom
    }
113 997 markom
  PRINTF(OR1K_MEM_VERILOG_FOOTER);
114 55 lampret
}
115 85 lampret
 
116 1604 nogj
void dumphex(oraddr_t from, oraddr_t to)
117 85 lampret
{
118 1604 nogj
  oraddr_t i;
119
  uint32_t insn;
120
  int index;
121 138 markom
 
122 221 markom
  for(i = from; i < to; i++) {
123 1604 nogj
    if(!(i & 3)) {
124
      insn = eval_direct32(i, 0, 0);
125
      index = insn_decode(insn);
126
      if(index >= 0) {
127
        PRINTF("%.8"PRIx32"\n", eval_direct32(i, 0, 0));
128
        i += insn_len(index) - 1;
129
        continue;
130 138 markom
      }
131 1604 nogj
    }
132
    PRINTF("%.2x\n", eval_direct8(i, 0, 0));
133 138 markom
  }
134 85 lampret
}

powered by: WebSVN 2.1.0

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