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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_40/] [or1ksim/] [sim-config.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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