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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_61/] [or1ksim/] [sim-config.c] - Blame information for rev 103

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 jrydberg
/* config.c -- Simulator configuration
2
   Copyright (C) 1999 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
/* Simulator configuration. Eventually this one will be a lot bigger. */
21
 
22 103 lampret
#include <stdio.h>
23 7 jrydberg
#include "sim-config.h"
24 30 lampret
#include "abstract.h"
25 103 lampret
#include "spr_defs.h"
26 7 jrydberg
 
27
struct config config;
28
 
29
void init_defconfig()
30
{
31 103 lampret
        unsigned long val;
32
 
33 30 lampret
        memset(&config, 0, sizeof(config));
34
        config.dc.tagtype = VIRTUAL;
35 78 lampret
        config.ic.tagtype = VIRTUAL;
36 103 lampret
        config.bp.bpb_sim = 1;
37
        config.bp.btic_sim = 1;
38 30 lampret
        config.clkcycle_ns = 4; /* 4 for 4ns (250MHz) */
39
        config.uarts[0].rxfile = "/tmp/uart0.rx";
40
        config.uarts[0].txfile = "/tmp/uart0.tx";
41
        config.uarts[0].baseaddr = 0x80000000;
42
        config.ram.startaddr = MEMORY_START;
43
        config.ram.endaddr = MEMORY_START + MEMORY_LEN;
44 103 lampret
        config.simdebug = 0;
45
        config.iprompt = 0;
46
        config.dependstats = 1;
47
        config.dependency = 1;
48
        config.history = 1;
49
        config.superscalar = 1;
50
        config.slp = 1;
51
 
52
        mtspr(SPR_VR, SPR_VR_VER & 0x1200);
53
 
54
        val = SPR_UPR_UP | SPR_UPR_DCP | SPR_UPR_ICP | SPR_UPR_DMP |
55
        SPR_UPR_IMP | SPR_UPR_OB32P | SPR_UPR_DUP | SPR_UPR_PICP |
56
        SPR_UPR_PMP | SPR_UPR_TTP;
57
 
58
        mtspr(SPR_UPR, val);
59
}
60
 
61
int parse_args(int argc, char *argv[])
62
{
63
        unsigned long val;
64
 
65
        argv++; argc--;
66
        while (argc) {
67
                if (argc && (*argv[0] != '-'))
68
                        return 0;
69
 
70
                if (strcmp(*argv, "-i") == 0) {
71
                        config.iprompt = 1;
72
                        argv++; argc--;
73
                } else
74
                if (strcmp(*argv, "-v") == 0) {
75
                        version();
76
                        exit(0);
77
                } else
78
                if (strcmp(*argv, "-bpb") == 0) {
79
                        config.bp.bpb_sim = 0;
80
                        argv++; argc--;
81
                } else
82
                if (strcmp(*argv, "-hazards") == 0) {
83
                        config.dependstats = 0;
84
                        config.dependency = 0;
85
                        argv++; argc--;
86
                } else
87
                if (strcmp(*argv, "-history") == 0) {
88
                        config.history = 0;
89
                        argv++; argc--;
90
                } else
91
                if (strcmp(*argv, "-superscalar") == 0) {
92
                        config.superscalar = 0;
93
                        argv++; argc--;
94
                } else
95
                if (strcmp(*argv, "-fast") == 0) {
96
                        config.superscalar = 0;
97
                        config.history = 0;
98
                        config.dependstats = 0;
99
                        config.dependency = 0;
100
                        config.bp.bpb_sim = 0;
101
                        config.bp.btic_sim = 0;
102
                        config.slp = 0;
103
                        argv++; argc--;
104
                } else
105
                if (strcmp(*argv, "-btic") == 0) {
106
                        config.bp.btic_sim = 0;
107
                        argv++; argc--;
108
                } else
109
                if (strcmp(*argv, "-upr") == 0) {
110
                        argv++; argc--;
111
                        val = strtoul(*argv, NULL, 0);
112
                        mtspr(SPR_UPR, val);
113
                        argv++; argc--;
114
                } else
115
                if (strcmp(*argv, "-ver") == 0) {
116
                        argv++; argc--;
117
                        val = strtoul(*argv, NULL, 0);
118
                        setsprbits(SPR_VR, SPR_VR_VER, val);
119
                        argv++; argc--;
120
                } else
121
                if (strcmp(*argv, "-rev") == 0) {
122
                        argv++; argc--;
123
                        val = strtoul(*argv, NULL, 0);
124
                        setsprbits(SPR_VR, SPR_VR_REV, val);
125
                        argv++; argc--;
126
                } else {
127
                        printf("Unknown option: %s\n", *argv);
128
                        return 1;
129
                }
130
        }
131
 
132
        if (!argc)
133
                return 0;
134
 
135
        return 0;
136
}
137
 
138
void print_config()
139
{
140
        printf("Machine initialization...\n");
141
        if (getsprbits(SPR_UPR, SPR_UPR_DCP))
142
                printf("Data cache tag: %s\n", config.dc.tagtype == VIRTUAL ? "virtual" : "physical");
143
        else
144
                printf("No data cache.\n");
145
        if (getsprbits(SPR_UPR, SPR_UPR_ICP))
146
                printf("Insn cache tag: %s\n", config.ic.tagtype == VIRTUAL ? "virtual" : "physical");
147
        else
148
                printf("No instruction cache.\n");
149
        if (config.bp.bpb_sim)
150
                printf("BPB simulation on.\n");
151
        else
152
                printf("BPB simulation off.\n");
153
        if (config.bp.btic_sim)
154
                printf("BTIC simulation on.\n");
155
        else
156
                printf("BTIC simulation off.\n");
157
        printf("Clock cycle: %d ns\n", config.clkcycle_ns);
158 30 lampret
        printf("RAM: 0x%x to ", config.ram.startaddr);
159
        printf("0x%x (", config.ram.endaddr);
160
        printf("%d KB)\n\n", (config.ram.endaddr - config.ram.startaddr) / 1024);
161 103 lampret
        if (config.simdebug)
162
                printf("simdebug on, ");
163
        else
164
                printf("simdebug off, ");
165
        if (config.iprompt)
166
                printf("interactive prompt on\n");
167
        else
168
                printf("interactive prompt off\n");
169 7 jrydberg
}

powered by: WebSVN 2.1.0

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