OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_2_x/] [or1ksim/] [sim-config.h] - Blame information for rev 1486

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
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
    int entrysize;                    /* ITLB entry size */
46
    int ustates;                      /* number of ITLB usage states */
47 541 markom
    int missdelay;                    /* How much cycles does the miss cost */
48
    int hitdelay;                     /* How much cycles does the hit cost */
49 425 markom
  } immu;
50
 
51
  struct {
52
    int enabled;                      /* Whether DMMU is enabled */
53
    int nways;                        /* Number of DTLB ways */
54
    int nsets;                        /* Number of DTLB sets */
55
    int pagesize;                     /* DTLB page size */
56
    int entrysize;                    /* DTLB entry size */
57
    int ustates;                      /* number of DTLB usage states */
58 541 markom
    int missdelay;                    /* How much cycles does the miss cost */
59
    int hitdelay;                     /* How much cycles does the hit cost */
60 425 markom
  } dmmu;
61 428 markom
 
62
  struct {
63
    int enabled;                      /* Whether instruction cache is enabled */
64
    int nways;                        /* Number of IC ways */
65
    int nsets;                        /* Number of IC sets */
66
    int blocksize;                    /* IC entry size */
67
    int ustates;                      /* number of IC usage states */
68 541 markom
    int missdelay;                    /* How much cycles does the miss cost */
69
    int hitdelay;                     /* How much cycles does the hit cost */
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
    unsigned long ver, rev;           /* Version register */
103
    int sr;                           /* Supervision register */
104
    int superscalar;                  /* superscalara analysis */
105
    int hazards;                      /* dependency hazards analysis */
106
    int dependstats;                  /* dependency statistics */
107
    int sbuf_len;                     /* length of store buffer, zero if disabled */
108
  } cpu;
109
 
110
  struct {
111
    int debug;                        /* Simulator debugging */
112
    int verbose;                      /* Force verbose output */
113
 
114
    int profile;                      /* Is profiler running */
115
    char prof_fn[STR_SIZE];           /* Profiler filename */
116
 
117
    int mprofile;                     /* Is memory profiler running */
118
    char mprof_fn[STR_SIZE];          /* Memory profiler filename */
119
 
120
    int history;                      /* instruction stream history analysis */
121
    int exe_log;                      /* Print out RTL states? */
122
    int exe_log_type;                 /* Type of log */
123
    int exe_log_start;                /* First instruction to log */
124
    int exe_log_end;                  /* Last instruction to log, -1 if continuous */
125
    int exe_log_marker;               /* If nonzero, place markers before each exe_log_marker instructions */
126
    char exe_log_fn[STR_SIZE];        /* RTL state comparison filename */
127
    int spr_log;                      /* Print out SPR states */
128
    char spr_log_fn[STR_SIZE];        /* SPR state log filename */
129 823 ivang
    char fstdout[STR_SIZE];           /* stdout filename */
130 672 markom
    long clkcycle_ps;                 /* Clock duration in ps */
131 805 markom
    long system_kfreq;                /* System frequency in kHz*/
132 672 markom
  } sim;
133
 
134
  struct {
135
    int enabled;                      /* Whether is debug module enabled */
136
    int gdb_enabled;                  /* Whether is debugging with gdb possible */
137
    int server_port;                  /* A user specified port number for services */
138
    unsigned long vapi_id;            /* "Fake" vapi device id for JTAG proxy */
139
  } 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
    FILE *fspr_log;                   /* SPR state log file */
168 997 markom
    FILE *fout;                       /* file for standard output */
169 672 markom
    int init;                         /* Whether we are still initilizing sim */
170
    int script_file_specified;        /* Whether script file was already loaded */
171
    char *filename;                   /* Original Command Simulator file (CZ) */
172
    char script_fn[STR_SIZE];         /* Script file read */
173
    int iprompt;                      /* Interactive prompt */
174 1320 phoenix
    long long cycles;                 /* Cycles counts fetch stages */
175 884 markom
 
176
    int mem_cycles;                   /* Each cycle has counter of mem_cycles;
177
                                         this value is joined with cycles
178
                                         at the end of the cycle; no sim
179
                                         originated memory accesses should be
180
                                         performed inbetween. */
181
    int loadcycles;                   /* Load and store stalls */
182
    int storecycles;
183 1320 phoenix
 
184
    long long reset_cycles;
185 1353 nogj
 
186
    int hush;                         /* Is simulator to do reg dumps */
187 264 markom
  } sim;
188 883 markom
 
189
  /* Command line parameters */
190
  struct {
191
    int profile;                      /* Whether profiling was enabled */
192
    int mprofile;                     /* Whether memory profiling was enabled */
193
  } simcmd;
194 557 markom
 
195
  struct {
196 1320 phoenix
    long long instructions;           /* Instructions executed */
197
    long long reset_instructions;
198
 
199 884 markom
    int stalled;
200
    int hazardwait;                   /* how many cycles were wasted because of hazards */
201
    int supercycles;                  /* Superscalar cycles */
202 672 markom
  } cpu;
203
 
204
  struct {                            /* Verification API, part of Advanced Core Verification */
205
    int enabled;                      /* Whether is VAPI module enabled */
206
    FILE *vapi_file;                  /* vapi file */
207
    int server_port;                  /* A user specified port number for services */
208 293 markom
  } vapi;
209 897 markom
 
210
/* CUC configuration parameters */
211
  struct {
212
    int mdelay[4];                  /* average memory delays in cycles
213
                                     {read single, read burst, write single, write burst} */
214
    double cycle_duration;          /* in ns */
215
  } cuc;
216 7 jrydberg
};
217 239 markom
 
218 7 jrydberg
extern struct config config;
219 551 markom
 
220 997 markom
#define PRINTF(x...) fprintf (runtime.sim.fout, x)
221
 
222 361 markom
extern struct runtime runtime;
223 239 markom
 
224
/* Read environment from a script file. Does not fail - assumes defaukt configuration instead. */
225
void read_script_file (char *filename);
226 361 markom
 
227
/* Executes set sim command.  Returns nonzero if error.  */
228 1353 nogj
void set_config_command (int argc, char **argv);
229 428 markom
 
230 549 markom
/* Outputs C structure of current config to file */
231
void output_cfg (FILE *f);
232
 
233 1308 phoenix
void init_defconfig();
234
 
235
int parse_args(int argc, char *argv[]);
236
 
237
void print_config();
238
 
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
  oraddr_t addr_val;
263
};
264
 
265
enum param_t {
266
  paramt_none = 0, /* No parameter */
267
  paramt_str, /* String parameter enclosed in double quotes (") */
268
  paramt_word, /* String parameter NOT enclosed in double quotes */
269
  paramt_int, /* Integer parameter */
270
  paramt_addr /* Address parameter */
271
};
272
 
273
struct config_section {
274
  char *name;
275
  void *(*sec_start)(void);
276
  void (*sec_end)(void *);
277
  void *dat;
278
  struct config_param *params;
279
  struct config_section *next;
280
};
281
 
282
/* Register a parameter in a section of the config file */
283
void reg_config_param(struct config_section *sec, const char *param,
284
                      enum param_t type,
285
                      void (*param_cb)(union param_val, void*));
286
 
287
/* Register a section in the config file */
288
struct config_section *reg_config_sec(const char *section,
289
                                      void *(*sec_start)(void),
290
                                      void (*sec_end)(void *));
291
 
292
extern struct config_section *cur_section;
293
#define CONFIG_ERROR(s) {fprintf (stderr, "ERROR: config.%s:%s\n", cur_section->name, s); if (runtime.sim.init) exit (1);}
294
 
295 1446 nogj
/* FIXME: These will disapeer one day... */
296 1358 nogj
void reg_mc_sec(void);
297
void reg_uart_sec(void);
298
void reg_dma_sec(void);
299
void reg_memory_sec(void);
300
void reg_debug_sec(void);
301
void reg_vapi_sec(void);
302
void reg_ethernet_sec(void);
303
void reg_immu_sec(void);
304
void reg_dmmu_sec(void);
305
void reg_ic_sec(void);
306
void reg_dc_sec(void);
307
void reg_gpio_sec(void);
308
void reg_bpb_sec(void);
309
void reg_pm_sec(void);
310
void reg_vga_sec(void);
311
void reg_fb_sec(void);
312
void reg_kbd_sec(void);
313
void reg_ata_sec(void);
314
void reg_cuc_sec(void);
315 428 markom
#endif

powered by: WebSVN 2.1.0

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