Accept memory trace filename from VCS plusargs
Now can use `EXTRA_SIM_FLAGS="+memtracefile=<tracefile>"` to simulate with different trace files without recompiling.
This commit is contained in:
@@ -75,7 +75,8 @@ MemTraceLine MemTraceReader::read_trace_at(const long cycle,
|
|||||||
// read it right now.
|
// read it right now.
|
||||||
return MemTraceLine{};
|
return MemTraceLine{};
|
||||||
} else if (line.cycle == cycle && line.lane_id == lane_id) {
|
} else if (line.cycle == cycle && line.lane_id == lane_id) {
|
||||||
printf("fire! cycle=%ld, valid=%d, %s \n", cycle, line.valid, line.loadstore);
|
printf("fire! cycle=%ld, valid=%d, %s \n", cycle, line.valid,
|
||||||
|
line.loadstore);
|
||||||
|
|
||||||
// FIXME! Currently lane_id is assumed to be in round-robin order, e.g.
|
// FIXME! Currently lane_id is assumed to be in round-robin order, e.g.
|
||||||
// 0->1->2->3->0->..., both in the trace file and the order the caller calls
|
// 0->1->2->3->0->..., both in the trace file and the order the caller calls
|
||||||
@@ -91,6 +92,23 @@ MemTraceLine MemTraceReader::read_trace_at(const long cycle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void memtrace_init(const char *filename) {
|
extern "C" void memtrace_init(const char *filename) {
|
||||||
|
#ifndef NO_VPI
|
||||||
|
s_vpi_vlog_info info;
|
||||||
|
if (!vpi_get_vlog_info(&info)) {
|
||||||
|
fprintf(stderr, "fatal: failed to get plusargs from VCS\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
const char* TRACEFILENAME_PLUSARG = "+memtracefile=";
|
||||||
|
for (int i = 0; i < info.argc; i++) {
|
||||||
|
char* input_arg = info.argv[i];
|
||||||
|
if (strncmp(input_arg, TRACEFILENAME_PLUSARG,
|
||||||
|
strlen(TRACEFILENAME_PLUSARG)) == 0) {
|
||||||
|
filename = input_arg + strlen(TRACEFILENAME_PLUSARG);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
printf("memtrace_init: filename=[%s]\n", filename);
|
printf("memtrace_init: filename=[%s]\n", filename);
|
||||||
|
|
||||||
reader = std::make_unique<MemTraceReader>(filename);
|
reader = std::make_unique<MemTraceReader>(filename);
|
||||||
|
|||||||
Reference in New Issue
Block a user