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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_52/] [or1ksim/] [support/] [dumpverilog.c] - Blame information for rev 55

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
   Copyright (C) 2000 Damjan Lampret, lampret@opencores.org
3
 
4
This file is part of OpenRISC 1000 Architectural Simulator.
5
 
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
 
20
/* Verilog dump can be used for stimulating OpenRISC Verilog RTL models. */
21
 
22
#include <stdio.h>
23
#include <ctype.h>
24
#include <string.h>
25
 
26
#include "config.h"
27
#include "sim-config.h"
28
 
29
#include "parse.h"
30
#include "abstract.h"
31
#include "arch.h"
32
#include "trace.h"
33
#include "execute.h"
34
#include "sprs.h"
35
#include "stats.h"
36
#include "except.h"
37
#include "dumpverilog.h"
38
 
39
extern struct mem_entry mem[MEMORY_LEN];
40
extern char rcsrev[];
41
 
42
void dumpverilog(char *verilog_modname, unsigned int from, unsigned int to)
43
{
44
        unsigned int i, done = 0;
45
        struct label_entry *tmp;
46
 
47
        printf("// This file was generated by or1ksim %s\n", rcsrev);
48
        printf(OR1K_MEM_VERILOG_HEADER(verilog_modname, from/DWQ, to/DWQ));
49
 
50
        for(i = from; i < to && i < (MEMORY_START + MEMORY_LEN); i++) {
51
                if (mem[i].insn) {
52
                        tmp = mem[i].label;
53
                        for(; tmp; tmp = tmp->next)
54
                                printf("\n//\t%s%s", tmp->name, LABELEND_CHAR);
55
 
56
                        printf("\n\tmem['h%x] = %d'h%.2x%.2x", i/DWQ, DW, mem[i].data, mem[i+1].data);
57
                        printf("%.2x%.2x;", mem[i+2].data, mem[i+3].data);
58
                        if (mem[i].insn)
59
                                printf("\n\tdis['h%x] = {\"%s\t%s\"", i/DWQ, mem[i].insn->insn, mem[i].insn->op1);
60
                        if (strlen(mem[i].insn->op2))
61
                                printf(",\"%s%s\"", OPERAND_DELIM, mem[i].insn->op2);
62
                        if (strlen(mem[i].insn->op3))
63
                                printf(",\"%s%s\"", OPERAND_DELIM, mem[i].insn->op3);
64
                        if (strlen(mem[i].insn->op4))
65
                                printf(",\"%s%s\"", OPERAND_DELIM, mem[i].insn->op4);
66
                        printf("};");
67
                        i += (insn_len(mem[i].insn->insn) - 1);
68
                } else
69
                {
70
                        if (i % 64 == 0)
71
                                printf("\n");
72
 
73
                        printf("\n\tmem['h%x] = 'h%.2x;", i/DWQ, (unsigned char)mem[i].data);
74
                }
75
                done = 1;
76
        }
77
 
78
        if (done) {
79
                printf(OR1K_MEM_VERILOG_FOOTER);
80
                return;
81
        }
82
 
83
        /* this needs to be fixed */
84
 
85
        for(i = from; i < to; i++) {
86
                if (i % 8 == 0)
87
                        printf("\n%.8x:  ", i);
88
 
89
                /* don't print ascii chars below 0x20. */
90
                if (eval_mem32(i) < 0x20)
91
                        printf("0x%.2x     ", (unsigned char)eval_mem32(i));
92
                else
93
                        printf("0x%.2x'%c'  ", (unsigned char)eval_mem32(i), (unsigned char)eval_mem32(i));
94
 
95
        }
96
        printf(OR1K_MEM_VERILOG_FOOTER);
97
}

powered by: WebSVN 2.1.0

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