Commit 8d56964c56a3269be707316382dd36c11ed9ea2f
authorMichel Pollet <buserror@gmail.com>
Tue, 15 Dec 2009 21:38:43 +0000 (21:38 +0000)
committerMichel Pollet <buserror@gmail.com>
Tue, 15 Dec 2009 21:38:43 +0000 (21:38 +0000)
Traces in multiple of the "period" and use the
correct stamps for value changes.

Signed-off-by: Michel Pollet <buserror@gmail.com>
2 files changed:
simavr/sim/sim_vcd_file.c
simavr/sim/sim_vcd_file.h

index bc1a6d4683805cd646f4e05a26f7a454a2056009..0dcd2e7c7d08b4bad586dab31b7131649723f4e3 100644 (file)
@@ -34,6 +34,7 @@ int avr_vcd_init(struct avr_t * avr, const char * filename, avr_vcd_t * vcd, uin
        memset(vcd, 0, sizeof(avr_vcd_t));
        vcd->avr = avr;
        strncpy(vcd->filename, filename, sizeof(vcd->filename));
+       vcd->period_usec = period;
        vcd->period = avr_usec_to_cycles(vcd->avr, period);
        
        for (int i = 0; i < AVR_VCD_MAX_SIGNALS; i++) {
@@ -84,7 +85,7 @@ static avr_cycle_count_t _avr_vcd_timer(struct avr_t * avr, avr_cycle_count_t wh
                if (s->touched) {
                        if (done == 0) {
                                fprintf(vcd->output, "#%ld\n", 
-                                       avr_cycles_to_usec(vcd->avr, when - vcd->start));
+                                       avr_cycles_to_usec(vcd->avr, when - vcd->start) / vcd->period_usec);
                        }
                        char out[32];
                        fprintf(vcd->output, "%s\n", _avr_vcd_get_signal_text(s, out));
@@ -121,7 +122,7 @@ int avr_vcd_start(avr_vcd_t * vcd)
                perror(vcd->filename);
                return -1;
        }
-       fprintf(vcd->output, "$timescale 1us $end\n");
+       fprintf(vcd->output, "$timescale %dus $end\n", vcd->period_usec);
        fprintf(vcd->output, "$scope module logic $end\n");
 
        for (int i = 0; i < vcd->signal_count; i++) {
index 46f14be594bf82d76dcabf7f7580be7ed7965ad5..b0845f4ce6491efcb21c9dafc61da9c162a8994d 100644 (file)
@@ -54,6 +54,7 @@ typedef struct avr_vcd_t {
        int signal_count;
        avr_vcd_signal_t        signal [AVR_VCD_MAX_SIGNALS];   
        uint64_t period;
+       uint32_t period_usec;
        uint64_t start;
 } avr_vcd_t;