1 |
1446 |
nogj |
/* sim-config.h -- Simulator configuration header file
|
2 |
7 |
jrydberg |
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 |
428 |
markom |
|
20 |
|
|
#ifndef _CONFIG_H_
|
21 |
|
|
#define _CONFIG_H_
|
22 |
|
|
|
23 |
173 |
markom |
#include <stdio.h>
|
24 |
|
|
|
25 |
7 |
jrydberg |
/* Simulator configuration macros. Eventually this one will be a lot bigger. */
|
26 |
30 |
lampret |
|
27 |
672 |
markom |
#define MAX_SBUF_LEN 256 /* Max. length of store buffer */
|
28 |
424 |
markom |
|
29 |
672 |
markom |
#define EXE_LOG_HARDWARE 0 /* Print out RTL states */
|
30 |
675 |
markom |
#define EXE_LOG_SIMPLE 1 /* Executed log prints out dissasembly */
|
31 |
|
|
#define EXE_LOG_SOFTWARE 2 /* Simple with some register output*/
|
32 |
672 |
markom |
|
33 |
239 |
markom |
#define STR_SIZE (256)
|
34 |
|
|
|
35 |
7 |
jrydberg |
struct config {
|
36 |
239 |
markom |
struct {
|
37 |
332 |
markom |
int enabled; /* Is tick timer enabled? */
|
38 |
|
|
} tick;
|
39 |
|
|
|
40 |
261 |
markom |
struct {
|
41 |
425 |
markom |
int enabled; /* Whether IMMU is enabled */
|
42 |
|
|
int nways; /* Number of ITLB ways */
|
43 |
|
|
int nsets; /* Number of ITLB sets */
|
44 |
|
|
int pagesize; /* ITLB page size */
|
45 |
1538 |
nogj |
int pagesize_log2; /* ITLB page size (log2(pagesize)) */
|
46 |
|
|
oraddr_t page_offset_mask; /* Address mask to get page offset */
|
47 |
|
|
oraddr_t page_mask; /* Page number mask (diff. from vpn) */
|
48 |
|
|
oraddr_t vpn_mask; /* Address mask to get vpn */
|
49 |
|
|
int lru_reload; /* What to reload the lru value to */
|
50 |
|
|
oraddr_t set_mask; /* Mask to get set of an address */
|
51 |
425 |
markom |
int entrysize; /* ITLB entry size */
|
52 |
|
|
int ustates; /* number of ITLB usage states */
|
53 |
541 |
markom |
int missdelay; /* How much cycles does the miss cost */
|
54 |
|
|
int hitdelay; /* How much cycles does the hit cost */
|
55 |
425 |
markom |
} immu;
|
56 |
|
|
|
57 |
|
|
struct {
|
58 |
|
|
int enabled; /* Whether DMMU is enabled */
|
59 |
|
|
int nways; /* Number of DTLB ways */
|
60 |
|
|
int nsets; /* Number of DTLB sets */
|
61 |
|
|
int pagesize; /* DTLB page size */
|
62 |
1539 |
nogj |
int pagesize_log2; /* DTLB page size (log2(pagesize)) */
|
63 |
|
|
oraddr_t page_offset_mask; /* Address mask to get page offset */
|
64 |
|
|
oraddr_t page_mask; /* Page number mask (diff. from vpn) */
|
65 |
|
|
oraddr_t vpn_mask; /* Address mask to get vpn */
|
66 |
|
|
int lru_reload; /* What to reload the lru value to */
|
67 |
|
|
oraddr_t set_mask; /* Mask to get set of an address */
|
68 |
425 |
markom |
int entrysize; /* DTLB entry size */
|
69 |
|
|
int ustates; /* number of DTLB usage states */
|
70 |
541 |
markom |
int missdelay; /* How much cycles does the miss cost */
|
71 |
|
|
int hitdelay; /* How much cycles does the hit cost */
|
72 |
425 |
markom |
} dmmu;
|
73 |
428 |
markom |
|
74 |
|
|
struct {
|
75 |
|
|
int enabled; /* Whether instruction cache is enabled */
|
76 |
|
|
int nways; /* Number of IC ways */
|
77 |
|
|
int nsets; /* Number of IC sets */
|
78 |
|
|
int blocksize; /* IC entry size */
|
79 |
|
|
int ustates; /* number of IC usage states */
|
80 |
541 |
markom |
int missdelay; /* How much cycles does the miss cost */
|
81 |
|
|
int hitdelay; /* How much cycles does the hit cost */
|
82 |
428 |
markom |
} ic;
|
83 |
424 |
markom |
|
84 |
263 |
markom |
struct {
|
85 |
541 |
markom |
int enabled; /* Whether data cache is enabled */
|
86 |
428 |
markom |
int nways; /* Number of DC ways */
|
87 |
|
|
int nsets; /* Number of DC sets */
|
88 |
|
|
int blocksize; /* DC entry size */
|
89 |
|
|
int ustates; /* number of DC usage states */
|
90 |
541 |
markom |
int store_missdelay; /* How much cycles does the store miss cost */
|
91 |
|
|
int store_hitdelay; /* How much cycles does the store hit cost */
|
92 |
|
|
int load_missdelay; /* How much cycles does the load miss cost */
|
93 |
|
|
int load_hitdelay; /* How much cycles does the load hit cost */
|
94 |
428 |
markom |
} dc;
|
95 |
|
|
|
96 |
|
|
struct {
|
97 |
672 |
markom |
int enabled; /* branch prediction buffer analysis */
|
98 |
|
|
int sbp_bnf_fwd; /* Static branch prediction for l.bnf uses forward prediction */
|
99 |
|
|
int sbp_bf_fwd; /* Static branch prediction for l.bf uses forward prediction */
|
100 |
|
|
int btic; /* branch prediction target insn cache analysis */
|
101 |
|
|
int missdelay; /* How much cycles does the miss cost */
|
102 |
|
|
int hitdelay; /* How much cycles does the hit cost */
|
103 |
|
|
#if 0
|
104 |
|
|
int nways; /* Number of BP ways */
|
105 |
|
|
int nsets; /* Number of BP sets */
|
106 |
|
|
int blocksize; /* BP entry size */
|
107 |
|
|
int ustates; /* number of BP usage states */
|
108 |
|
|
int pstates; /* number of BP predict states */
|
109 |
|
|
#endif
|
110 |
|
|
} bpb;
|
111 |
|
|
|
112 |
|
|
struct {
|
113 |
|
|
unsigned long upr; /* Unit present register */
|
114 |
|
|
unsigned long ver, rev; /* Version register */
|
115 |
|
|
int sr; /* Supervision register */
|
116 |
|
|
int superscalar; /* superscalara analysis */
|
117 |
|
|
int hazards; /* dependency hazards analysis */
|
118 |
|
|
int dependstats; /* dependency statistics */
|
119 |
|
|
int sbuf_len; /* length of store buffer, zero if disabled */
|
120 |
|
|
} cpu;
|
121 |
|
|
|
122 |
|
|
struct {
|
123 |
|
|
int debug; /* Simulator debugging */
|
124 |
|
|
int verbose; /* Force verbose output */
|
125 |
|
|
|
126 |
|
|
int profile; /* Is profiler running */
|
127 |
|
|
char prof_fn[STR_SIZE]; /* Profiler filename */
|
128 |
|
|
|
129 |
|
|
int mprofile; /* Is memory profiler running */
|
130 |
|
|
char mprof_fn[STR_SIZE]; /* Memory profiler filename */
|
131 |
|
|
|
132 |
|
|
int history; /* instruction stream history analysis */
|
133 |
|
|
int exe_log; /* Print out RTL states? */
|
134 |
|
|
int exe_log_type; /* Type of log */
|
135 |
1580 |
nogj |
long long int exe_log_start; /* First instruction to log */
|
136 |
|
|
long long int exe_log_end; /* Last instruction to log, -1 if continuous */
|
137 |
672 |
markom |
int exe_log_marker; /* If nonzero, place markers before each exe_log_marker instructions */
|
138 |
|
|
char exe_log_fn[STR_SIZE]; /* RTL state comparison filename */
|
139 |
823 |
ivang |
char fstdout[STR_SIZE]; /* stdout filename */
|
140 |
672 |
markom |
long clkcycle_ps; /* Clock duration in ps */
|
141 |
805 |
markom |
long system_kfreq; /* System frequency in kHz*/
|
142 |
672 |
markom |
} sim;
|
143 |
|
|
|
144 |
|
|
struct {
|
145 |
|
|
int enabled; /* Whether is debug module enabled */
|
146 |
|
|
int gdb_enabled; /* Whether is debugging with gdb possible */
|
147 |
|
|
int server_port; /* A user specified port number for services */
|
148 |
|
|
unsigned long vapi_id; /* "Fake" vapi device id for JTAG proxy */
|
149 |
|
|
} debug;
|
150 |
|
|
|
151 |
|
|
struct { /* Verification API, part of Advanced Core Verification */
|
152 |
|
|
int enabled; /* Whether is VAPI module enabled */
|
153 |
|
|
int server_port; /* A user specified port number for services */
|
154 |
|
|
int log_enabled; /* Whether to log the vapi requests */
|
155 |
|
|
int hide_device_id; /* Whether to log device ID for each request */
|
156 |
|
|
char vapi_fn[STR_SIZE]; /* vapi log filename */
|
157 |
|
|
} vapi;
|
158 |
|
|
|
159 |
|
|
struct {
|
160 |
|
|
int enabled; /* Whether power menagement is operational */
|
161 |
|
|
} pm;
|
162 |
897 |
markom |
|
163 |
|
|
struct {
|
164 |
|
|
char timings_fn[STR_SIZE]; /* Filename of the timing table */
|
165 |
|
|
int memory_order; /* Memory access stricness */
|
166 |
|
|
int calling_convention; /* Whether functions follow standard calling convention */
|
167 |
|
|
int enable_bursts; /* Whether burst are enabled */
|
168 |
|
|
int no_multicycle; /* When enabled no multicycle paths are generated */
|
169 |
|
|
} cuc;
|
170 |
672 |
markom |
};
|
171 |
|
|
|
172 |
|
|
struct runtime {
|
173 |
|
|
struct {
|
174 |
|
|
FILE *fprof; /* Profiler file */
|
175 |
|
|
FILE *fmprof; /* Memory profiler file */
|
176 |
|
|
FILE *fexe_log; /* RTL state comparison file */
|
177 |
997 |
markom |
FILE *fout; /* file for standard output */
|
178 |
672 |
markom |
int init; /* Whether we are still initilizing sim */
|
179 |
|
|
int script_file_specified; /* Whether script file was already loaded */
|
180 |
|
|
char *filename; /* Original Command Simulator file (CZ) */
|
181 |
|
|
char script_fn[STR_SIZE]; /* Script file read */
|
182 |
|
|
int iprompt; /* Interactive prompt */
|
183 |
1593 |
nogj |
int iprompt_run; /* Interactive prompt is running */
|
184 |
1320 |
phoenix |
long long cycles; /* Cycles counts fetch stages */
|
185 |
884 |
markom |
|
186 |
|
|
int mem_cycles; /* Each cycle has counter of mem_cycles;
|
187 |
|
|
this value is joined with cycles
|
188 |
|
|
at the end of the cycle; no sim
|
189 |
|
|
originated memory accesses should be
|
190 |
|
|
performed inbetween. */
|
191 |
|
|
int loadcycles; /* Load and store stalls */
|
192 |
|
|
int storecycles;
|
193 |
1320 |
phoenix |
|
194 |
|
|
long long reset_cycles;
|
195 |
1353 |
nogj |
|
196 |
|
|
int hush; /* Is simulator to do reg dumps */
|
197 |
264 |
markom |
} sim;
|
198 |
883 |
markom |
|
199 |
|
|
/* Command line parameters */
|
200 |
|
|
struct {
|
201 |
|
|
int profile; /* Whether profiling was enabled */
|
202 |
|
|
int mprofile; /* Whether memory profiling was enabled */
|
203 |
|
|
} simcmd;
|
204 |
557 |
markom |
|
205 |
|
|
struct {
|
206 |
1320 |
phoenix |
long long instructions; /* Instructions executed */
|
207 |
|
|
long long reset_instructions;
|
208 |
|
|
|
209 |
884 |
markom |
int stalled;
|
210 |
|
|
int hazardwait; /* how many cycles were wasted because of hazards */
|
211 |
|
|
int supercycles; /* Superscalar cycles */
|
212 |
672 |
markom |
} cpu;
|
213 |
|
|
|
214 |
|
|
struct { /* Verification API, part of Advanced Core Verification */
|
215 |
|
|
int enabled; /* Whether is VAPI module enabled */
|
216 |
|
|
FILE *vapi_file; /* vapi file */
|
217 |
|
|
int server_port; /* A user specified port number for services */
|
218 |
293 |
markom |
} vapi;
|
219 |
897 |
markom |
|
220 |
|
|
/* CUC configuration parameters */
|
221 |
|
|
struct {
|
222 |
|
|
int mdelay[4]; /* average memory delays in cycles
|
223 |
|
|
{read single, read burst, write single, write burst} */
|
224 |
|
|
double cycle_duration; /* in ns */
|
225 |
|
|
} cuc;
|
226 |
7 |
jrydberg |
};
|
227 |
239 |
markom |
|
228 |
7 |
jrydberg |
extern struct config config;
|
229 |
551 |
markom |
|
230 |
997 |
markom |
#define PRINTF(x...) fprintf (runtime.sim.fout, x)
|
231 |
|
|
|
232 |
361 |
markom |
extern struct runtime runtime;
|
233 |
239 |
markom |
|
234 |
|
|
/* Read environment from a script file. Does not fail - assumes defaukt configuration instead. */
|
235 |
|
|
void read_script_file (char *filename);
|
236 |
361 |
markom |
|
237 |
|
|
/* Executes set sim command. Returns nonzero if error. */
|
238 |
1353 |
nogj |
void set_config_command (int argc, char **argv);
|
239 |
428 |
markom |
|
240 |
1550 |
nogj |
void init_defconfig(void);
|
241 |
549 |
markom |
|
242 |
1308 |
phoenix |
int parse_args(int argc, char *argv[]);
|
243 |
|
|
|
244 |
1550 |
nogj |
void print_config(void);
|
245 |
1308 |
phoenix |
|
246 |
1353 |
nogj |
void sim_done(void);
|
247 |
|
|
|
248 |
1471 |
nogj |
/* Periodically checks runtime.sim.iprompt to see if ctrl_c has been pressed */
|
249 |
|
|
void check_int(void *dat);
|
250 |
|
|
|
251 |
|
|
/* Number of cycles between checks to runtime.sim.iprompt */
|
252 |
|
|
#define CHECK_INT_TIME 100000
|
253 |
|
|
|
254 |
1353 |
nogj |
/* Resets all subunits */
|
255 |
|
|
void sim_reset(void);
|
256 |
|
|
|
257 |
|
|
/* Handle the sim commandline */
|
258 |
|
|
void handle_sim_command(void);
|
259 |
1358 |
nogj |
|
260 |
1360 |
nogj |
/* Registers a new reset hook, called when sim_reset below is called */
|
261 |
|
|
void reg_sim_reset(void (*reset_hook)(void *), void *dat);
|
262 |
|
|
|
263 |
1363 |
nogj |
/* Registers a status printing callback */
|
264 |
|
|
void reg_sim_stat(void (*stat_func)(void *dat), void *dat);
|
265 |
|
|
|
266 |
1358 |
nogj |
union param_val {
|
267 |
|
|
char *str_val;
|
268 |
|
|
int int_val;
|
269 |
1580 |
nogj |
long long int longlong_val;
|
270 |
1358 |
nogj |
oraddr_t addr_val;
|
271 |
|
|
};
|
272 |
|
|
|
273 |
|
|
enum param_t {
|
274 |
|
|
paramt_none = 0, /* No parameter */
|
275 |
|
|
paramt_str, /* String parameter enclosed in double quotes (") */
|
276 |
|
|
paramt_word, /* String parameter NOT enclosed in double quotes */
|
277 |
|
|
paramt_int, /* Integer parameter */
|
278 |
1580 |
nogj |
paramt_longlong, /* Long long int parameter */
|
279 |
1358 |
nogj |
paramt_addr /* Address parameter */
|
280 |
|
|
};
|
281 |
|
|
|
282 |
|
|
struct config_section {
|
283 |
|
|
char *name;
|
284 |
|
|
void *(*sec_start)(void);
|
285 |
|
|
void (*sec_end)(void *);
|
286 |
|
|
void *dat;
|
287 |
|
|
struct config_param *params;
|
288 |
|
|
struct config_section *next;
|
289 |
|
|
};
|
290 |
|
|
|
291 |
|
|
/* Register a parameter in a section of the config file */
|
292 |
|
|
void reg_config_param(struct config_section *sec, const char *param,
|
293 |
|
|
enum param_t type,
|
294 |
|
|
void (*param_cb)(union param_val, void*));
|
295 |
|
|
|
296 |
|
|
/* Register a section in the config file */
|
297 |
|
|
struct config_section *reg_config_sec(const char *section,
|
298 |
|
|
void *(*sec_start)(void),
|
299 |
|
|
void (*sec_end)(void *));
|
300 |
|
|
|
301 |
|
|
extern struct config_section *cur_section;
|
302 |
|
|
#define CONFIG_ERROR(s) {fprintf (stderr, "ERROR: config.%s:%s\n", cur_section->name, s); if (runtime.sim.init) exit (1);}
|
303 |
|
|
|
304 |
1446 |
nogj |
/* FIXME: These will disapeer one day... */
|
305 |
1358 |
nogj |
void reg_mc_sec(void);
|
306 |
|
|
void reg_uart_sec(void);
|
307 |
|
|
void reg_dma_sec(void);
|
308 |
|
|
void reg_memory_sec(void);
|
309 |
|
|
void reg_debug_sec(void);
|
310 |
|
|
void reg_vapi_sec(void);
|
311 |
|
|
void reg_ethernet_sec(void);
|
312 |
|
|
void reg_immu_sec(void);
|
313 |
|
|
void reg_dmmu_sec(void);
|
314 |
|
|
void reg_ic_sec(void);
|
315 |
|
|
void reg_dc_sec(void);
|
316 |
|
|
void reg_gpio_sec(void);
|
317 |
|
|
void reg_bpb_sec(void);
|
318 |
|
|
void reg_pm_sec(void);
|
319 |
|
|
void reg_vga_sec(void);
|
320 |
|
|
void reg_fb_sec(void);
|
321 |
|
|
void reg_kbd_sec(void);
|
322 |
|
|
void reg_ata_sec(void);
|
323 |
|
|
void reg_cuc_sec(void);
|
324 |
1557 |
nogj |
void reg_config_secs(void);
|
325 |
428 |
markom |
#endif
|