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 75

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 60 lampret
        char dis[DISWIDTH + 100];
47 55 lampret
 
48
        printf("// This file was generated by or1ksim %s\n", rcsrev);
49 60 lampret
        printf(OR1K_MEM_VERILOG_HEADER(verilog_modname, from/DWQ, to/DWQ, (DISWIDTH*8)));
50 55 lampret
 
51
        for(i = from; i < to && i < (MEMORY_START + MEMORY_LEN); i++) {
52
                if (mem[i].insn) {
53
                        tmp = mem[i].label;
54
                        for(; tmp; tmp = tmp->next)
55
                                printf("\n//\t%s%s", tmp->name, LABELEND_CHAR);
56
 
57
                        printf("\n\tmem['h%x] = %d'h%.2x%.2x", i/DWQ, DW, mem[i].data, mem[i+1].data);
58
                        printf("%.2x%.2x;", mem[i+2].data, mem[i+3].data);
59
                        if (mem[i].insn)
60 60 lampret
                                sprintf(dis, "%s  %s", mem[i].insn->insn, mem[i].insn->op1);
61 55 lampret
                        if (strlen(mem[i].insn->op2))
62 60 lampret
                                sprintf(dis, "%s%s%s", dis, OPERAND_DELIM, mem[i].insn->op2);
63 55 lampret
                        if (strlen(mem[i].insn->op3))
64 60 lampret
                                sprintf(dis, "%s%s%s", dis, OPERAND_DELIM, mem[i].insn->op3);
65 55 lampret
                        if (strlen(mem[i].insn->op4))
66 60 lampret
                                sprintf(dis, "%s%s%s", dis, OPERAND_DELIM, mem[i].insn->op4);
67
                        if (strlen(dis) < DISWIDTH)
68
                                memset(dis + strlen(dis), ' ', DISWIDTH);
69
                        dis[DISWIDTH] = '\0';
70
                        printf("\n\tdis['h%x] = {\"%s\"};", i/DWQ, dis);
71
                        dis[0] = '\0';
72 55 lampret
                        i += (insn_len(mem[i].insn->insn) - 1);
73
                } else
74
                {
75
                        if (i % 64 == 0)
76
                                printf("\n");
77
 
78
                        printf("\n\tmem['h%x] = 'h%.2x;", i/DWQ, (unsigned char)mem[i].data);
79
                }
80
                done = 1;
81
        }
82
 
83
        if (done) {
84
                printf(OR1K_MEM_VERILOG_FOOTER);
85
                return;
86
        }
87
 
88
        /* this needs to be fixed */
89
 
90
        for(i = from; i < to; i++) {
91
                if (i % 8 == 0)
92
                        printf("\n%.8x:  ", i);
93
 
94
                /* don't print ascii chars below 0x20. */
95 75 lampret
                if (evalsim_mem32(i) < 0x20)
96
                        printf("0x%.2x     ", (unsigned char)evalsim_mem32(i));
97 55 lampret
                else
98 75 lampret
                        printf("0x%.2x'%c'  ", (unsigned char)evalsim_mem32(i), (unsigned char)evalsim_mem32(i));
99 55 lampret
 
100
        }
101
        printf(OR1K_MEM_VERILOG_FOOTER);
102
}

powered by: WebSVN 2.1.0

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