Commit 735ebf7cfd5e1e8998b24653a359d05c331c021b
authorMichel Pollet <buserror@gmail.com>
Thu, 23 Feb 2017 11:01:56 +0000 (11:01 +0000)
committerMichel Pollet <buserror@gmail.com>
Thu, 2 Mar 2017 17:31:15 +0000 (17:31 +0000)
Still need the backend code, let's not get overexcited here ;-)

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

index 0a539fa8a17dedad9967cdc83679ec61ab05f698..c39d4743dbe542eb954a2aa4b4b4139d00627f35 100644 (file)
@@ -29,6 +29,7 @@
 #include "sim_core.h"
 #include "sim_gdb.h"
 #include "sim_hex.h"
+#include "sim_vcd_file.h"
 
 #include "sim_core_decl.h"
 
@@ -46,6 +47,7 @@ display_usage(
                        "       [--gdb|-g]          Listen for gdb connection on port 1234\n"
                        "       [-ff <.hex file>]   Load next .hex file as flash\n"
                        "       [-ee <.hex file>]   Load next .hex file as eeprom\n"
+                       "       [--input|-i <file>] A .vcd file to use as input signals\n"
                        "       [-v]                Raise verbosity level\n"
                        "                           (can be passed more than once)\n"
                        "       <firmware>          A .hex or an ELF file. ELF files are\n"
@@ -92,6 +94,7 @@ main(
        uint32_t loadBase = AVR_SEGMENT_OFFSET_FLASH;
        int trace_vectors[8] = {0};
        int trace_vectors_count = 0;
+       const char *vcd_input = NULL;
 
        if (argc == 1)
                display_usage(basename(argv[0]));
@@ -111,7 +114,12 @@ main(
                                f_cpu = atoi(argv[++pi]);
                        else
                                display_usage(basename(argv[0]));
-               } else if (!strcmp(argv[pi], "-t") || !strcmp(argv[pi], "-trace")) {
+               } else if (!strcmp(argv[pi], "-i") || !strcmp(argv[pi], "--input")) {
+                       if (pi < argc-1)
+                               vcd_input = argv[++pi];
+                       else
+                               display_usage(basename(argv[0]));
+               } else if (!strcmp(argv[pi], "-t") || !strcmp(argv[pi], "--trace")) {
                        trace++;
                } else if (!strcmp(argv[pi], "-ti")) {
                        if (pi < argc-1)
@@ -187,6 +195,12 @@ main(
                        if (avr->interrupts.vector[vi]->vector == trace_vectors[ti])
                                avr->interrupts.vector[vi]->trace = 1;
        }
+       if (vcd_input) {
+               static avr_vcd_t input;
+               if (avr_vcd_init_input(avr, vcd_input, &input)) {
+                       fprintf(stderr, "%s: Warning: VCD input file %s failed\n", argv[0], vcd_input);
+               }
+       }
 
        // even if not setup at startup, activate gdb if crashing
        avr->gdb_port = 1234;