Commit 61d2f1f006f6bc10dcdbcbb35b75834527edc171
authorDaniël Geelen <daniel.geelen+github@gmail.com>
Wed, 18 Apr 2018 06:35:28 +0000 (08:35 +0200)
committerDaniël Geelen <daniel.geelen+github@gmail.com>
Sat, 21 Apr 2018 18:57:54 +0000 (20:57 +0200)
simavr/sim/run_avr.c

index c39d4743dbe542eb954a2aa4b4b4139d00627f35..c3a00c1779b16163301f4ce250df3117162ca3ed 100644 (file)
@@ -121,6 +121,63 @@ main(
                                display_usage(basename(argv[0]));
                } else if (!strcmp(argv[pi], "-t") || !strcmp(argv[pi], "--trace")) {
                        trace++;
+               } else if (!strcmp(argv[pi], "--vcd-trace-name")) {
+                       if(pi+1>=argc) {
+                               fprintf(stderr, "%s: missing mandatory argument for %s.\n", argv[0], argv[pi]);
+                               exit(1);
+                       }
+                       ++pi;
+                       strncpy(f.tracename, argv[pi], sizeof(f.tracename));
+               } else if (!strcmp(argv[pi], "--add-vcd-trace")) {
+                       if(pi+1>=argc) {
+                               fprintf(stderr, "%s: missing mandatory argument for %s.\n", argv[0], argv[pi]);
+                               exit(1);
+                       }
+                       ++pi;
+                       struct {
+                               char     kind[64];
+                               uint8_t  mask;
+                               uint16_t addr;
+                               char     name[64];
+                       } trace;
+                       if(4 != sscanf(argv[pi], "%63[^=]=%63[^@]@0x%hx/0x%hhx", &trace.name[0], &trace.kind[0], &trace.addr, &trace.mask)) {
+                               --pi;
+                               fprintf(stderr, "%s: format for %s is name=kind@addr/mask.\n", argv[0], argv[pi]);
+                               exit(1);
+                       }
+
+                       /****/ if(!strcmp(trace.kind, "portpin")) {
+                               f.trace[f.tracecount].kind = AVR_MMCU_TAG_VCD_PORTPIN;
+                       } else if(!strcmp(trace.kind, "irq")) {
+                               f.trace[f.tracecount].kind = AVR_MMCU_TAG_VCD_IRQ;
+                       } else if(!strcmp(trace.kind, "trace")) {
+                               f.trace[f.tracecount].kind = AVR_MMCU_TAG_VCD_TRACE;
+                       } else {
+                               fprintf(stderr, "%s: unknown trace kind '%s', not one of 'portpin', 'irq', or 'trace'.\n", argv[0], trace.kind);
+                               exit(1);
+                       }
+                       f.trace[f.tracecount].mask = trace.mask;
+                       f.trace[f.tracecount].addr = trace.addr;
+                       strncpy(f.trace[f.tracecount].name, trace.name, sizeof(f.trace[f.tracecount].name));
+
+                       printf(
+                               "Adding %s trace on address 0x%04x, mask 0x%02x ('%s')\n",
+                                 f.trace[f.tracecount].kind == AVR_MMCU_TAG_VCD_PORTPIN ? "portpin"
+                               : f.trace[f.tracecount].kind == AVR_MMCU_TAG_VCD_IRQ     ? "irq"
+                               : f.trace[f.tracecount].kind == AVR_MMCU_TAG_VCD_TRACE   ? "trace"
+                               : "unknown",
+                               f.trace[f.tracecount].addr,
+                               f.trace[f.tracecount].mask,
+                               f.trace[f.tracecount].name
+                       );
+
+                       ++f.tracecount;
+               } else if (!strcmp(argv[pi], "--vcd-trace-file")) {
+                       if(pi+1>=argc) {
+                               fprintf(stderr, "%s: missing mandatory argument for %s.\n", argv[0], argv[pi]);
+                               exit(1);
+                       }
+                       strncpy(f.tracename, argv[++pi], sizeof(f.tracename));
                } else if (!strcmp(argv[pi], "-ti")) {
                        if (pi < argc-1)
                                trace_vectors[trace_vectors_count++] = atoi(argv[++pi]);