From: Uwe Hermann Date: Sun, 9 May 2010 19:05:15 +0000 (+0200) Subject: VCD: Optimizations and fixes. X-Git-Tag: libsigrok-0.1.0~505 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=fbe2f7945d70500f6db374956a36d7bb131b09d5;p=libsigrok.git VCD: Optimizations and fixes. --- diff --git a/output/output_gnuplot.c b/output/output_gnuplot.c index d2e16d0e..69a45256 100644 --- a/output/output_gnuplot.c +++ b/output/output_gnuplot.c @@ -175,7 +175,7 @@ static int data(struct output *o, char *data_in, uint64_t length_in, /* The next columns are the values of all channels. */ for (p = 0; p < ctx->num_enabled_probes; p++) { - curbit = (sample & ((uint64_t) (1 << p))) != 0; + curbit = (sample & ((uint64_t) (1 << p))) >> p; c = outbuf + strlen(outbuf); sprintf(c, "%d ", curbit); } diff --git a/output/output_vcd.c b/output/output_vcd.c index a9f794ad..d8ce6ef0 100644 --- a/output/output_vcd.c +++ b/output/output_vcd.c @@ -183,22 +183,20 @@ static int data(struct output *o, char *data_in, uint64_t length_in, for (i = 0; i <= length_in - ctx->unitsize; i += ctx->unitsize) { samplecount++; memcpy(&sample, data_in + i, ctx->unitsize); + if (i == 0) + prevsample = sample; + else + memcpy(&prevsample, data_in + i - 1, ctx->unitsize); + for (p = 0; p < ctx->num_enabled_probes; p++) { - curbit = (sample & ((uint64_t) (1 << p))) != 0; - if (i == 0) { - prevbit = ~curbit; - } else { - memcpy(&prevsample, data_in + i - 1, - ctx->unitsize); - prevbit = - (prevsample & ((uint64_t) (1 << p))) != 0; - } - - /* VCD only contains deltas/changes. */ + curbit = (sample & ((uint64_t) (1 << p))) >> p; + prevbit = (prevsample & ((uint64_t) (1 << p))) >> p; + + /* VCD only contains deltas/changes of signals. */ if (prevbit == curbit) continue; - /* FIXME: Only once per sample? */ + /* Output which signal changed to which value. */ c = outbuf + strlen(outbuf); sprintf(c, "#%" PRIu64 "\n%i%c\n", samplecount, curbit, (char)('!' + p));