chiark / gitweb /
pcb/points-pin-alloc: use actual INDIV0 etc. pin info and net info
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 4 Dec 2010 18:29:24 +0000 (18:29 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 4 Dec 2010 18:29:30 +0000 (18:29 +0000)
pcb/points-pin-alloc-gen
pcb/points-pin-alloc.setup

index ac574be18aa987b31d344206f6f8e503c60a88a9..d1ecc34016ab8530e6aa61201191e85687d1a245 100755 (executable)
@@ -5,24 +5,25 @@ use strict qw(refs vars);
 use POSIX;
 use IO::Handle;
 
-our @boards;
-foreach (@ARGV) {
-    m/^(\w+)\:(\d+)$/ or die "$_ ?";
-    foreach (my $i=0; $i<$2; $i++) { push @boards, $1; }
-}
-
-our @pins;
 our @pin2otherdesc;
 while (<DATA>) {
     m/^(\d+)\t(\S.*\S)\s+/ or die;
-    push @pins, $1;
     $pin2otherdesc[$1]= $2;
 }
 
+our @boards;
+foreach (@ARGV) {
+    m/^(\w+)\:(\d+)$/ or die "$_ ?";
+    foreach (my $i=0; $i<$2; $i++) { push @boards, $1; }
+}
+
 our %boardpin2point;
+our %boardpin2indiv;
+our @pinboard2other;
 foreach my $board (0..$#boards) {
     my $bkind= $boards[$board];
     next if exists $boardpin2point{$bkind};
+
     open NI, "$bkind.net-info" or die "$bkind $!";
     while (<NI>) {
        next if m/^\#/;
@@ -32,14 +33,24 @@ foreach my $board (0..$#boards) {
        my ($netname, $type, $pins) = m/^(\w+)\s+(\w+)\s+(\S.*)?$/
            or die "$_ ?";
        next unless defined $pins;
+
        $pins= " $pins ";
        $pins =~ m/\sPIC-(\d+)\s/ or next;
        my $pin= $1;
+
+       my $indivpin;
+       $indivpin=$1 if $pins =~ m/\sINDIV0-(\d+)\s/;
+
        $netname= "__${netname}__";
-       $netname =~ m/__pt(\d+)__/ or next;
+       $netname =~ s/__pt(\d+)__/__/ or next;
        my $point= $1;
-       die "$netname $pin" unless defined $pin2otherdesc[$pin];
+
+       $netname =~ s/^__//;
+       $netname =~ s/__$//;
+       $netname =~ s,__,/,g;
        $boardpin2point{$bkind}[$pin]= $point;
+       $boardpin2indiv{$bkind}[$pin]= $indivpin;
+       $pinboard2other[$pin]{$bkind}= $netname;
     }
     NI->error and die "$bkind $!";
     close NI;
@@ -98,16 +109,41 @@ foreach my $board (0..$#boards) {
 cell('', '@B pin');
 endrow();
 
-foreach my $pin (@pins) {
+our @outrows;
+foreach my $pin (0..$#pinboard2other) {
+    my $netnames= $pinboard2other[$pin];
+    next unless $netnames;
+    my %netnames;
+    $netnames{$_}=1 foreach grep { /\S/ && !m/^icsp_/ } values %$netnames;
+    $netnames= join '/', sort keys %netnames;
+    push @outrows, { Pin => $pin, Others => $netnames,
+                Priority =>
+                    ($netnames !~ /\S/ ? -10 :
+                     -($netnames =~ m/spare/g))
+                };
+}
+
+foreach my $outrow (sort { $a->{Priority} <=> $b->{Priority}
+                          || $a->{Others} cmp $b->{Others}
+                          || $a->{Pin} <=> $b->{Pin}
+                      } @outrows) {
+    my $pin= $outrow->{Pin};
+    my $netnames= $outrow->{Others};
     startrow();
     cell('indent { right }', $pin);
-    cell('', "\"$pin2otherdesc[$pin]\"");
+    my $desc= $pin2otherdesc[$pin];
+    my $cell= "{Courier Base} \@Font \"$netnames\"";
+    $cell .= "//1fx \"$desc\"" if $netnames =~ /\S/ && defined $desc;
+    cell('margin { 0.1f }', "10p \@Font {$cell}");
     foreach my $board (0..$#boards) {
-       my $point= $boardpin2point{$boards[$board]}[$pin];
+       my $bkind= $boards[$board];
+       my $point= $boardpin2point{$bkind}[$pin];
+       my $indivpin= $boardpin2indiv{$bkind}[$pin];
+       my $rhs= defined($indivpin) ? "I.$indivpin" : '"*"';
        if (!defined $point) {
            cell('paint { lightgrey }', '');
        } else {
-           cell('marginhorizontal { 0.1f }', "10p \@Font PT$point");
+           cell('margin { 0.1f }', "10p \@Font { PT$point //1vx $rhs }");
        }
     }
     cell('indent { right }', $pin);
@@ -120,7 +156,7 @@ chomp($revid) or die $?;
 $revid =~ s/[\"\\]/\\$&/g;
 
 print <<END;
-//3vx
+//1vx
 10p \@Font "$revid"
 \@End \@Text
 END
@@ -138,9 +174,9 @@ __DATA__
 34     External Interrupt 1
 33     External Interrupt 0
 30     ECCP1 PWM output D
-29     ECCP1 PWN output C
-28     ECCP1 PWN output B
-27     ECCP1 PWN output A
+29     ECCP1 PWM output C
+28     ECCP1 PWM output B
+27     ECCP1 PWM output A
 26     RS232 RX
 25     RS232 TX
 22     Comparator 2 input
index f382b75398e89f1419bb2a891016d5a013970feb..17a4d2a71fafb7bca40cc1a1c62229dc4ce5739a 100644 (file)
@@ -85,8 +85,8 @@
   # @PageHeight                { 66f                   } # page height if type Other
     @PageOrientation   { Landscape             } # Portrait, Landscape, etc.
   # @PageBackground    {                       } # background of each page
-  # @TopMargin         { 2.5c  @OrIfPlain 6f   } # top margin of all pages
-  # @FootMargin                { 2.5c  @OrIfPlain 6f   } # bottom margin of all pages
+    @TopMargin         { 0.7c                  } # top margin of all pages
+    @FootMargin                { 0.7c                  } # bottom margin of all pages
     @OddLeftMargin     { 1c                    } # left margin of odd pages
     @OddRightMargin    { 1c                    } # right margin of odd pages
     @EvenLeftMargin    { 1c                    } # left margin of even pages