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 123

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 123 markom
        config.dc.tagtype = NONE/*VIRTUAL*/;
35
        config.ic.tagtype = NONE/*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 123 markom
          if (argc && (*argv[0] != '-')) {
68
                    config.filename = argv[0];
69
                    argc--;
70
                    argv++;
71
                 } else
72
                 if (strncmp(*argv, "-loadmem",8) == 0) {  /* (CZ) */
73
                        MemoryBlock** block = &config.memory;
74
                        int address = 0;
75
 
76
                        if(!--argc)
77
                          return 1;
78
 
79
                        if(argv[0][8] == '@')
80
                          {
81
                            char *s;
82
 
83
                            address = strtol(address,&s,0);
84
                            if(*s)
85
                              return 1;
86
                          }
87
                        else if(argv[0][8])
88
                          return 1;
89
 
90
                        while(*block)
91
                          block = &(*block)->next;
92
                        *block = (MemoryBlock*)malloc(sizeof(MemoryBlock));
93
                        memset(*block,0,sizeof(MemoryBlock));
94
                        (*block)->address = address;
95
                        (*block)->file = *(++argv);
96
                        argv++; argc--;
97
                } else
98
                if (strcmp(*argv, "-initmem") == 0) {  /* (CZ) */
99
                        char *pattern,*s;
100
                        if(!--argc)
101
                          return 1;
102
                        pattern = *(++argv);
103
                        if(!strcmp(pattern,"random"))
104
                          config.random_mem = 1;
105
                        else
106
                          {
107
                            val = strtol(pattern,&s,0);
108
                            if(*s)
109
                              return 1;
110
                            config.pattern_mem = val;
111
                          }
112
                } else
113
                if (strcmp(*argv, "-nosrv") == 0) {  /* (CZ) */
114
                        config.inhibit_server = 1;
115
                        argv++; argc--;
116
                } else
117
                if (strcmp(*argv, "-srv") == 0) {  /* (CZ) */
118
                        char *s;
119
                        if(!--argc)
120
                          return 1;
121
                        config.server_port = strtol(*(++argv),&s,10);
122
                        if(*s)
123
                          return 1;
124
                        argv++; argc--;
125
                } else
126 103 lampret
                if (strcmp(*argv, "-i") == 0) {
127
                        config.iprompt = 1;
128
                        argv++; argc--;
129
                } else
130
                if (strcmp(*argv, "-v") == 0) {
131
                        version();
132
                        exit(0);
133
                } else
134
                if (strcmp(*argv, "-bpb") == 0) {
135
                        config.bp.bpb_sim = 0;
136
                        argv++; argc--;
137
                } else
138
                if (strcmp(*argv, "-hazards") == 0) {
139
                        config.dependstats = 0;
140
                        config.dependency = 0;
141
                        argv++; argc--;
142
                } else
143
                if (strcmp(*argv, "-history") == 0) {
144
                        config.history = 0;
145
                        argv++; argc--;
146
                } else
147
                if (strcmp(*argv, "-superscalar") == 0) {
148
                        config.superscalar = 0;
149
                        argv++; argc--;
150
                } else
151
                if (strcmp(*argv, "-fast") == 0) {
152
                        config.superscalar = 0;
153
                        config.history = 0;
154
                        config.dependstats = 0;
155
                        config.dependency = 0;
156
                        config.bp.bpb_sim = 0;
157
                        config.bp.btic_sim = 0;
158
                        config.slp = 0;
159
                        argv++; argc--;
160
                } else
161
                if (strcmp(*argv, "-btic") == 0) {
162
                        config.bp.btic_sim = 0;
163
                        argv++; argc--;
164
                } else
165
                if (strcmp(*argv, "-upr") == 0) {
166
                        argv++; argc--;
167
                        val = strtoul(*argv, NULL, 0);
168
                        mtspr(SPR_UPR, val);
169
                        argv++; argc--;
170
                } else
171
                if (strcmp(*argv, "-ver") == 0) {
172
                        argv++; argc--;
173
                        val = strtoul(*argv, NULL, 0);
174
                        setsprbits(SPR_VR, SPR_VR_VER, val);
175
                        argv++; argc--;
176
                } else
177
                if (strcmp(*argv, "-rev") == 0) {
178
                        argv++; argc--;
179
                        val = strtoul(*argv, NULL, 0);
180
                        setsprbits(SPR_VR, SPR_VR_REV, val);
181
                        argv++; argc--;
182
                } else {
183
                        printf("Unknown option: %s\n", *argv);
184
                        return 1;
185
                }
186
        }
187
 
188
        if (!argc)
189
                return 0;
190
 
191
        return 0;
192
}
193
 
194
void print_config()
195
{
196
        printf("Machine initialization...\n");
197
        if (getsprbits(SPR_UPR, SPR_UPR_DCP))
198
                printf("Data cache tag: %s\n", config.dc.tagtype == VIRTUAL ? "virtual" : "physical");
199
        else
200
                printf("No data cache.\n");
201
        if (getsprbits(SPR_UPR, SPR_UPR_ICP))
202
                printf("Insn cache tag: %s\n", config.ic.tagtype == VIRTUAL ? "virtual" : "physical");
203
        else
204
                printf("No instruction cache.\n");
205
        if (config.bp.bpb_sim)
206
                printf("BPB simulation on.\n");
207
        else
208
                printf("BPB simulation off.\n");
209
        if (config.bp.btic_sim)
210
                printf("BTIC simulation on.\n");
211
        else
212
                printf("BTIC simulation off.\n");
213
        printf("Clock cycle: %d ns\n", config.clkcycle_ns);
214 30 lampret
        printf("RAM: 0x%x to ", config.ram.startaddr);
215
        printf("0x%x (", config.ram.endaddr);
216
        printf("%d KB)\n\n", (config.ram.endaddr - config.ram.startaddr) / 1024);
217 103 lampret
        if (config.simdebug)
218
                printf("simdebug on, ");
219
        else
220
                printf("simdebug off, ");
221
        if (config.iprompt)
222
                printf("interactive prompt on\n");
223
        else
224
                printf("interactive prompt off\n");
225 7 jrydberg
}

powered by: WebSVN 2.1.0

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