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 230

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 230 erez
#include "pic.h"
27 7 jrydberg
 
28
struct config config;
29
 
30
void init_defconfig()
31
{
32 103 lampret
        unsigned long val;
33
 
34 30 lampret
        memset(&config, 0, sizeof(config));
35 123 markom
        config.dc.tagtype = NONE/*VIRTUAL*/;
36
        config.ic.tagtype = NONE/*VIRTUAL*/;
37 103 lampret
        config.bp.bpb_sim = 1;
38
        config.bp.btic_sim = 1;
39 30 lampret
        config.clkcycle_ns = 4; /* 4 for 4ns (250MHz) */
40
        config.uarts[0].rxfile = "/tmp/uart0.rx";
41
        config.uarts[0].txfile = "/tmp/uart0.tx";
42
        config.uarts[0].baseaddr = 0x80000000;
43 190 chris
        config.uarts[0].jitter = -1; /* Async behavior */
44 230 erez
        config.dmas[0].baseaddr = 0x90000000;
45
        config.dmas[0].irq = INT_DMA;
46 103 lampret
        config.simdebug = 0;
47 173 markom
        config.profile = 0;
48 103 lampret
        config.iprompt = 0;
49
        config.dependstats = 1;
50
        config.dependency = 1;
51
        config.history = 1;
52
        config.superscalar = 1;
53
        config.slp = 1;
54 190 chris
        config.profile = 0;
55 103 lampret
 
56
        mtspr(SPR_VR, SPR_VR_VER & 0x1200);
57
 
58
        val = SPR_UPR_UP | SPR_UPR_DCP | SPR_UPR_ICP | SPR_UPR_DMP |
59
        SPR_UPR_IMP | SPR_UPR_OB32P | SPR_UPR_DUP | SPR_UPR_PICP |
60
        SPR_UPR_PMP | SPR_UPR_TTP;
61
 
62
        mtspr(SPR_UPR, val);
63
}
64
 
65
int parse_args(int argc, char *argv[])
66
{
67
        unsigned long val;
68
 
69
        argv++; argc--;
70
        while (argc) {
71 123 markom
          if (argc && (*argv[0] != '-')) {
72
                    config.filename = argv[0];
73
                    argc--;
74
                    argv++;
75
                 } else
76
                 if (strncmp(*argv, "-loadmem",8) == 0) {  /* (CZ) */
77
                        MemoryBlock** block = &config.memory;
78
                        int address = 0;
79
 
80
                        if(!--argc)
81
                          return 1;
82
 
83
                        if(argv[0][8] == '@')
84
                          {
85
                            char *s;
86
 
87
                            address = strtol(address,&s,0);
88
                            if(*s)
89
                              return 1;
90
                          }
91
                        else if(argv[0][8])
92
                          return 1;
93
 
94
                        while(*block)
95
                          block = &(*block)->next;
96
                        *block = (MemoryBlock*)malloc(sizeof(MemoryBlock));
97
                        memset(*block,0,sizeof(MemoryBlock));
98
                        (*block)->address = address;
99
                        (*block)->file = *(++argv);
100
                        argv++; argc--;
101
                } else
102
                if (strcmp(*argv, "-initmem") == 0) {  /* (CZ) */
103
                        char *pattern,*s;
104
                        if(!--argc)
105
                          return 1;
106
                        pattern = *(++argv);
107
                        if(!strcmp(pattern,"random"))
108
                          config.random_mem = 1;
109
                        else
110
                          {
111
                            val = strtol(pattern,&s,0);
112
                            if(*s)
113
                              return 1;
114
                            config.pattern_mem = val;
115
                          }
116
                } else
117
                if (strcmp(*argv, "-nosrv") == 0) {  /* (CZ) */
118
                        config.inhibit_server = 1;
119
                        argv++; argc--;
120
                } else
121
                if (strcmp(*argv, "-srv") == 0) {  /* (CZ) */
122
                        char *s;
123
                        if(!--argc)
124
                          return 1;
125
                        config.server_port = strtol(*(++argv),&s,10);
126
                        if(*s)
127
                          return 1;
128
                        argv++; argc--;
129
                } else
130 103 lampret
                if (strcmp(*argv, "-i") == 0) {
131
                        config.iprompt = 1;
132
                        argv++; argc--;
133
                } else
134
                if (strcmp(*argv, "-v") == 0) {
135
                        version();
136
                        exit(0);
137
                } else
138
                if (strcmp(*argv, "-bpb") == 0) {
139
                        config.bp.bpb_sim = 0;
140
                        argv++; argc--;
141
                } else
142
                if (strcmp(*argv, "-hazards") == 0) {
143
                        config.dependstats = 0;
144
                        config.dependency = 0;
145
                        argv++; argc--;
146
                } else
147
                if (strcmp(*argv, "-history") == 0) {
148
                        config.history = 0;
149
                        argv++; argc--;
150
                } else
151
                if (strcmp(*argv, "-superscalar") == 0) {
152
                        config.superscalar = 0;
153
                        argv++; argc--;
154
                } else
155
                if (strcmp(*argv, "-fast") == 0) {
156
                        config.superscalar = 0;
157
                        config.history = 0;
158
                        config.dependstats = 0;
159
                        config.dependency = 0;
160
                        config.bp.bpb_sim = 0;
161
                        config.bp.btic_sim = 0;
162
                        config.slp = 0;
163
                        argv++; argc--;
164
                } else
165
                if (strcmp(*argv, "-btic") == 0) {
166
                        config.bp.btic_sim = 0;
167
                        argv++; argc--;
168
                } else
169
                if (strcmp(*argv, "-upr") == 0) {
170
                        argv++; argc--;
171
                        val = strtoul(*argv, NULL, 0);
172
                        mtspr(SPR_UPR, val);
173
                        argv++; argc--;
174
                } else
175
                if (strcmp(*argv, "-ver") == 0) {
176
                        argv++; argc--;
177
                        val = strtoul(*argv, NULL, 0);
178
                        setsprbits(SPR_VR, SPR_VR_VER, val);
179
                        argv++; argc--;
180
                } else
181
                if (strcmp(*argv, "-rev") == 0) {
182
                        argv++; argc--;
183
                        val = strtoul(*argv, NULL, 0);
184
                        setsprbits(SPR_VR, SPR_VR_REV, val);
185
                        argv++; argc--;
186 173 markom
                } else
187
                if (strcmp(*argv, "-profile") == 0) {
188
                  config.profile = 1;
189
                  argv++; argc--;
190 103 lampret
                } else {
191
                        printf("Unknown option: %s\n", *argv);
192
                        return 1;
193
                }
194
        }
195
 
196
        if (!argc)
197
                return 0;
198
 
199
        return 0;
200
}
201
 
202
void print_config()
203
{
204
        printf("Machine initialization...\n");
205 167 markom
        if (testsprbits(SPR_UPR, SPR_UPR_DCP))
206 103 lampret
                printf("Data cache tag: %s\n", config.dc.tagtype == VIRTUAL ? "virtual" : "physical");
207
        else
208
                printf("No data cache.\n");
209 167 markom
        if (testsprbits(SPR_UPR, SPR_UPR_ICP))
210 103 lampret
                printf("Insn cache tag: %s\n", config.ic.tagtype == VIRTUAL ? "virtual" : "physical");
211
        else
212
                printf("No instruction cache.\n");
213
        if (config.bp.bpb_sim)
214
                printf("BPB simulation on.\n");
215
        else
216
                printf("BPB simulation off.\n");
217
        if (config.bp.btic_sim)
218
                printf("BTIC simulation on.\n");
219
        else
220
                printf("BTIC simulation off.\n");
221
        printf("Clock cycle: %d ns\n", config.clkcycle_ns);
222 221 markom
        /*printf("RAM: 0x%x to 0x%x (%d KB)\n\n", config.ram.startaddr, config.ram.endaddr);
223
          (config.ram.endaddr - config.ram.startaddr) / 1024); MM170901 different memory scheme.  */
224
 
225 103 lampret
        if (config.simdebug)
226
                printf("simdebug on, ");
227
        else
228
                printf("simdebug off, ");
229
        if (config.iprompt)
230
                printf("interactive prompt on\n");
231
        else
232
                printf("interactive prompt off\n");
233 7 jrydberg
}

powered by: WebSVN 2.1.0

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