VCD: Optimizations and fixes.

This commit is contained in:
Uwe Hermann 2010-05-09 21:05:15 +02:00
parent 086eac7c7b
commit fbe2f7945d
2 changed files with 11 additions and 13 deletions

View 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. */ /* The next columns are the values of all channels. */
for (p = 0; p < ctx->num_enabled_probes; p++) { 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); c = outbuf + strlen(outbuf);
sprintf(c, "%d ", curbit); sprintf(c, "%d ", curbit);
} }

View 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) { for (i = 0; i <= length_in - ctx->unitsize; i += ctx->unitsize) {
samplecount++; samplecount++;
memcpy(&sample, data_in + i, ctx->unitsize); memcpy(&sample, data_in + i, ctx->unitsize);
for (p = 0; p < ctx->num_enabled_probes; p++) { if (i == 0)
curbit = (sample & ((uint64_t) (1 << p))) != 0; prevsample = sample;
if (i == 0) { else
prevbit = ~curbit; memcpy(&prevsample, data_in + i - 1, ctx->unitsize);
} else {
memcpy(&prevsample, data_in + i - 1,
ctx->unitsize);
prevbit =
(prevsample & ((uint64_t) (1 << p))) != 0;
}
/* VCD only contains deltas/changes. */ for (p = 0; p < ctx->num_enabled_probes; p++) {
curbit = (sample & ((uint64_t) (1 << p))) >> p;
prevbit = (prevsample & ((uint64_t) (1 << p))) >> p;
/* VCD only contains deltas/changes of signals. */
if (prevbit == curbit) if (prevbit == curbit)
continue; continue;
/* FIXME: Only once per sample? */ /* Output which signal changed to which value. */
c = outbuf + strlen(outbuf); c = outbuf + strlen(outbuf);
sprintf(c, "#%" PRIu64 "\n%i%c\n", samplecount, sprintf(c, "#%" PRIu64 "\n%i%c\n", samplecount,
curbit, (char)('!' + p)); curbit, (char)('!' + p));