fix changed highlight, aligments of output
[x300-pci] / openocd-jtag-boundary-scan.pl
index c44a386..bd7518b 100755 (executable)
@@ -13,8 +13,10 @@ my $bsdl_file = $ENV{BSDL} ||
 #      '_3128at100.bsd';
 #      '3064at44.bsd'; # XXX 
 my $tap = $ENV{TAP} || 'tb276.tap';
+my $project_file = 'Altera/epm3064_dac/3064at44.qsf';
+$project_file = 'tb276/f32c.qsf';
 
-my $BOUNDARY_LENGTH = 288;
+my $BOUNDARY_LENGTH = -1;
 my $entity;
 
 my $bit2pin;
@@ -91,12 +93,11 @@ store \$pin2io, $entity . '.pin2io.storable';
 
 my $opcode;
 my $o = $parse->{INSTRUCTION_OPCODE} || die "no INSTRUCTION_OPCODE in ",dump($parse);
-warn "XXX [$o]";
 
 foreach ( split(/\)\s*,\s*/, $o) ) {
        s/\s+\(/ /g;
        s/\s*\)\s*$//g;
-       warn "XXX [$_]\n";
+       warn "### [$_]\n";
        my ( $inst_opcode, $bin ) = split(/\s+/, $_);
        $opcode->{$inst_opcode} = sprintf "0x%02x", eval '0b' . $bin;
 }
@@ -120,10 +121,10 @@ foreach my $pin_file ( glob "pins/$entity*.tsv" ) {
 }
 
 {
-       my $pin_file = 'Altera/epm3064_dac/3064at44.qsf';
-       open(my $fh, '<', $pin_file);
+       open(my $fh, '<', $project_file);
        while(<$fh>) {
                chomp;
+               s/[\r\n]+$//;
                my ($set,$pin, $op, $desc) = split(/\s+/,$_,4);
                if ( $set =~ m/set_location_assignment/i && $op =~ m/-to/i && $pin =~ s/^PIN_//ig ) {
                        $pin_desc->{$pin} = $desc; # overwrite pin description
@@ -132,7 +133,7 @@ foreach my $pin_file ( glob "pins/$entity*.tsv" ) {
                }
        }
        close($fh);
-       warn "# $pin_file ",dump($pin_desc);
+       warn "# $project_file ",dump($pin_desc);
 }
 
 =for remove
@@ -158,8 +159,9 @@ sub print_io {
        my $bits = shift;
        my $o_bits = $bits;
        $bits = reverse $bits; # make substr work as expected
+       my $last_bits_r = reverse $last_bits;
 
-       print "pin off io___ ICO prv | " x 4, $openocd_remote,"\n";
+       print "pin off io___ ICO          | " x 4, $openocd_remote,"\n";
        foreach my $i ( 0 .. ($#$pin2io/4)-1 ) {
                foreach my $j ( 0 .. 3 ) {
                        #my $pin = ($i*4) + $j + 1; # rows
@@ -169,7 +171,7 @@ sub print_io {
 
                        if ( defined $o ) {
                                my $l = $b = substr($bits, $o, 3);
-                               $l = substr($last_bits,$o,3) if $last_bits;
+                               $l = substr($last_bits_r,$o,3) if $last_bits;
 
                                my $desc = $pin_desc->{$pin} || '';
                                my $bits = bits($b);
@@ -184,7 +186,7 @@ sub print_io {
 
                                printf "%-3d %-3d %-5s %3s %-8s | ", $pin, $o, $io, $bits, $desc;
                        } else {
-                               printf "%-3d ... %-5s %3s %-8s | ", $pin, $io, '', '';
+                               printf "%-3d ... %-18s | ", $pin, $io, '', '';
                        }
                }
                print "\n";
@@ -297,7 +299,7 @@ warn "XXX",length($old_bsr), " == ",length($b);
 
        $b = reverse $b;
 
-       diff_bits( $BSR, $b ), $/;
+       diff_bits( $BSR, $b );
 
 #      print $sock "irscan $tap $opcode->{SAMPLE}\n"; # SAMPLE/PRELOAD
        print $sock "drscan $tap $BOUNDARY_LENGTH 0x", bin2hex($b), "\n";