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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [or1ksim/] [sim-config.h] - Blame information for rev 1743

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 1743 jeremybenn
 
3 7 jrydberg
   Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
4 1743 jeremybenn
   Copyright (C) 2008 Embecosm Limited
5
 
6
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
7
 
8 7 jrydberg
   This file is part of OpenRISC 1000 Architectural Simulator.
9 1743 jeremybenn
 
10
   This program is free software; you can redistribute it and/or modify it
11
   under the terms of the GNU General Public License as published by the Free
12
   Software Foundation; either version 3 of the License, or (at your option)
13
   any later version.
14
 
15
   This program is distributed in the hope that it will be useful, but WITHOUT
16
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
18
   more details.
19
 
20
   You should have received a copy of the GNU General Public License along
21
   with this program.  If not, see <http://www.gnu.org/licenses/>. */
22 428 markom
 
23 1743 jeremybenn
 
24 428 markom
#ifndef _CONFIG_H_
25
#define _CONFIG_H_
26
 
27 173 markom
#include <stdio.h>
28
 
29 7 jrydberg
/* Simulator configuration macros. Eventually this one will be a lot bigger. */
30 30 lampret
 
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 1718 nogj
 
44 261 markom
  struct {
45 428 markom
    int enabled;                      /* Whether instruction cache is enabled */
46
    int nways;                        /* Number of IC ways */
47
    int nsets;                        /* Number of IC sets */
48
    int blocksize;                    /* IC entry size */
49
    int ustates;                      /* number of IC usage states */
50 541 markom
    int missdelay;                    /* How much cycles does the miss cost */
51
    int hitdelay;                     /* How much cycles does the hit cost */
52 1730 nogj
    unsigned int blocksize_log2;      /* log2(blocksize) */
53
    oraddr_t set_mask;                /* Mask to get set number */
54
    oraddr_t tagaddr_mask;            /* Mask to get tag address */
55
    oraddr_t last_way;                /* nways * nsets */
56
    oraddr_t block_offset_mask;       /* mask to get offset into block */
57
    oraddr_t block_mask;              /* mask to get block number */
58
    unsigned int ustates_reload;      /* ustates - 1 */
59 428 markom
  } ic;
60 424 markom
 
61 263 markom
  struct {
62 541 markom
    int enabled;                      /* Whether data cache is enabled */
63 428 markom
    int nways;                        /* Number of DC ways */
64
    int nsets;                        /* Number of DC sets */
65
    int blocksize;                    /* DC entry size */
66
    int ustates;                      /* number of DC usage states */
67 541 markom
    int store_missdelay;              /* How much cycles does the store miss cost */
68
    int store_hitdelay;               /* How much cycles does the store hit cost */
69
    int load_missdelay;               /* How much cycles does the load miss cost */
70
    int load_hitdelay;                /* How much cycles does the load hit cost */
71 428 markom
  } dc;
72
 
73
  struct {
74 672 markom
    int enabled;                      /* branch prediction buffer analysis */
75
    int sbp_bnf_fwd;                  /* Static branch prediction for l.bnf uses forward prediction */
76
    int sbp_bf_fwd;                   /* Static branch prediction for l.bf uses forward prediction */
77
    int btic;                         /* branch prediction target insn cache analysis */
78
    int missdelay;                    /* How much cycles does the miss cost */
79
    int hitdelay;                     /* How much cycles does the hit cost */
80
#if 0                                 
81
    int nways;                        /* Number of BP ways */
82
    int nsets;                        /* Number of BP sets */
83
    int blocksize;                    /* BP entry size */
84
    int ustates;                      /* number of BP usage states */
85
    int pstates;                      /* number of BP predict states */
86
#endif                                
87
  } bpb;
88
 
89
  struct {
90
    unsigned long upr;                /* Unit present register */
91 1743 jeremybenn
    unsigned long cfgr;               /* CPU configuration register */
92 672 markom
    unsigned long ver, rev;           /* Version register */
93
    int sr;                           /* Supervision register */
94
    int superscalar;                  /* superscalara analysis */
95
    int hazards;                      /* dependency hazards analysis */
96
    int dependstats;                  /* dependency statistics */
97
    int sbuf_len;                     /* length of store buffer, zero if disabled */
98
  } cpu;
99
 
100
  struct {
101
    int debug;                        /* Simulator debugging */
102
    int verbose;                      /* Force verbose output */
103
 
104
    int profile;                      /* Is profiler running */
105
    char prof_fn[STR_SIZE];           /* Profiler filename */
106
 
107
    int mprofile;                     /* Is memory profiler running */
108
    char mprof_fn[STR_SIZE];          /* Memory profiler filename */
109
 
110
    int history;                      /* instruction stream history analysis */
111
    int exe_log;                      /* Print out RTL states? */
112
    int exe_log_type;                 /* Type of log */
113 1580 nogj
    long long int exe_log_start;      /* First instruction to log */
114
    long long int exe_log_end;        /* Last instruction to log, -1 if continuous */
115 672 markom
    int exe_log_marker;               /* If nonzero, place markers before each exe_log_marker instructions */
116
    char exe_log_fn[STR_SIZE];        /* RTL state comparison filename */
117 823 ivang
    char fstdout[STR_SIZE];           /* stdout filename */
118 672 markom
    long clkcycle_ps;                 /* Clock duration in ps */
119 805 markom
    long system_kfreq;                /* System frequency in kHz*/
120 672 markom
  } sim;
121
 
122
  struct {
123 1743 jeremybenn
    int enabled;                      /* Is debug module enabled */
124
    int gdb_enabled;                  /* Is debugging with gdb possible */
125
    int server_port;                  /* A user specified port for services */
126
    unsigned long      vapi_id;       /* "Fake" vapi dev id for JTAG proxy */
127
    unsigned long int  cfgr;          /* JPB: Debug config SPR */
128 672 markom
  } debug;
129
 
130
  struct {                            /* Verification API, part of Advanced Core Verification */
131
    int enabled;                      /* Whether is VAPI module enabled */
132
    int server_port;                  /* A user specified port number for services */
133
    int log_enabled;                  /* Whether to log the vapi requests */
134
    int hide_device_id;               /* Whether to log device ID for each request */
135
    char vapi_fn[STR_SIZE];           /* vapi log filename */
136
  } vapi;
137
 
138
  struct {
139
    int enabled;                      /* Whether power menagement is operational */
140
  } pm;
141 897 markom
 
142
  struct {
143
    char timings_fn[STR_SIZE];        /* Filename of the timing table */
144
    int memory_order;                 /* Memory access stricness */
145
    int calling_convention;           /* Whether functions follow standard calling convention */
146
    int enable_bursts;                /* Whether burst are enabled */
147
    int no_multicycle;                /* When enabled no multicycle paths are generated */
148
  } cuc;
149 672 markom
};
150
 
151
struct runtime {
152
  struct {
153
    FILE *fprof;                      /* Profiler file */
154
    FILE *fmprof;                     /* Memory profiler file */
155
    FILE *fexe_log;                   /* RTL state comparison file */
156 997 markom
    FILE *fout;                       /* file for standard output */
157 672 markom
    int init;                         /* Whether we are still initilizing sim */
158
    int script_file_specified;        /* Whether script file was already loaded */
159
    char *filename;                   /* Original Command Simulator file (CZ) */
160
    char script_fn[STR_SIZE];         /* Script file read */
161
    int iprompt;                      /* Interactive prompt */
162 1593 nogj
    int iprompt_run;                  /* Interactive prompt is running */
163 1320 phoenix
    long long cycles;                 /* Cycles counts fetch stages */
164 884 markom
 
165
    int mem_cycles;                   /* Each cycle has counter of mem_cycles;
166
                                         this value is joined with cycles
167
                                         at the end of the cycle; no sim
168
                                         originated memory accesses should be
169
                                         performed inbetween. */
170
    int loadcycles;                   /* Load and store stalls */
171
    int storecycles;
172 1320 phoenix
 
173
    long long reset_cycles;
174 1353 nogj
 
175
    int hush;                         /* Is simulator to do reg dumps */
176 264 markom
  } sim;
177 883 markom
 
178
  /* Command line parameters */
179
  struct {
180
    int profile;                      /* Whether profiling was enabled */
181
    int mprofile;                     /* Whether memory profiling was enabled */
182
  } simcmd;
183 557 markom
 
184
  struct {
185 1320 phoenix
    long long instructions;           /* Instructions executed */
186
    long long reset_instructions;
187
 
188 884 markom
    int stalled;
189
    int hazardwait;                   /* how many cycles were wasted because of hazards */
190
    int supercycles;                  /* Superscalar cycles */
191 672 markom
  } cpu;
192
 
193
  struct {                            /* Verification API, part of Advanced Core Verification */
194
    int enabled;                      /* Whether is VAPI module enabled */
195
    FILE *vapi_file;                  /* vapi file */
196
    int server_port;                  /* A user specified port number for services */
197 293 markom
  } vapi;
198 897 markom
 
199
/* CUC configuration parameters */
200
  struct {
201
    int mdelay[4];                  /* average memory delays in cycles
202
                                     {read single, read burst, write single, write burst} */
203
    double cycle_duration;          /* in ns */
204
  } cuc;
205 7 jrydberg
};
206 239 markom
 
207 7 jrydberg
extern struct config config;
208 551 markom
 
209 997 markom
#define PRINTF(x...) fprintf (runtime.sim.fout, x)
210
 
211 361 markom
extern struct runtime runtime;
212 239 markom
 
213
/* Read environment from a script file. Does not fail - assumes defaukt configuration instead. */
214
void read_script_file (char *filename);
215 361 markom
 
216
/* Executes set sim command.  Returns nonzero if error.  */
217 1353 nogj
void set_config_command (int argc, char **argv);
218 428 markom
 
219 1550 nogj
void init_defconfig(void);
220 549 markom
 
221 1308 phoenix
int parse_args(int argc, char *argv[]);
222
 
223 1550 nogj
void print_config(void);
224 1308 phoenix
 
225 1353 nogj
void sim_done(void);
226
 
227 1471 nogj
/* Periodically checks runtime.sim.iprompt to see if ctrl_c has been pressed */
228
void check_int(void *dat);
229
 
230
/* Number of cycles between checks to runtime.sim.iprompt */
231
#define CHECK_INT_TIME 100000
232
 
233 1353 nogj
/* Resets all subunits */
234
void sim_reset(void);
235
 
236
/* Handle the sim commandline */
237
void handle_sim_command(void);
238 1358 nogj
 
239 1360 nogj
/* Registers a new reset hook, called when sim_reset below is called */
240
void reg_sim_reset(void (*reset_hook)(void *), void *dat);
241
 
242 1363 nogj
/* Registers a status printing callback */
243
void reg_sim_stat(void (*stat_func)(void *dat), void *dat);
244
 
245 1358 nogj
union param_val {
246
  char *str_val;
247
  int int_val;
248 1580 nogj
  long long int longlong_val;
249 1358 nogj
  oraddr_t addr_val;
250
};
251
 
252
enum param_t {
253
  paramt_none = 0, /* No parameter */
254
  paramt_str, /* String parameter enclosed in double quotes (") */
255
  paramt_word, /* String parameter NOT enclosed in double quotes */
256
  paramt_int, /* Integer parameter */
257 1580 nogj
  paramt_longlong, /* Long long int parameter */
258 1358 nogj
  paramt_addr /* Address parameter */
259
};
260
 
261
struct config_section {
262
  char *name;
263
  void *(*sec_start)(void);
264
  void (*sec_end)(void *);
265
  void *dat;
266
  struct config_param *params;
267
  struct config_section *next;
268
};
269
 
270
/* Register a parameter in a section of the config file */
271
void reg_config_param(struct config_section *sec, const char *param,
272
                      enum param_t type,
273
                      void (*param_cb)(union param_val, void*));
274
 
275
/* Register a section in the config file */
276
struct config_section *reg_config_sec(const char *section,
277
                                      void *(*sec_start)(void),
278
                                      void (*sec_end)(void *));
279
 
280
extern struct config_section *cur_section;
281
#define CONFIG_ERROR(s) {fprintf (stderr, "ERROR: config.%s:%s\n", cur_section->name, s); if (runtime.sim.init) exit (1);}
282
 
283 1446 nogj
/* FIXME: These will disapeer one day... */
284 1715 nogj
void reg_pic_sec(void);
285 1358 nogj
void reg_mc_sec(void);
286
void reg_uart_sec(void);
287
void reg_dma_sec(void);
288
void reg_memory_sec(void);
289
void reg_debug_sec(void);
290
void reg_vapi_sec(void);
291
void reg_ethernet_sec(void);
292
void reg_immu_sec(void);
293
void reg_dmmu_sec(void);
294
void reg_ic_sec(void);
295
void reg_dc_sec(void);
296
void reg_gpio_sec(void);
297
void reg_bpb_sec(void);
298
void reg_pm_sec(void);
299
void reg_vga_sec(void);
300
void reg_fb_sec(void);
301
void reg_kbd_sec(void);
302
void reg_ata_sec(void);
303
void reg_cuc_sec(void);
304 1557 nogj
void reg_config_secs(void);
305 428 markom
#endif

powered by: WebSVN 2.1.0

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