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