summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-11-14 01:10:33 -0300
committerGenerated from internal repo <nobody@neo900.org>2016-11-14 01:10:33 -0300
commit8e3d4ef910c831d13ff520024ae87bc596c15e7b (patch)
treebe124c6b1f15babc35502992948ae16f7a6ddb77 /scripts
parentfe7e45fb89d5f35882db2cd8a2a3f266f7ccda13 (diff)
downloadee-8e3d4ef910c831d13ff520024ae87bc596c15e7b.tar.gz
ee-8e3d4ef910c831d13ff520024ae87bc596c15e7b.tar.bz2
ee-8e3d4ef910c831d13ff520024ae87bc596c15e7b.zip
scripts/anl.pl: generate "abstract" netlist
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/anl.pl46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/anl.pl b/scripts/anl.pl
new file mode 100755
index 0000000..0e3b57b
--- /dev/null
+++ b/scripts/anl.pl
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+#
+# anl.pl - Generate "abstract" netlist
+#
+# This generates one line per net, containing all pins connecting to this
+# net. Each pin is identified as <value>.<pin> so that this list is stable
+# when re-annotating schematics. (However, it is ambiguous.)
+#
+# Each net line is sorted alphabetically and nets are also sorted.
+#
+# The purpose of this script is to make it possible to compare netlists before
+# and after major refactoring of the schematics.
+#
+
+sub flush
+{
+ push(@nets, join(" ", sort({ $a cmp $b } @net)));
+ undef @net;
+}
+
+
+while (<>) {
+ if (/\(comp\s+\(ref\s+(\S+?)\)/) {
+ $comp = $1;
+ next;
+ }
+ if (/\(value\s+"([^"]+)"/) {
+ $c{$comp} = $1 if defined $comp;
+ next;
+ }
+ if (/\(value\s+(\S+?)\)/) {
+ $c{$comp} = $1 if defined $comp;
+ next;
+ }
+ if (/\(net\s/) {
+ &flush unless $#net == -1;
+ next;
+ }
+ if (/\(node\s+\(ref\s+(\S+?)\)\s+\(pin\s+(\S+?)\)/) {
+ die "unknown component \"$1\"" unless defined $c{$1};
+ push(@net, "$c{$1}.$2");
+ }
+}
+&flush;
+
+print join("\n", sort({ $a cmp $b } @nets)), "\n";