44 #define VCD_SKIP_ARRAYS 1
45 #define VCD_INCLUDE_RANGE 0
46 #define VCD_TIMEVAR "dtime"
61 for (scope = root; scope; scope = scope->
next) {
64 if (!strcmp (var->
code, code))
84 for (vc = cs->
changes; vc; vc = vnext) {
99 if (last) last = last->
next;
108 while (root != NULL) {
125 double Min = root ? root->
t : 0;
126 for (cs = root; cs; cs = cs->
next) {
127 if (!cs->done && cs->
t <= Min) {
141 if (!strcmp (vv->code, var->
code))
152 struct vcd_set * vs, * current = NULL;
165 while ((cs = vcd_find_firstset (root)) != NULL) {
168 if (current == NULL || current->
t != cs->
t) {
186 if (current->
t > 0) {
187 fprintf (stderr,
"vcd notice, duplicate value change at t = %g of "
188 "variable `%s'\n", current->
t, vc->
var->
ident);
216 while (scope && scope != vcd->
scopes) {
224 char * txt = (
char *) malloc (strlen (ident) + strlen (scope->
ident) + 2);
225 sprintf (txt,
"%s.%s", scope->
ident, ident);
238 int len = strlen (var->
ident) + 1;
244 #if VCD_INCLUDE_RANGE
245 if (var->
range) len += 32;
247 char * id1, * id2 = (
char *) malloc (len);
252 if (strstr (var->
ident,
"implicit_wait_for"))
256 if (strstr (var->
ident,
"net") == var->
ident) {
257 id1 = strdup (&var->
ident[3]);
259 id1 = strdup (var->
ident);
264 id1 = strdup (var->
ident);
269 id1 = strdup (var->
ident);
272 #if VCD_INCLUDE_RANGE
275 sprintf (id2,
"%s", id1);
276 }
else if (var->
range->
l == -1) {
278 sprintf (id2,
"%s[%d]", id1, var->
range->
h);
279 }
else if (var->
range->
h == -1) {
281 sprintf (id2,
"%s[%d]", id1, var->
range->
l);
284 sprintf (id2,
"%s[%d:%d]", id1, var->
range->
l, var->
range->
h);
287 sprintf (id2,
"%s", id1);
296 ds->
ident = strdup (id2);
309 int i, len = strlen (vv->
value);
315 double val = strtod (vv->
value, NULL);
316 sprintf (txt,
"%+.11e", val);
317 value = strdup (txt);
321 long val = 0, bit, i = strlen (vv->
value) - 1;
322 for (bit = 1; i >= 0; i--, bit <<= 1) {
323 if (vv->
value[i] ==
'1')
325 else if (vv->
value[i] ==
'0')
328 sprintf (txt,
"%+ld", val);
329 value = strdup (txt);
331 }
else if (size == len) {
333 value = strdup (vv->
value);
336 value = (
char *) calloc (1, size + 1);
338 fill = (vv->
value[0] ==
'1') ?
'0' : vv->
value[0];
339 for (i = 0; i < size - len; i++) value[i] = fill;
340 strcpy (&value[i], vv->
value);
353 char * currentval = NULL;
359 for (vs = vcd_sets; vs; vs = vs->
next) {
363 if (!strcmp (vv->
code, var->
code)) {
377 currentval = dv->
value;
386 fprintf (stderr,
"vcd error, variable `%s' has no initial value\n",
393 dv->
value = strdup (currentval);
417 ds->
ident = strdup (name);
421 for (vs = vcd_sets; vs; vs = vs->
next) {
426 sprintf (txt,
"%+.11e", vs->
t * vcd->
t * vcd->
scale);
427 dv->
value = strdup (txt);
443 for (scope = root; scope; scope = scope->
next) {
472 static void vcd_print_sets (
void) {
476 fprintf (stderr,
"--- t => %g\n", vs->
t);
484 static void vcd_dataset_print (
void) {
487 for (ds = dataset_root; ds; ds = ds->
next) {
488 fprintf (stderr,
"\n%s%s => %s\n",
492 fprintf (stderr,
" %s\n", dv->
value);
504 for (changeset = vcd->
changesets; changeset; changeset = changeset->
next) {
506 for (change = changeset->
changes; change; change = change->
next) {
508 if (change->
var == NULL) {
509 fprintf (stderr,
"vcd error, no such variable reference `%s' "
510 "found\n", change->
code);
526 vcd_dataset_print ();
535 for (vs = root; vs; vs = snext) {
539 for (vv = vs->
vardefs; vv; vv = vnext) {
565 for (vs = root; vs; vs = snext) {
568 for (vv = vs->
variables; vv; vv = vnext) {
579 for (ds = root; ds; ds = snext) {
584 for (dv = ds->
values; dv; dv = dnext) {
static void vcd_prepare_datasets(void)
static char * vcd_create_value(struct vcd_variable *vv, int size)
struct vcd_scope * scopes
struct vcd_scope * scopes
static void vcd_free_dataset(struct dataset_variable *root)
static struct dataset_variable * vcd_create_dataset(struct vcd_vardef *var)
static struct vcd_variable * vcd_find_variable(struct vcd_variable *root, struct vcd_vardef *var)
struct vcd_set * vcd_sets
static void vcd_free_scope(struct vcd_scope *root)
enum dataset_vartypes type
struct dataset_value * next
struct vcd_changeset * changesets
struct vcd_variable * next
static void vcd_free_changeset(struct vcd_changeset *cs)
static void vcd_prepare_variable_datasets(struct vcd_scope *root)
struct dataset_value * values
static void vcd_free_set(struct vcd_set *root)
struct dataset_variable * next
static struct vcd_vardef * vcd_find_code(struct vcd_scope *root, char *code)
struct dataset_variable * dataset_root
struct vcd_variable * variables
static void vcd_free_change(struct vcd_change *vc)
static void vcd_free_file(struct vcd_file *vcd)
static struct dataset_variable * vcd_create_variable(struct vcd_vardef *var)
struct vcd_scope * parent
struct vcd_changeset * next
static char * vcd_prepend_scopes(struct vcd_vardef *var, char *ident)
static struct vcd_changeset * vcd_find_firstset_fast(struct vcd_changeset *root)
struct vcd_vardef * vardefs
static struct dataset_variable * vcd_create_indep(const char *name)
static void vcd_sort_changesets(struct vcd_changeset *root)
static struct vcd_changeset * vcd_reverse_changesets(struct vcd_changeset *root)
struct vcd_change * changes