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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel-0-3-0-rc2/] [or1ksim/] [sim-config.h] - Blame information for rev 1730

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

powered by: WebSVN 2.1.0

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