From: Michel Pollet Date: Tue, 15 Dec 2009 21:38:43 +0000 (+0000) Subject: VCD: Traces now have the correct timestamps X-Git-Tag: v1.0a1~57 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=8d56964c56a3269be707316382dd36c11ed9ea2f;p=sx%2Fsimavr.git VCD: Traces now have the correct timestamps Traces in multiple of the "period" and use the correct stamps for value changes. Signed-off-by: Michel Pollet --- diff --git a/simavr/sim/sim_vcd_file.c b/simavr/sim/sim_vcd_file.c index bc1a6d4..0dcd2e7 100644 --- a/simavr/sim/sim_vcd_file.c +++ b/simavr/sim/sim_vcd_file.c @@ -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++) { diff --git a/simavr/sim/sim_vcd_file.h b/simavr/sim/sim_vcd_file.h index 46f14be..b0845f4 100644 --- a/simavr/sim/sim_vcd_file.h +++ b/simavr/sim/sim_vcd_file.h @@ -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;