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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_62/] [or1ksim/] [sim-config.h] - Blame information for rev 1369

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

powered by: WebSVN 2.1.0

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