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

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_2_x/] [or1ksim/] [support/] [dumpverilog.c] - Blame information for rev 1350

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 55 lampret
#include "sim-config.h"
35 1350 nogj
#include "arch.h"
36 55 lampret
#include "parse.h"
37
#include "abstract.h"
38 1344 nogj
#include "opcode/or32.h"
39 261 markom
#include "labels.h"
40 55 lampret
#include "execute.h"
41
#include "sprs.h"
42
#include "stats.h"
43
#include "except.h"
44
#include "dumpverilog.h"
45
 
46
extern char rcsrev[];
47 138 markom
extern char *disassembled;
48 55 lampret
 
49
void dumpverilog(char *verilog_modname, unsigned int from, unsigned int to)
50
{
51 138 markom
  unsigned int i, done = 0;
52
  struct label_entry *tmp;
53 221 markom
  char dis[DISWIDTH + 100];
54 997 markom
  PRINTF("// This file was generated by or1ksim %s\n", rcsrev);
55
  PRINTF(OR1K_MEM_VERILOG_HEADER(verilog_modname, from/DWQ, to/DWQ, (DISWIDTH*8)));
56 138 markom
 
57 221 markom
  for(i = from; i < to; i++)
58
    {
59
      unsigned int _insn = evalsim_mem32 (i);
60 138 markom
      int index = insn_decode(_insn);
61
      if (index >= 0)
62 237 erez
        {
63 261 markom
          if (verify_memoryarea(i) && (tmp = get_label(i)))
64
          if (tmp)
65 997 markom
            PRINTF("\n//\t%s%s", tmp->name, LABELEND_CHAR);
66 138 markom
 
67 1350 nogj
          PRINTF("\n\tmem['h%x] = %d'h%.8"PRIx32";", i/DWQ, DW, evalsim_mem32(i));
68 138 markom
 
69 237 erez
          disassemble_insn (_insn);
70
          strcpy (dis, disassembled);
71 138 markom
 
72 237 erez
          if (strlen(dis) < DISWIDTH)
73
            memset(dis + strlen(dis), ' ', DISWIDTH);
74
          dis[DISWIDTH] = '\0';
75 997 markom
          PRINTF("\n\tdis['h%x] = {\"%s\"};", i/DWQ, dis);
76 237 erez
          dis[0] = '\0';
77
          i += insn_len(index) - 1;
78
        } else {
79
          if (i % 64 == 0)
80 997 markom
            PRINTF("\n");
81 138 markom
 
82 997 markom
          PRINTF("\n\tmem['h%x] = 'h%.2x;", i/DWQ, evalsim_mem8(i));
83 237 erez
        }
84 138 markom
      done = 1;
85
    }
86
 
87
  if (done)
88
    {
89 997 markom
      PRINTF(OR1K_MEM_VERILOG_FOOTER);
90 138 markom
      return;
91
    }
92
 
93
  /* this needs to be fixed */
94
 
95
  for(i = from; i < to; i++)
96
    {
97
      if (i % 8 == 0)
98 997 markom
        PRINTF("\n%.8x:  ", i);
99 138 markom
 
100
      /* don't print ascii chars below 0x20. */
101 221 markom
      if (evalsim_mem32(i) < 0x20)
102 997 markom
        PRINTF("0x%.2x     ", (unsigned char)evalsim_mem32(i));
103 138 markom
      else
104 997 markom
        PRINTF("0x%.2x'%c'  ", (unsigned char)evalsim_mem32(i), (unsigned char)evalsim_mem32(i));
105 138 markom
    }
106 997 markom
  PRINTF(OR1K_MEM_VERILOG_FOOTER);
107 55 lampret
}
108 85 lampret
 
109
void dumphex(unsigned int from, unsigned int to)
110
{
111 1308 phoenix
  unsigned int i;
112 138 markom
 
113 221 markom
  for(i = from; i < to; i++) {
114
    unsigned int _insn = evalsim_mem32 (i);
115 138 markom
    int index = insn_decode(_insn);
116
    if (index >= 0)
117 221 markom
      {
118 1350 nogj
              PRINTF("%.8"PRIx32"\n", evalsim_mem32(i));
119 221 markom
 
120
              i += insn_len(index) - 1;
121 138 markom
      }
122
    else
123 997 markom
      PRINTF("%.2x\n", evalsim_mem8(i));
124 138 markom
  }
125 85 lampret
}

powered by: WebSVN 2.1.0

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