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

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_2_x/] [or1ksim/] [sim-config.h] - Blame information for rev 1471

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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