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

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc1/] [or1ksim/] [support/] [dumpverilog.c] - Blame information for rev 1765

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
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 1557 nogj
  PRINTF("// This file was generated by or1ksim version %s\n", or1ksim_ver);
56 997 markom
  PRINTF(OR1K_MEM_VERILOG_HEADER(verilog_modname, from/DWQ, to/DWQ, (DISWIDTH*8)));
57 138 markom
 
58 221 markom
  for(i = from; i < to; i++)
59
    {
60 1487 nogj
      unsigned int _insn = eval_direct32 (i, 0, 0);
61 138 markom
      int index = insn_decode(_insn);
62
      if (index >= 0)
63 237 erez
        {
64 261 markom
          if (verify_memoryarea(i) && (tmp = get_label(i)))
65
          if (tmp)
66 997 markom
            PRINTF("\n//\t%s%s", tmp->name, LABELEND_CHAR);
67 138 markom
 
68 1484 nogj
          PRINTF("\n\tmem['h%x] = %d'h%.8"PRIx32";", i/DWQ, DW,
69 1487 nogj
                 eval_direct32(i, 0, 0));
70 138 markom
 
71 237 erez
          disassemble_insn (_insn);
72
          strcpy (dis, disassembled);
73 138 markom
 
74 237 erez
          if (strlen(dis) < DISWIDTH)
75
            memset(dis + strlen(dis), ' ', DISWIDTH);
76
          dis[DISWIDTH] = '\0';
77 997 markom
          PRINTF("\n\tdis['h%x] = {\"%s\"};", i/DWQ, dis);
78 237 erez
          dis[0] = '\0';
79
          i += insn_len(index) - 1;
80
        } else {
81
          if (i % 64 == 0)
82 997 markom
            PRINTF("\n");
83 138 markom
 
84 1484 nogj
          PRINTF("\n\tmem['h%x] = 'h%.2x;", i/DWQ,
85 1487 nogj
                 eval_direct8(i, 0, 0));
86 237 erez
        }
87 138 markom
      done = 1;
88
    }
89
 
90
  if (done)
91
    {
92 997 markom
      PRINTF(OR1K_MEM_VERILOG_FOOTER);
93 138 markom
      return;
94
    }
95
 
96
  /* this needs to be fixed */
97
 
98
  for(i = from; i < to; i++)
99
    {
100
      if (i % 8 == 0)
101 997 markom
        PRINTF("\n%.8x:  ", i);
102 138 markom
 
103
      /* don't print ascii chars below 0x20. */
104 1487 nogj
      if (eval_direct32(i, 0, 0) < 0x20)
105
        PRINTF("0x%.2x     ", (uint8_t)eval_direct32(i, 0, 0));
106 138 markom
      else
107 1487 nogj
        PRINTF("0x%.2x'%c'  ", (uint8_t)eval_direct32(i, 0, 0),
108
               (char)eval_direct32(i, 0, 0));
109 138 markom
    }
110 997 markom
  PRINTF(OR1K_MEM_VERILOG_FOOTER);
111 55 lampret
}
112 85 lampret
 
113
void dumphex(unsigned int from, unsigned int to)
114
{
115 1308 phoenix
  unsigned int i;
116 138 markom
 
117 221 markom
  for(i = from; i < to; i++) {
118 1487 nogj
    unsigned int _insn = eval_direct32 (i, 0, 0);
119 138 markom
    int index = insn_decode(_insn);
120
    if (index >= 0)
121 221 markom
      {
122 1487 nogj
              PRINTF("%.8"PRIx32"\n", eval_direct32(i, 0, 0));
123 221 markom
 
124
              i += insn_len(index) - 1;
125 138 markom
      }
126
    else
127 1487 nogj
      PRINTF("%.2x\n", eval_direct8(i, 0, 0));
128 138 markom
  }
129 85 lampret
}

powered by: WebSVN 2.1.0

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