summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2013-05-14 08:50:59 +0200
committerClifford Wolf <clifford@clifford.at>2013-05-14 08:50:59 +0200
commitbe8ecd6d1681b6f3b0c43470508473ba3301ce30 (patch)
treefba274baca6916a9953e9dd6932b24d463b66128
parentb56e06d2f518b79481309636c57fa40500d425e8 (diff)
Some improvements in vcdcd.pl
-rwxr-xr-xtests/tools/vcdcd.pl20
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/tools/vcdcd.pl b/tests/tools/vcdcd.pl
index 4875eeeb..93041534 100755
--- a/tests/tools/vcdcd.pl
+++ b/tests/tools/vcdcd.pl
@@ -8,14 +8,21 @@ use Verilog::VCD qw(parse_vcd list_sigs);
$| = 1;
+my $opt_width = 0;
+if ($ARGV[0] eq '-w') {
+ $opt_width = +$ARGV[1];
+ shift @ARGV;
+ shift @ARGV;
+}
+
if ($#ARGV != 1) {
print STDERR "\n";
print STDERR "VCDCD - Value Change Dump Change Dumper\n";
print STDERR "\n";
- print STDERR "Usage: $0 gold.vcd gate.vcd\n";
+ print STDERR "Usage: $0 [-w N] gold.vcd gate.vcd\n";
print STDERR "\n";
print STDERR "Compare a known-good (gold) vcd file with a second (gate) vcd file.\n";
- print STDERR "This is not very efficient -- so use with care with large vcd files.\n";
+ print STDERR "This is not very efficient -- so use with care on large vcd files.\n";
print STDERR "\n";
exit 1;
}
@@ -112,6 +119,8 @@ for my $key (keys %$vcd_gate) {
}
}
+$signal_maxlen = $opt_width if $opt_width > 0;
+
my $diffcount = 0;
my %state_gold;
my %state_gate;
@@ -161,8 +170,11 @@ sub cmp_signal($$)
my @a = split //, $a;
my @b = split //, $b;
- unshift @a, "-" while $#a < $#b;
- unshift @b, "-" while $#b < $#a;
+ my $trail_a = $#a < 0 ? '-' : $a[0] eq '1' ? '0' : $a[0];
+ my $trail_b = $#b < 0 ? '-' : $b[0] eq '1' ? '0' : $b[0];
+
+ unshift @a, $trail_a while $#a < $#b;
+ unshift @b, $trail_b while $#b < $#a;
for (my $i = 0; $i <= $#a; $i++) {
return 0 if $a[$i] ne "x" && $a[$i] ne $b[$i];