mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
build/sim: handle verilog $finish and if coverage is enabled, write report at the end of the simulation.
This commit is contained in:
parent
b6c98cab0d
commit
180912a7a3
4 changed files with 29 additions and 5 deletions
|
@ -32,6 +32,7 @@ struct session_list_s {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct session_list_s *sesslist=NULL;
|
struct session_list_s *sesslist=NULL;
|
||||||
|
struct event_base *base=NULL;
|
||||||
|
|
||||||
static int litex_sim_initialize_all(void **dut, void *base)
|
static int litex_sim_initialize_all(void **dut, void *base)
|
||||||
{
|
{
|
||||||
|
@ -175,7 +176,6 @@ static void cb(int sock, short which, void *arg)
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
||||||
for(i = 0; i < 1000; i++)
|
for(i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
for(s = sesslist; s; s=s->next)
|
for(s = sesslist; s; s=s->next)
|
||||||
|
@ -192,6 +192,9 @@ static void cb(int sock, short which, void *arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (litex_sim_got_finish())
|
||||||
|
event_base_loopbreak(base);
|
||||||
|
|
||||||
if (!evtimer_pending(ev, NULL)) {
|
if (!evtimer_pending(ev, NULL)) {
|
||||||
event_del(ev);
|
event_del(ev);
|
||||||
evtimer_add(ev, &tv);
|
evtimer_add(ev, &tv);
|
||||||
|
@ -201,7 +204,6 @@ static void cb(int sock, short which, void *arg)
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
void *vdut=NULL;
|
void *vdut=NULL;
|
||||||
struct event_base *base=NULL;
|
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -235,8 +237,10 @@ int main()
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
ev = event_new(base, -1, EV_PERSIST, cb, vdut);
|
ev = event_new(base, -1, EV_PERSIST, cb, vdut);
|
||||||
event_add(ev, &tv);
|
event_add(ev, &tv);
|
||||||
|
|
||||||
event_base_dispatch(base);
|
event_base_dispatch(base);
|
||||||
|
#if VM_COVERAGE
|
||||||
|
litex_sim_coverage_dump();
|
||||||
|
#endif
|
||||||
out:
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,17 @@ extern "C" void litex_sim_tracer_dump()
|
||||||
tfp->dump(ticks++);
|
tfp->dump(ticks++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" int litex_sim_got_finish()
|
||||||
|
{
|
||||||
|
return Verilated::gotFinish();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if VM_COVERAGE
|
||||||
|
extern "C" void litex_sim_coverage_dump()
|
||||||
|
{
|
||||||
|
VerilatedCov::write("dut.cov");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
vluint64_t main_time = 0;
|
vluint64_t main_time = 0;
|
||||||
double sc_time_stamp()
|
double sc_time_stamp()
|
||||||
|
|
|
@ -7,10 +7,18 @@
|
||||||
extern "C" void litex_sim_eval(void *vdut);
|
extern "C" void litex_sim_eval(void *vdut);
|
||||||
extern "C" void litex_sim_init_tracer(void *vdut);
|
extern "C" void litex_sim_init_tracer(void *vdut);
|
||||||
extern "C" void litex_sim_tracer_dump();
|
extern "C" void litex_sim_tracer_dump();
|
||||||
|
extern "C" int litex_sim_got_finish();
|
||||||
|
#if VM_COVERAGE
|
||||||
|
extern "C" void litex_sim_coverage_dump();
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
void litex_sim_eval(void *vdut);
|
void litex_sim_eval(void *vdut);
|
||||||
void litex_sim_init_tracer(void *vdut);
|
void litex_sim_init_tracer(void *vdut);
|
||||||
void litex_sim_tracer_dump();
|
void litex_sim_tracer_dump();
|
||||||
|
int litex_sim_got_finish();
|
||||||
|
#if VM_COVERAGE
|
||||||
|
void litex_sim_coverage_dump();
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -160,6 +160,7 @@ def _run_sim(build_name, as_root=False):
|
||||||
if r != 0:
|
if r != 0:
|
||||||
raise OSError("Subprocess failed")
|
raise OSError("Subprocess failed")
|
||||||
except:
|
except:
|
||||||
|
pass
|
||||||
if sys.platform != "win32":
|
if sys.platform != "win32":
|
||||||
termios.tcsetattr(sys.stdin.fileno(), termios.TCSAFLUSH, termios_settings)
|
termios.tcsetattr(sys.stdin.fileno(), termios.TCSAFLUSH, termios_settings)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue