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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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