chiark / gitweb /
correct reverser object specification and improve related comments
authorian <ian>
Mon, 19 Jun 2006 16:16:38 +0000 (16:16 +0000)
committerian <ian>
Mon, 19 Jun 2006 16:16:38 +0000 (16:16 +0000)
detpic/reverse.asm
layout/data2safety
layout/layout-data.h

index 725edfc4908ab077e5cc033fc3db3ed5a40638dc..ea1e3ab5b68b4330465aa9faf384777245dd450b 100644 (file)
@@ -40,6 +40,7 @@ polarity_local_do @
 ;  LATA,LATE   any                                     modified appropriately
 ;  all others  any                                     preserved
 ;
+;       ( bit-in-byte letters in command_polarity:   Nf Ne  Nd Nc Nb Na )
 ;      on entry:               ; W =           PP PP v3 v0  v2 v1 v5 v4
 ;
 ; where        PP bits are those specifying that this is a polarity message
@@ -113,7 +114,7 @@ command_polarity @
 ;      zz      bit zero
 ;      other things are <board><segment> where <segment>
 ;              is a for LSb in message to PIC, b for next bit,
-;              and so on until f for bit 5.  (See polarity_do_here, below.)
+;              and so on until f for bit 5.  (See polarity_local_do, above.)
 ;
 ; we accumulate (`gather') the `g' bits in t.
        mov_lfsr polarity_cmds, 1
index 13cd0f0ddb9ffbf56d083783e8586043fc23f1f6..0d4cbaeea889a1c0779d2cb16a98cc26c1090c51 100755 (executable)
@@ -30,16 +30,15 @@ our (%nodes);
 
 our ($maxptixln2) = 5;
 
-our ($nextboardnum,@boardtype,%numboards,$nreverses,@sensesin,@sensesbase);
-our (@objkinds,%pin_used);
-# @boardtype[$boardnum]
-# $numboards{$type}
-# $nreverses
+our ($nextboardnum,@boardtype,@sensesin,$maxreverseobjnum);
+our (@reversersboardnum,@sensesbase,@objkinds,%pin_used);
+# $boardtype[$boardnum]
 # $sensesin[$page]
+# $maxreverseobjnum
+# $reversersboardnum[$boardnum]  # undef => none; -1 => not yet determined
 # $sensesbase[$boardnum]= ($page << 7) | $baselsbyte
-# %pin_used{$objkind}[$objnum] = [ $boardnum, $pin_info, $objonboard ]
+# $pin_used{$objkind}[$objnum] = [ $boardnum, $pin_info, $objonboard ]
 $nextboardnum= 0;
-$nreverses= 0;
 $sensesin[0]= 0;
 @objkinds= qw(pt sense reverse);
 
@@ -104,13 +103,15 @@ sub line_segment () {
     m/^\s+(\w+)\s+(\d+\.\d+)$/ or return syntaxerror();
     ($seg,$boob)=($1,$2);
     mistake("duplicate topology for $seg") if exists $segs{$seg};
+    $boob= pa_boob($boob);
     $segs{$seg}= {
-       BoOb => pa_boob($boob),
+       BoOb => $boob,
        Inv => $invertible,
        Posns => 1,
        Feats => { },
        FeatCount => 0
     };
+    &{"line_segment_".($invertible?'invertible':'vanilla')}($boob);
 }
 
 sub begin_endwiring () {
@@ -127,7 +128,6 @@ sub line_boards () {
 
     $nextboardnum++;
     $boardtype[$num]= $type;
-    $numboards{$type}++;
     require "./$type.pin-info";
 
     my ($sense_count, $page);
@@ -146,16 +146,13 @@ sub line_boards () {
     &{"line_boards_$type"}($num);
 }
 
-sub line_boards_reversers {
-    my ($num) = @_;
-    my ($i,$objnum);
-    for ($i=0; $i<6; $i++) {
-       $objnum= boob2objnum($num,$i,'reverse',0);
-       fixme nreverses seems unused
-       $nreverses= $objnum+1 if $objnum >= $nreverses;
-    }
-}
+sub line_boards_reversers { }
 sub line_boards_detectors { }
+sub line_segment_vanilla ($) { }
+sub line_segment_invertible ($) {
+    my ($boob) = @_;
+    $reversersboardnum[$boob->[0]]= -1;
+}
 
 sub mistake ($) {
     my ($m) = @_;
@@ -248,9 +245,7 @@ sub boob2objnum_pt {
 }
 
 sub boob2objnum_reverse {
-    my ($boardnum,$obj,$boardtype)=@_;
-fixme need to map board num for reversers to 
-
+    my ($orgboardnum,$obj,$boardtype)=@_;
     # Converts board and object number (in canonical pic number plus
     # and reverse0...reverse5 as seen on pinout diagrams), to the
     # segment number for POLARITY command numbered as shown in
@@ -260,34 +255,46 @@ fixme need to map board num for reversers to
     #
     #  * We invert the on-board mapping; ie, we untangle the
     #    tangling between the message from master to slave pic
-    #    and the actual pins (see reverse.asm, polarity_do_here)
+    #    and the actual pins (see reverse.asm, polarity_local_do)
     #
     #  * We figure out which bit of which message byte the
-    #    object corresponds to.  (see reverse.asm, polarity_decode_message)
+    #    object corresponds to.  (see reverse.asm, command_polarity)
     #
     #  * We compute the README.protocol segment number.
     
-    my ($cycle,$boardincycle,$cyclebasebyte,$byte,$bit);
+    my ($cycle,$boardincycle,$cyclebasebyte,$byte,$bit,$boardnum,$rv);
+    $boardnum= $reversersboardnum[$orgboardnum];
+    die "$orgboardnum $boardnum" unless defined $boardnum;
+    die "$orgboardnum $boardnum" unless $boardnum >= 0;
     die unless $boardtype eq 'reversers';
     die $obj if $obj > 5;
+#print STDERR "data2safety $boardnum.$obj ";
     $obj = sprintf '%d', $obj;
     $obj =~ y/302154/543210/; # mapping due to polarity_do_here
+#print STDERR " obj=$obj";
     $cycle= int(($boardnum+3) / 7);
+#print STDERR " cycle=$cycle";
     $boardincycle= ($boardnum+3) - $cycle*7;
+#print STDERR " boardin=$boardincycle";
     $cyclebasebyte= $cycle*6 - 2;
+#print STDERR " baseby=$cyclebasebyte";
     if ($boardnum==2 && $obj > 2) {
        $byte= 0; $bit= $obj-3;
-       return 3 - $bit; # only these three in byte 0, a special case
+       $rv= 3 - $bit; # only these three in byte 0, a special case;
+#print STDERR " special bit=$bit => $rv\n";
+       return $rv;
     } elsif ($boardincycle<5) {
-       $byte= $cyclebasebyte + $boardincycle; $bit= $obj;
+       $byte= $cyclebasebyte + $boardincycle; $bit= $obj + 1;
     } elsif ($boardincycle==6) {
-       $byte= $cyclebasebyte + 5; $bit= $obj;
+       $byte= $cyclebasebyte + 5; $bit= $obj + 1;
     } elsif ($boardincycle==5) {
-       $byte= $cyclebasebyte + 5 - $bit; $bit= 6;
+       $byte= $cyclebasebyte + 5 - $bit; $bit= 0;
     } else {
        die;
     }
-    return $byte*7 + 3 - $bit;
+    $rv= $byte*7 + 3 - $bit;
+#print STDERR " ordinary byte=$byte bit=$bit => $rv\n";
+    return $rv;
 }
 
 sub boob2objnum_sense {
@@ -365,9 +372,19 @@ sub mainread () {
 }
 
 sub redaction () {
+    my ($num,$mappednum,$i,$objnum);
+    $maxreverseobjnum= 0;
     for ($num=0, $mappednum=0; $num<@boardtype; $num++) {
-       next if $boardtype[$num] eq 'detectors';
-       
+       next unless defined $reversersboardnum[$num];
+       die if $reversersboardnum[$num] != -1;
+       $reversersboardnum[$num]= $mappednum;
+       for ($i=0; $i<6; $i++) {
+           $objnum= boob2objnum($mappednum,$i,'reverse',0);
+           $maxreverseobjnum= $objnum+1 if $objnum >= $maxreverseobjnum;
+       }
+       $mappednum++;
+    }
+}    
 
 sub nummap ($) {
     my ($p) = @_;
@@ -474,6 +491,7 @@ sub writeout () {
        $delim= ',';
     }
     o("\n};\n");
+    o("const BoardObject info_maxreverse=$maxreverseobjnum;\n");
 }
 
 # writeasm_KIND()
index 84391c7b213026a1bd9aba351e0c16fd3b21cd16..145eaf0a69df1380a2a9bfb1d13e7eb6bb47f9e8 100644 (file)
@@ -74,12 +74,12 @@ typedef struct {
  */
 
 extern const SegmentNum info_nsegments;
-extern const SegmentInfo info_segments[]; 
+extern const SegmentInfo info_segments[];
 
 extern const TrainNum info_nsegments;
 extern const TrainInfo info_trains[];
 
-extern const BoardObject info_nreverses; /* max. reverse + 1 */
+extern const BoardObject info_maxreverse; /* max. reverse + 1 */
 
 #define NOTA(x) (~(x##Num)0)