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 1371

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

powered by: WebSVN 2.1.0

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