From 3cee361fbf6efd5b4fc76509efadc4a7aff977ce Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Thu, 17 Dec 2009 19:53:42 +0000 Subject: [PATCH] core: Added an avr_terminate() call This allow the VCD file to be flushed and closed properly. Signed-off-by: Michel Pollet --- simavr/sim/run_avr.c | 4 +++- simavr/sim/sim_avr.c | 8 ++++++++ simavr/sim/sim_avr.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/simavr/sim/run_avr.c b/simavr/sim/run_avr.c index bc1d606..f39fb3b 100644 --- a/simavr/sim/run_avr.c +++ b/simavr/sim/run_avr.c @@ -135,5 +135,7 @@ int main(int argc, char *argv[]) } for (;;) - avr_run(avr); + avr_run(avr); + + avr_terminate(avr); } diff --git a/simavr/sim/sim_avr.c b/simavr/sim/sim_avr.c index e0f9cb7..ae480ff 100644 --- a/simavr/sim/sim_avr.c +++ b/simavr/sim/sim_avr.c @@ -26,6 +26,7 @@ #include "sim_avr.h" #include "sim_core.h" #include "sim_gdb.h" +#include "sim_vcd_file.h" int avr_init(avr_t * avr) @@ -45,6 +46,13 @@ int avr_init(avr_t * avr) return 0; } +void avr_terminate(avr_t * avr) +{ + if (avr->vcd) + avr_vcd_close(avr->vcd); + avr->vcd = NULL; +} + void avr_reset(avr_t * avr) { memset(avr->data, 0x0, avr->ramend + 1); diff --git a/simavr/sim/sim_avr.h b/simavr/sim/sim_avr.h index cac737f..27b2354 100644 --- a/simavr/sim/sim_avr.h +++ b/simavr/sim/sim_avr.h @@ -212,6 +212,8 @@ int avr_init(avr_t * avr); void avr_reset(avr_t * avr); // run one cycle of the AVR, sleep if necessary int avr_run(avr_t * avr); +// finish any pending operations +void avr_terminate(avr_t * avr); // load code in the "flash" void avr_loadcode(avr_t * avr, uint8_t * code, uint32_t size, uint32_t address); -- 2.20.1