core: Added an avr_terminate() call
authorMichel Pollet <buserror@gmail.com>
Thu, 17 Dec 2009 19:53:42 +0000 (19:53 +0000)
committerMichel Pollet <buserror@gmail.com>
Thu, 17 Dec 2009 19:53:42 +0000 (19:53 +0000)
This allow the VCD file to be flushed and closed properly.

Signed-off-by: Michel Pollet <buserror@gmail.com>
simavr/sim/run_avr.c
simavr/sim/sim_avr.c
simavr/sim/sim_avr.h

index bc1d606..f39fb3b 100644 (file)
@@ -135,5 +135,7 @@ int main(int argc, char *argv[])
        }
 
        for (;;)
-               avr_run(avr);   
+               avr_run(avr);
+       
+       avr_terminate(avr);
 }
index e0f9cb7..ae480ff 100644 (file)
@@ -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);
index cac737f..27b2354 100644 (file)
@@ -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);