anl.pl 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/perl
  2. #
  3. # anl.pl - Generate "abstract" netlist
  4. #
  5. # This generates one line per net, containing all pins connecting to this
  6. # net. Each pin is identified as <value>.<pin> so that this list is stable
  7. # when re-annotating schematics. (However, it is ambiguous.)
  8. #
  9. # Each net line is sorted alphabetically and nets are also sorted.
  10. #
  11. # The purpose of this script is to make it possible to compare netlists before
  12. # and after major refactoring of the schematics.
  13. #
  14. sub flush
  15. {
  16. push(@nets, join(" ", sort({ $a cmp $b } @net)));
  17. undef @net;
  18. }
  19. while (<>) {
  20. if (/\(comp\s+\(ref\s+(\S+?)\)/) {
  21. $comp = $1;
  22. next;
  23. }
  24. if (/\(value\s+"([^"]+)"/) {
  25. $c{$comp} = $1 if defined $comp;
  26. next;
  27. }
  28. if (/\(value\s+(\S+?)\)/) {
  29. $c{$comp} = $1 if defined $comp;
  30. next;
  31. }
  32. if (/\(net\s/) {
  33. &flush unless $#net == -1;
  34. next;
  35. }
  36. if (/\(node\s+\(ref\s+(\S+?)\)\s+\(pin\s+(\S+?)\)/) {
  37. die "unknown component \"$1\"" unless defined $c{$1};
  38. push(@net, "$c{$1}.$2");
  39. }
  40. }
  41. &flush;
  42. print join("\n", sort({ $a cmp $b } @nets)), "\n";