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 1372

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

powered by: WebSVN 2.1.0

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