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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_67/] [or1ksim/] [sim-config.h] - Blame information for rev 1367

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

powered by: WebSVN 2.1.0

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