-
Notifications
You must be signed in to change notification settings - Fork 43
/
sim-config.h
302 lines (254 loc) · 9.89 KB
/
sim-config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/* sim-config.h -- Simulator configuration header file
Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
Copyright (C) 2008 Embecosm Limited
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
This file is part of OpenRISC 1000 Architectural Simulator.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This program is commented throughout in a fashion suitable for processing
with Doxygen. */
#ifndef SIM_CONFIG_H
#define SIM_CONFIG_H
/* System includes */
#include <stdio.h>
/* Package includes */
#include "arch.h"
/* Simulator configuration macros. Eventually this one will be a lot bigger. */
#define MAX_SBUF_LEN 256 /* Max. length of store buffer */
#define EXE_LOG_HARDWARE 0 /* Print out RTL states */
#define EXE_LOG_SIMPLE 1 /* Executed log prints out dissasembly */
#define EXE_LOG_SOFTWARE 2 /* Simple with some register output */
#define STR_SIZE 256
/* Number of cycles between checks to runtime.sim.iprompt */
#define CHECK_INT_TIME 100000
/* Print to the defined output stream */
#define PRINTF(x...) fprintf (runtime.sim.fout, x)
/* Print only if we are not running silently */
#define PRINTFQ(x...) if (!config.sim.quiet) { fprintf (runtime.sim.fout, x); }
/*! Data structure for configuration data */
struct config
{
struct
{ /* External linkage for SystemC */
void *class_ptr;
int (*read_up) (void *class_ptr,
unsigned long int addr,
unsigned char mask[],
unsigned char rdata[],
int data_len);
int (*write_up) (void *class_ptr,
unsigned long int addr,
unsigned char mask[],
unsigned char wdata[],
int data_len);
} ext;
struct
{
int is_library; /* Library operation */
int debug; /* Simulator debugging */
int verbose; /* Force verbose output */
int profile; /* Is profiler running */
char *prof_fn; /* Profiler filename */
int mprofile; /* Is memory profiler running */
char *mprof_fn; /* Memory profiler filename */
int history; /* instruction stream history analysis */
int exe_log; /* Print out RTL states? */
int exe_log_type; /* Type of log */
long long int exe_log_start; /* First instruction to log */
long long int exe_log_end; /* Last instr to log, -1 if continuous */
int exe_log_marker; /* If nonzero, place markers before */
/* each exe_log_marker instructions */
char *exe_log_fn; /* RTL state comparison filename */
int exe_bin_insn_log; /* Binary dump log of exec. instructions */
char* exe_bin_insn_log_fn; /* Binary dump log of exec. instructions name */
long clkcycle_ps; /* Clock duration in ps */
int strict_npc; /* JPB. NPC flushes pipeline when changed */
int quiet; /* Minimize message output */
int report_mem_errs; /* Report out of memory accesses */
} sim;
struct
{ /* Verification API */
int enabled; /* Whether is VAPI module enabled */
int server_port; /* user specified port for services */
int log_enabled; /* Whether to log the vapi requests */
int hide_device_id; /* Whether to log dev ID each request */
char *vapi_fn; /* vapi log filename */
} vapi;
struct
{
char *timings_fn; /* Filename of the timing table */
int memory_order; /* Memory access stricness */
int calling_convention; /* Do funcs follow std calling conv? */
int enable_bursts; /* Whether burst are enabled */
int no_multicycle; /* Generate no multicycle paths */
} cuc;
struct
{
int superscalar; /* superscalara analysis */
int hazards; /* dependency hazards analysis */
int dependstats; /* dependency statistics */
int sbuf_len; /* length of store buffer, 0=disabled */
int hardfloat; /* whether hardfloat is enabled */
} cpu;
struct
{
int enabled; /* Whether data cache is enabled */
int nways; /* Number of DC ways */
int nsets; /* Number of DC sets */
int blocksize; /* DC entry size */
int ustates; /* number of DC usage states */
int store_missdelay; /* cycles a store miss costs */
int store_hitdelay; /* cycles a store hit costs */
int load_missdelay; /* cycles a load miss costs */
int load_hitdelay; /* cycles a load hit costs */
} dc;
struct pic
{
int enabled; /* Is interrupt controller enabled? */
int edge_trigger; /* Are interrupts edge triggered? */
int use_nmi; /* Do we have non-maskable interrupts? */
} pic;
struct
{
int enabled; /* Is power management operational? */
} pm;
struct
{
int enabled; /* Are performance counters enabled? */
} pcu;
struct
{
int enabled; /* branch prediction buffer analysis */
int sbp_bnf_fwd; /* Static BP for l.bnf uses fwd predn */
int sbp_bf_fwd; /* Static BP for l.bf uses fwd predn */
int btic; /* BP target insn cache analysis */
int missdelay; /* How much cycles does the miss cost */
int hitdelay; /* How much cycles does the hit cost */
} bpb;
struct
{
int enabled; /* Is debug module enabled */
int rsp_enabled; /* Is RSP debugging with GDB possible */
int rsp_port; /* Port for RSP GDB connection */
unsigned long vapi_id; /* "Fake" vapi dev id for JTAG proxy */
long int jtagcycle_ps; /* JTAG clock duration in ps */
} debug;
};
/*! Data structure for run time data */
struct runtime
{
struct
{
FILE *fprof; /* Profiler file */
FILE *fmprof; /* Memory profiler file */
FILE *fexe_log; /* RTL state comparison file */
FILE *fexe_bin_insn_log; /* Binary instruction dump/log file */
FILE *fout; /* file for standard output */
char *filename; /* Original Command Simulator file (CZ) */
int iprompt; /* Interactive prompt */
int iprompt_run; /* Interactive prompt is running */
long long cycles; /* Cycles counts fetch stages */
long long int end_cycles; /* JPB. Cycles to end of quantum */
double time_point; /* JPB. Time point in the simulation */
unsigned long int ext_int_set; /* JPB. External interrupts to set */
unsigned long int ext_int_clr; /* DXL. External interrupts ti clear */
int mem_cycles; /* Each cycle has counter of mem_cycles;
this value is joined with cycles
at the end of the cycle; no sim
originated memory accesses should be
performed inbetween. */
int loadcycles; /* Load and store stalls */
int storecycles;
long long reset_cycles;
int hush; /* Is simulator to do reg dumps */
int trace_phy; /* Show physical instr addr when tracing */
int trace_virt; /* Show virtual instr addr when tracing */
} sim;
struct
{
unsigned int instr; /* Current JTAG instruction */
unsigned long int mod_id; /* Currently selected module */
int write_defined_p; /* WRITE_COMMAND has set details for GO */
unsigned char acc_type; /* Access type for GO */
unsigned long int addr; /* Address to read/write for GO */
unsigned long int size; /* Num bytes to read/write (up to 2^16) */
} debug;
struct
{
long long instructions; /* Instructions executed */
long long reset_instructions;
int stalled;
int halted; /* When library hits exit. */
int hazardwait; /* how many cycles were wasted because of hazards */
int supercycles; /* Superscalar cycles */
} cpu;
struct
{ /* Verification API, part of Adv Core Verif */
int enabled; /* Whether is VAPI module enabled */
FILE *vapi_file; /* vapi file */
int server_port; /* A user specified port number for services */
} vapi;
/* CUC configuration parameters */
struct
{
int mdelay[4]; /* average memory delays in cycles
{read single, read burst, write single, write burst} */
double cycle_duration; /* in ns */
} cuc;
};
/*! Union of all possible paramter values */
union param_val
{
char *str_val;
int int_val;
long long int longlong_val;
oraddr_t addr_val;
};
/*! Enum of all possible paramter types */
enum param_t
{
PARAMT_NONE = 0, /* No parameter */
PARAMT_STR, /* String parm enclosed in double quotes (") */
PARAMT_WORD, /* String parm NOT enclosed in double quotes */
PARAMT_INT, /* Integer parameter */
PARAMT_LONGLONG, /* Long long int parameter */
PARAMT_ADDR /* Address parameter */
};
/* Generic structure for a configuration section */
struct config_section
{
char *name;
void *(*sec_start) (void);
void (*sec_end) (void *);
void *dat;
struct config_param *params;
struct config_section *next;
};
/* Externally visible data structures*/
extern struct config config;
extern struct runtime runtime;
extern struct config_section *cur_section;
extern int do_stats;
/* Prototypes for external use */
extern void set_config_command (int argc, char **argv);
extern void init_defconfig (void);
extern int parse_args (int argc, char *argv[]);
extern void print_config (void);
extern void reg_config_param (struct config_section *sec,
const char *param,
enum param_t type,
void (*param_cb) (union param_val,
void *));
extern struct config_section *reg_config_sec (const char *section,
void *(*sec_start) (void),
void (*sec_end) (void *));
extern void reg_config_secs ();
#endif /* SIM_CONFIG_H */