Line 19... |
Line 19... |
|
|
/* Simulator configuration. Eventually this one will be a lot bigger. */
|
/* Simulator configuration. Eventually this one will be a lot bigger. */
|
|
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include <limits.h>
|
#include <limits.h>
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
|
#include "sim-config.h"
|
#include "sim-config.h"
|
#include "abstract.h"
|
#include "abstract.h"
|
#include "sprs.h"
|
#include "sprs.h"
|
#include "spr_defs.h"
|
#include "spr_defs.h"
|
#include "pic.h"
|
#include "pic.h"
|
Line 186... |
Line 189... |
runtime.vapi.enabled = 0;
|
runtime.vapi.enabled = 0;
|
}
|
}
|
|
|
int parse_args(int argc, char *argv[])
|
int parse_args(int argc, char *argv[])
|
{
|
{
|
unsigned long val;
|
|
|
|
argv++; argc--;
|
argv++; argc--;
|
while (argc) {
|
while (argc) {
|
if (strcmp(*argv, "profiler") == 0) {
|
if (strcmp(*argv, "profiler") == 0) {
|
exit (main_profiler (argc, argv));
|
exit (main_profiler (argc, argv));
|
} else
|
} else
|
Line 1305... |
Line 1306... |
*/
|
*/
|
|
|
void read_script_file (char *filename)
|
void read_script_file (char *filename)
|
{
|
{
|
FILE *f;
|
FILE *f;
|
unsigned long memory_needed = 0;
|
|
char *home = getenv("HOME");
|
char *home = getenv("HOME");
|
char ctmp[STR_SIZE];
|
char ctmp[STR_SIZE];
|
int local = 1;
|
int local = 1;
|
section = 0;
|
section = 0;
|
|
|
sprintf(ctmp, "%s/.or1k/%s", home, filename);
|
sprintf(ctmp, "%s/.or1k/%s", home, filename);
|
if ((f = fopen (filename, "rt")) != NULL
|
if ((f = fopen (filename, "rt")) != NULL
|
|| home != NULL && !(local = 0) && (f = fopen (ctmp, "rt")) != NULL) {
|
|| home != NULL && !(local = 0) && (f = fopen (ctmp, "rt")) != NULL) {
|
unsigned long start, length;
|
|
char type[STR_SIZE];
|
|
int nparam;
|
|
int rd, wd;
|
|
if (config.sim.verbose && !runtime.sim.output_cfg)
|
if (config.sim.verbose && !runtime.sim.output_cfg)
|
PRINTF ("Reading script file from '%s'...\n", local ? filename : ctmp);
|
PRINTF ("Reading script file from '%s'...\n", local ? filename : ctmp);
|
strcpy (runtime.sim.script_fn, local ? filename : ctmp);
|
strcpy (runtime.sim.script_fn, local ? filename : ctmp);
|
|
|
while (!feof(f)) {
|
while (!feof(f)) {
|
char param[STR_SIZE];
|
char param[STR_SIZE];
|
if (fscanf(f, "%s ", ¶m) != 1) break;
|
if (fscanf(f, "%s ", param) != 1) break;
|
/* Is this a sections? */
|
/* Is this a sections? */
|
if (strcmp (param, "section") == 0) {
|
if (strcmp (param, "section") == 0) {
|
int i;
|
int i;
|
section = 0;
|
section = 0;
|
if (fscanf (f, "%s\n", ¶m) != 1) {
|
if (fscanf (f, "%s\n", param) != 1) {
|
fprintf (stderr, "%s: ERROR: Section name required.\n", local ? filename : ctmp);
|
fprintf (stderr, "%s: ERROR: Section name required.\n", local ? filename : ctmp);
|
exit (1);
|
exit (1);
|
}
|
}
|
for (i = 1; i < sizeof(sections) / sizeof(struct section); i++)
|
for (i = 1; i < sizeof(sections) / sizeof(struct section); i++)
|
if (strcmp (sections[i].name, param) == 0) {
|
if (strcmp (sections[i].name, param) == 0) {
|
Line 1343... |
Line 1339... |
if (!section) {
|
if (!section) {
|
char tmp[200];
|
char tmp[200];
|
sprintf (tmp, "Unknown section: %s; ignoring.", param);
|
sprintf (tmp, "Unknown section: %s; ignoring.", param);
|
WARNING(tmp);
|
WARNING(tmp);
|
/* just skip section */
|
/* just skip section */
|
while (fscanf (f, "%s\n", ¶m) != 1 && strcmp (param, "end"));
|
while (fscanf (f, "%s\n", param) != 1 && strcmp (param, "end"));
|
}
|
}
|
} else if (strcmp (param, "end") == 0) {
|
} else if (strcmp (param, "end") == 0) {
|
section = 0;
|
section = 0;
|
} else if (strncmp (param, "/*", 2) == 0) {
|
} else if (strncmp (param, "/*", 2) == 0) {
|
char c0 = 0, c1 = 0;
|
char c0 = 0, c1 = 0;
|
Line 1478... |
Line 1474... |
|
|
fprintf (f, " tick:{enabled:%i},\n", config.tick.enabled);
|
fprintf (f, " tick:{enabled:%i},\n", config.tick.enabled);
|
fprintf (f, " nuarts:%i, uarts:{", config.nuarts);
|
fprintf (f, " nuarts:%i, uarts:{", config.nuarts);
|
comma = 0;
|
comma = 0;
|
for (i = 0; i < config.nuarts; i++) {
|
for (i = 0; i < config.nuarts; i++) {
|
fprintf (f, "%s\n {channel:\"%s\", jitter:%i, baseaddr:0x%08x, irq:%i, vapi_id:0x%08x, uart16550:%i}",
|
fprintf (f, "%s\n {channel:\"%s\", jitter:%i, baseaddr:0x%08lx, irq:%i, vapi_id:0x%08lx, uart16550:%i}",
|
comma ? "," :"", config.uarts[i].channel, config.uarts[i].jitter, config.uarts[i].baseaddr, config.uarts[i].irq,
|
comma ? "," :"", config.uarts[i].channel, config.uarts[i].jitter, config.uarts[i].baseaddr, config.uarts[i].irq,
|
config.uarts[i].vapi_id, config.uarts[i].uart16550);
|
config.uarts[i].vapi_id, config.uarts[i].uart16550);
|
comma = 1;
|
comma = 1;
|
}
|
}
|
fprintf (f, "},\n");
|
fprintf (f, "},\n");
|
|
|
fprintf (f, " ndmas:%i, dmas:{", config.ndmas);
|
fprintf (f, " ndmas:%i, dmas:{", config.ndmas);
|
comma = 0;
|
comma = 0;
|
for (i = 0; i < config.ndmas; i++) {
|
for (i = 0; i < config.ndmas; i++) {
|
fprintf (f, "%s\n {baseaddr:0x%08x, irq:%i, vapi_id:0x%08x}",
|
fprintf (f, "%s\n {baseaddr:0x%08lx, irq:%i, vapi_id:0x%08lx}",
|
comma ? "," :"", config.dmas[i].baseaddr, config.dmas[i].irq, config.dmas[i].vapi_id);
|
comma ? "," :"", config.dmas[i].baseaddr, config.dmas[i].irq, config.dmas[i].vapi_id);
|
comma = 1;
|
comma = 1;
|
}
|
}
|
fprintf (f, "},\n");
|
fprintf (f, "},\n");
|
|
|
fprintf (f, " nethernets:%i, ethernets:{", config.nethernets);
|
fprintf (f, " nethernets:%i, ethernets:{", config.nethernets);
|
comma = 0;
|
comma = 0;
|
for (i = 0; i < config.nethernets; i++) {
|
for (i = 0; i < config.nethernets; i++) {
|
fprintf (f, "%s\n {baseaddr:0x%08x, dma:%i, tx_channel:0x%08x, rx_channel:0x%08x, rxfile:\"%s\", txfile:\"%s\", vapi_id:0x%08x}",
|
fprintf (f, "%s\n {baseaddr:0x%08lx, dma:%i, tx_channel:0x%08x, rx_channel:0x%08x, rxfile:\"%s\", txfile:\"%s\", vapi_id:0x%08lx}",
|
comma ? "," :"", config.ethernets[i].baseaddr, config.ethernets[i].dma, config.ethernets[i].tx_channel, config.ethernets[i].rx_channel,
|
comma ? "," :"", config.ethernets[i].baseaddr, config.ethernets[i].dma, config.ethernets[i].tx_channel, config.ethernets[i].rx_channel,
|
config.ethernets[i].rxfile, config.ethernets[i].txfile, config.ethernets[i].base_vapi_id);
|
config.ethernets[i].rxfile, config.ethernets[i].txfile, config.ethernets[i].base_vapi_id);
|
comma = 1;
|
comma = 1;
|
}
|
}
|
fprintf (f, "},\n");
|
fprintf (f, "},\n");
|
|
|
fprintf (f, " ngpios:%i, gpios:{", config.ngpios);
|
fprintf (f, " ngpios:%i, gpios:{", config.ngpios);
|
comma = 0;
|
comma = 0;
|
for (i = 0; i < config.ngpios; i++) {
|
for (i = 0; i < config.ngpios; i++) {
|
fprintf (f, "%s\n {baseaddr:0x%08x, irq:%i, base_vapi_id:0x%08x}",
|
fprintf (f, "%s\n {baseaddr:0x%08lx, irq:%i, base_vapi_id:0x%08lx}",
|
comma ? "," :"", config.gpios[i].baseaddr, config.gpios[i].irq, config.gpios[i].base_vapi_id);
|
comma ? "," :"", config.gpios[i].baseaddr, config.gpios[i].irq, config.gpios[i].base_vapi_id);
|
comma = 1;
|
comma = 1;
|
}
|
}
|
fprintf (f, "},\n");
|
fprintf (f, "},\n");
|
|
|
fprintf (f, " mc:{enabled:%i, baseaddr:%i, POC:%i},\n", config.mc.enabled, config.mc.baseaddr, config.mc.POC);
|
fprintf (f, " mc:{enabled:%i, baseaddr:0x%08lx, POC:%i},\n", config.mc.enabled, config.mc.baseaddr, config.mc.POC);
|
fprintf (f, " memory:{pattern:%i, random_seed:%i, type:%s, nmemories:%i, table:{", config.memory.pattern, config.memory.random_seed,
|
fprintf (f, " memory:{pattern:%i, random_seed:%i, type:%s, nmemories:%i, table:{", config.memory.pattern, config.memory.random_seed,
|
config.memory.type == MT_UNKNOWN ? "MT_UNKNOWN" : config.memory.type == MT_PATTERN ? "MT_PATTERN" : "MT_RANDOM", config.memory.nmemories);
|
config.memory.type == MT_UNKNOWN ? "MT_UNKNOWN" : config.memory.type == MT_PATTERN ? "MT_PATTERN" : "MT_RANDOM", config.memory.nmemories);
|
comma = 0;
|
comma = 0;
|
for (i = 0; i < config.memory.nmemories; i++) {
|
for (i = 0; i < config.memory.nmemories; i++) {
|
fprintf (f, "%s\n {ce:%i, baseaddr:0x%08x, size:0x%08x, name:\"%s\", log:\"%s\", delayr:%i, delayw:%i}",
|
fprintf (f, "%s\n {ce:%i, baseaddr:0x%08lx, size:0x%08lx, name:\"%s\", log:\"%s\", delayr:%i, delayw:%i}",
|
comma ? "," :"", config.memory.table[i].ce, config.memory.table[i].baseaddr, config.memory.table[i].size, config.memory.table[i].name,
|
comma ? "," :"", config.memory.table[i].ce, config.memory.table[i].baseaddr, config.memory.table[i].size, config.memory.table[i].name,
|
config.memory.table[i].log, config.memory.table[i].delayr, config.memory.table[i].delayw);
|
config.memory.table[i].log, config.memory.table[i].delayr, config.memory.table[i].delayw);
|
comma = 1;
|
comma = 1;
|
}
|
}
|
fprintf (f, "}},\n");
|
fprintf (f, "}},\n");
|
Line 1545... |
Line 1541... |
config.dc.load_missdelay, config.dc.load_hitdelay, config.dc.store_missdelay, config.dc.store_hitdelay);
|
config.dc.load_missdelay, config.dc.load_hitdelay, config.dc.store_missdelay, config.dc.store_hitdelay);
|
|
|
fprintf (f, " bpb:{enabled:%i, sbp_bnf_fwd:%i, sbp_bf_fwd:%i, btic:%i, missdelay:%i, hitdelay:%i},\n",
|
fprintf (f, " bpb:{enabled:%i, sbp_bnf_fwd:%i, sbp_bf_fwd:%i, btic:%i, missdelay:%i, hitdelay:%i},\n",
|
config.bpb.enabled, config.bpb.sbp_bnf_fwd, config.bpb.sbp_bf_fwd, config.bpb.btic, config.bpb.missdelay, config.bpb.hitdelay);
|
config.bpb.enabled, config.bpb.sbp_bnf_fwd, config.bpb.sbp_bf_fwd, config.bpb.btic, config.bpb.missdelay, config.bpb.hitdelay);
|
|
|
fprintf (f, " cpu:{upr:0x%08x, ver:0x%04x, rev:0x%04x, superscalar:%i, hazards:%i, dependstats:%i,\n"
|
fprintf (f, " cpu:{upr:0x%08lx, ver:0x%04lx, rev:0x%04lx, superscalar:%i, hazards:%i, dependstats:%i,\n"
|
" sr:0x%08x},\n",
|
" sr:0x%08x},\n",
|
config.cpu.upr, config.cpu.ver, config.cpu.rev, config.cpu.superscalar, config.cpu.hazards, config.cpu.dependstats,
|
config.cpu.upr, config.cpu.ver, config.cpu.rev, config.cpu.superscalar, config.cpu.hazards, config.cpu.dependstats,
|
config.cpu.sr);
|
config.cpu.sr);
|
|
|
fprintf (f, " sim:{debug:%i, verbose:%i, profile:%i, prof_fn:\"%s\", mprofile:%i, mprof_fn:\"%s\",\n",
|
fprintf (f, " sim:{debug:%i, verbose:%i, profile:%i, prof_fn:\"%s\", mprofile:%i, mprof_fn:\"%s\",\n",
|
config.sim.debug, config.sim.verbose, config.sim.profile, config.sim.prof_fn, config.sim.mprofile, config.sim.mprof_fn);
|
config.sim.debug, config.sim.verbose, config.sim.profile, config.sim.prof_fn, config.sim.mprofile, config.sim.mprof_fn);
|
|
|
fprintf (f, " history:%i, exe_log:%i, exe_log_fn:\"%s\", clkcycle_ps:%i,\n",
|
fprintf (f, " history:%i, exe_log:%i, exe_log_fn:\"%s\", clkcycle_ps:%li,\n",
|
config.sim.history, config.sim.exe_log, config.sim.exe_log_fn, config.sim.clkcycle_ps);
|
config.sim.history, config.sim.exe_log, config.sim.exe_log_fn, config.sim.clkcycle_ps);
|
|
|
fprintf (f, " spr_log:%i, spr_log_fn:\"%s\"},\n",
|
fprintf (f, " spr_log:%i, spr_log_fn:\"%s\"},\n",
|
config.sim.spr_log, config.sim.spr_log_fn);
|
config.sim.spr_log, config.sim.spr_log_fn);
|
|
|
fprintf (f, " debug:{enabled:%i, gdb_enabled:%i, server_port:%i, vapi_id:0x%08x},\n",
|
fprintf (f, " debug:{enabled:%i, gdb_enabled:%i, server_port:%i, vapi_id:0x%08lx},\n",
|
config.debug.enabled, config.debug.gdb_enabled, config.debug.server_port, config.debug.vapi_id);
|
config.debug.enabled, config.debug.gdb_enabled, config.debug.server_port, config.debug.vapi_id);
|
|
|
fprintf (f, " vapi:{enabled:%i, server_port:%i, log_enabled:%i, hide_device_id:%i, vapi_fn:\"%s\"},\n",
|
fprintf (f, " vapi:{enabled:%i, server_port:%i, log_enabled:%i, hide_device_id:%i, vapi_fn:\"%s\"},\n",
|
config.vapi.enabled, config.vapi.server_port, config.vapi.log_enabled, config.vapi.hide_device_id, config.vapi.vapi_fn);
|
config.vapi.enabled, config.vapi.server_port, config.vapi.log_enabled, config.vapi.hide_device_id, config.vapi.vapi_fn);
|
|
|