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

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0/] [or1ksim/] [sim-config.h] - Blame information for rev 1538

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 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
    int entrysize;                    /* DTLB entry size */
63
    int ustates;                      /* number of DTLB usage states */
64 541 markom
    int missdelay;                    /* How much cycles does the miss cost */
65
    int hitdelay;                     /* How much cycles does the hit cost */
66 425 markom
  } dmmu;
67 428 markom
 
68
  struct {
69
    int enabled;                      /* Whether instruction cache is enabled */
70
    int nways;                        /* Number of IC ways */
71
    int nsets;                        /* Number of IC sets */
72
    int blocksize;                    /* IC entry size */
73
    int ustates;                      /* number of IC usage states */
74 541 markom
    int missdelay;                    /* How much cycles does the miss cost */
75
    int hitdelay;                     /* How much cycles does the hit cost */
76 428 markom
  } ic;
77 424 markom
 
78 263 markom
  struct {
79 541 markom
    int enabled;                      /* Whether data cache is enabled */
80 428 markom
    int nways;                        /* Number of DC ways */
81
    int nsets;                        /* Number of DC sets */
82
    int blocksize;                    /* DC entry size */
83
    int ustates;                      /* number of DC usage states */
84 541 markom
    int store_missdelay;              /* How much cycles does the store miss cost */
85
    int store_hitdelay;               /* How much cycles does the store hit cost */
86
    int load_missdelay;               /* How much cycles does the load miss cost */
87
    int load_hitdelay;                /* How much cycles does the load hit cost */
88 428 markom
  } dc;
89
 
90
  struct {
91 672 markom
    int enabled;                      /* branch prediction buffer analysis */
92
    int sbp_bnf_fwd;                  /* Static branch prediction for l.bnf uses forward prediction */
93
    int sbp_bf_fwd;                   /* Static branch prediction for l.bf uses forward prediction */
94
    int btic;                         /* branch prediction target insn cache analysis */
95
    int missdelay;                    /* How much cycles does the miss cost */
96
    int hitdelay;                     /* How much cycles does the hit cost */
97
#if 0                                 
98
    int nways;                        /* Number of BP ways */
99
    int nsets;                        /* Number of BP sets */
100
    int blocksize;                    /* BP entry size */
101
    int ustates;                      /* number of BP usage states */
102
    int pstates;                      /* number of BP predict states */
103
#endif                                
104
  } bpb;
105
 
106
  struct {
107
    unsigned long upr;                /* Unit present register */
108
    unsigned long ver, rev;           /* Version register */
109
    int sr;                           /* Supervision register */
110
    int superscalar;                  /* superscalara analysis */
111
    int hazards;                      /* dependency hazards analysis */
112
    int dependstats;                  /* dependency statistics */
113
    int sbuf_len;                     /* length of store buffer, zero if disabled */
114
  } cpu;
115
 
116
  struct {
117
    int debug;                        /* Simulator debugging */
118
    int verbose;                      /* Force verbose output */
119
 
120
    int profile;                      /* Is profiler running */
121
    char prof_fn[STR_SIZE];           /* Profiler filename */
122
 
123
    int mprofile;                     /* Is memory profiler running */
124
    char mprof_fn[STR_SIZE];          /* Memory profiler filename */
125
 
126
    int history;                      /* instruction stream history analysis */
127
    int exe_log;                      /* Print out RTL states? */
128
    int exe_log_type;                 /* Type of log */
129
    int exe_log_start;                /* First instruction to log */
130
    int exe_log_end;                  /* Last instruction to log, -1 if continuous */
131
    int exe_log_marker;               /* If nonzero, place markers before each exe_log_marker instructions */
132
    char exe_log_fn[STR_SIZE];        /* RTL state comparison filename */
133 823 ivang
    char fstdout[STR_SIZE];           /* stdout filename */
134 672 markom
    long clkcycle_ps;                 /* Clock duration in ps */
135 805 markom
    long system_kfreq;                /* System frequency in kHz*/
136 672 markom
  } sim;
137
 
138
  struct {
139
    int enabled;                      /* Whether is debug module enabled */
140
    int gdb_enabled;                  /* Whether is debugging with gdb possible */
141
    int server_port;                  /* A user specified port number for services */
142
    unsigned long vapi_id;            /* "Fake" vapi device id for JTAG proxy */
143
  } debug;
144
 
145
  struct {                            /* Verification API, part of Advanced Core Verification */
146
    int enabled;                      /* Whether is VAPI module enabled */
147
    int server_port;                  /* A user specified port number for services */
148
    int log_enabled;                  /* Whether to log the vapi requests */
149
    int hide_device_id;               /* Whether to log device ID for each request */
150
    char vapi_fn[STR_SIZE];           /* vapi log filename */
151
  } vapi;
152
 
153
  struct {
154
    int enabled;                      /* Whether power menagement is operational */
155
  } pm;
156 897 markom
 
157
  struct {
158
    char timings_fn[STR_SIZE];        /* Filename of the timing table */
159
    int memory_order;                 /* Memory access stricness */
160
    int calling_convention;           /* Whether functions follow standard calling convention */
161
    int enable_bursts;                /* Whether burst are enabled */
162
    int no_multicycle;                /* When enabled no multicycle paths are generated */
163
  } cuc;
164 672 markom
};
165
 
166
struct runtime {
167
  struct {
168
    FILE *fprof;                      /* Profiler file */
169
    FILE *fmprof;                     /* Memory profiler file */
170
    FILE *fexe_log;                   /* RTL state comparison file */
171 997 markom
    FILE *fout;                       /* file for standard output */
172 672 markom
    int init;                         /* Whether we are still initilizing sim */
173
    int script_file_specified;        /* Whether script file was already loaded */
174
    char *filename;                   /* Original Command Simulator file (CZ) */
175
    char script_fn[STR_SIZE];         /* Script file read */
176
    int iprompt;                      /* Interactive prompt */
177 1320 phoenix
    long long cycles;                 /* Cycles counts fetch stages */
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 549 markom
/* Outputs C structure of current config to file */
234
void output_cfg (FILE *f);
235
 
236 1308 phoenix
void init_defconfig();
237
 
238
int parse_args(int argc, char *argv[]);
239
 
240
void print_config();
241
 
242 1353 nogj
void sim_done(void);
243
 
244 1471 nogj
/* Periodically checks runtime.sim.iprompt to see if ctrl_c has been pressed */
245
void check_int(void *dat);
246
 
247
/* Number of cycles between checks to runtime.sim.iprompt */
248
#define CHECK_INT_TIME 100000
249
 
250 1353 nogj
/* Resets all subunits */
251
void sim_reset(void);
252
 
253
/* Handle the sim commandline */
254
void handle_sim_command(void);
255 1358 nogj
 
256 1360 nogj
/* Registers a new reset hook, called when sim_reset below is called */
257
void reg_sim_reset(void (*reset_hook)(void *), void *dat);
258
 
259 1363 nogj
/* Registers a status printing callback */
260
void reg_sim_stat(void (*stat_func)(void *dat), void *dat);
261
 
262 1358 nogj
union param_val {
263
  char *str_val;
264
  int int_val;
265
  oraddr_t addr_val;
266
};
267
 
268
enum param_t {
269
  paramt_none = 0, /* No parameter */
270
  paramt_str, /* String parameter enclosed in double quotes (") */
271
  paramt_word, /* String parameter NOT enclosed in double quotes */
272
  paramt_int, /* Integer parameter */
273
  paramt_addr /* Address parameter */
274
};
275
 
276
struct config_section {
277
  char *name;
278
  void *(*sec_start)(void);
279
  void (*sec_end)(void *);
280
  void *dat;
281
  struct config_param *params;
282
  struct config_section *next;
283
};
284
 
285
/* Register a parameter in a section of the config file */
286
void reg_config_param(struct config_section *sec, const char *param,
287
                      enum param_t type,
288
                      void (*param_cb)(union param_val, void*));
289
 
290
/* Register a section in the config file */
291
struct config_section *reg_config_sec(const char *section,
292
                                      void *(*sec_start)(void),
293
                                      void (*sec_end)(void *));
294
 
295
extern struct config_section *cur_section;
296
#define CONFIG_ERROR(s) {fprintf (stderr, "ERROR: config.%s:%s\n", cur_section->name, s); if (runtime.sim.init) exit (1);}
297
 
298 1446 nogj
/* FIXME: These will disapeer one day... */
299 1358 nogj
void reg_mc_sec(void);
300
void reg_uart_sec(void);
301
void reg_dma_sec(void);
302
void reg_memory_sec(void);
303
void reg_debug_sec(void);
304
void reg_vapi_sec(void);
305
void reg_ethernet_sec(void);
306
void reg_immu_sec(void);
307
void reg_dmmu_sec(void);
308
void reg_ic_sec(void);
309
void reg_dc_sec(void);
310
void reg_gpio_sec(void);
311
void reg_bpb_sec(void);
312
void reg_pm_sec(void);
313
void reg_vga_sec(void);
314
void reg_fb_sec(void);
315
void reg_kbd_sec(void);
316
void reg_ata_sec(void);
317
void reg_cuc_sec(void);
318 428 markom
#endif

powered by: WebSVN 2.1.0

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