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 1370

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

powered by: WebSVN 2.1.0

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