]> sigrok.org Git - libsigrok.git/commitdiff
VCD: Optimizations and fixes.
authorUwe Hermann <redacted>
Sun, 9 May 2010 19:05:15 +0000 (21:05 +0200)
committerUwe Hermann <redacted>
Sun, 9 May 2010 20:06:30 +0000 (22:06 +0200)
output/output_gnuplot.c
output/output_vcd.c

index d2e16d0ed81737ac1894460bc8bc55d7266f5207..69a45256c432b4eb3b0bd2891e24a8134e843bd4 100644 (file)
@@ -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);
                }
index a9f794ad9762dbf70599d69cf2a24ab746330128..d8ce6ef063e9ad53eb068916d8505c9d5f8d0705 100644 (file)
@@ -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));