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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_70/] [or1ksim/] [sim-config.h] - Blame information for rev 1368

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

powered by: WebSVN 2.1.0

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