r5825 - trunk/gta02-core/bom

werner at docs.openmoko.org werner at docs.openmoko.org
Sun Feb 7 11:11:07 CET 2010


Author: werner
Date: 2010-02-07 11:11:07 +0100 (Sun, 07 Feb 2010)
New Revision: 5825

Modified:
   trunk/gta02-core/bom/Makefile
   trunk/gta02-core/bom/annotate
   trunk/gta02-core/bom/parser.pl
Log:
More work on annotations. Getting better.

- bom/parser.pl: schematics end with $EndSCHEMATC, not $EndSCHEMATIC
- bom/Makefile: annotated pmu.sch is now pmu-bom.sch instead of try.sch
- bom/Makefile: generate framework for invoking eeschema and new target "sch"
- bom/Makefile: annotate all sheets (in progress)
- bom/annotate: mark blocks with a diagonal, to verify coordinate translation
  (for debugging)
- bom/annotate: apply transformation matrix to field coordinates, relative to
  component origin



Modified: trunk/gta02-core/bom/Makefile
===================================================================
--- trunk/gta02-core/bom/Makefile	2010-02-07 08:27:45 UTC (rev 5824)
+++ trunk/gta02-core/bom/Makefile	2010-02-07 10:11:07 UTC (rev 5825)
@@ -5,6 +5,7 @@
 EQU=fic/fic.equ fic/missing.equ digi-key.equ
 INV=fic/fic.inv gta02-core.inv dummy.inv fic/missing.inv digi-key.inv
 CHR=darfon.chr ralec.chr avx.chr acx.chr misc.chr
+SCH=audio bt cpu-power cpu gps io lcm memory modem pmu sd-sim usb wlan
 
 .PHONY:		all spotless upload show-dup show-missing show-dk
 # mark them as phony since we have incomplete dependencies in this Makefile
@@ -56,6 +57,7 @@
 spotless:
 		$(MAKE) -C fic spotless
 		rm -f gta02-core.par gta02-core.ord darfon.chr ralec.chr
+		rm -f gta02-core-bom.pro gta02-core-bom.sch $(SCH:%=%-bom.sch)
 
 show-dup:	pardup.pl gta02-core.par
 		perl ./pardup.pl gta02-core.par
@@ -72,4 +74,22 @@
 
 ann:		annotate ../pmu.sch fic/fic.dsc gta02-core.par $(EQU)
 		perl ./annotate ../pmu.sch fic/fic.dsc gta02-core.par $(EQU) \
-		  >try.sch
+		  >pmu-bom.sch || { rm -f pmu-bom.sch; exit 1; }
+
+$(SCH:%=%-bom.sch): \
+		annotate $(SCH:%=../%.sch) fic/fic.dsc gta02-core.par $(EQU)
+		for n in $(SCH); do \
+		    perl ./annotate ../$$n.sch fic/fic.dsc gta02-core.par \
+		      $(EQU) >$$n-bom.sch || { rm -f $$n-bom.sch; exit 1; }; \
+		done
+
+gta02-core-bom.pro:	../gta02-core.pro
+		sed 's|\./|../|' <../gta02-core.pro >$@ || \
+		  { rm -f $@; exit 1; }
+
+gta02-core-bom.sch:	../gta02-core.sch
+		sed 's/\.sch"/-bom.sch"/' <$< >$@ || \
+		  { rm -f $@; exit 1; }
+
+sch:		gta02-core-bom.pro gta02-core-bom.sch #$(SCH:%=%-bom.sch)
+		eeschema `pwd`/gta02-core-bom.sch

Modified: trunk/gta02-core/bom/annotate
===================================================================
--- trunk/gta02-core/bom/annotate	2010-02-07 08:27:45 UTC (rev 5824)
+++ trunk/gta02-core/bom/annotate	2010-02-07 10:11:07 UTC (rev 5825)
@@ -23,9 +23,25 @@
 }
 
 
+#
+# 2x2 matrix inversion
+# http://en.wikipedia.org/wiki/Invertible_matrix#Inversion_of_2.C3.972_matrices
+#
+
+sub invert
+{
+    my @m = @_;
+    my $f = $_[0]*$_[3]-$_[1]*$_[2];
+    return ($f*$_[3], -$f*$_[1], -$f*$_[2], $f*$_[0]);
+}
+
+
 sub block
 {
-    push(@block, [ &normalize(@_) ]);
+    my @t = &normalize(@_);
+    push(@block, [ @t ]);
+#    push(@block, [ &normalize(@_) ]);
+$wnl .= "Wire Notes Line\n\t$t[0] $t[1] $t[2] $t[3]\n";
 }
 
 
@@ -47,7 +63,7 @@
 
 sub put
 {
-    local ($x0, $y0, $rot, @s) = @_;
+    local ($x0, $y0, $ref, @s) = @_;
 
     my $h = @s*$H;
     my $w = 0;
@@ -68,10 +84,15 @@
     }
     warn "no place found for \"$s[0]\"" if $i == 128;
 
-    &block($x, $y, $w, $h);
+    my @m = &invert( @{ $m{$ref} });
+    my $dx = $x-$x0;
+    my $dy = $y-$y0;
+    my $sx = $x0+$dx*$m[0]+$dy*$m[1];
+    my $sy = $y0+$dx*$m[2]+$dy*$m[3]; #-$H/2;
+    &block($sx, $sy, $w, $h);
     my $n = 10;
     for (reverse @s) {
-	my $hv = $rot ? "V" : "H";
+	my $hv = $rot{$ref} ? "V" : "H";
 	print "F $n \"$_\" $hv $x $y $H  0000 L CNN\n";
 	$y += $L;
 	$n++;
@@ -86,7 +107,11 @@
 for (@eeschema) {
     $ref = $1 if /^L \S+ (\S+)/;
     undef $ref if /^\$EndComp/;
-    $rot{$ref} = 1 if /^\s+0\s+1\s+1\s+0\s*$/ || /^\s+0\s+-1\s+-1\s+0\s*$/;
+    next unless /^\s+(-?[01])\s+(-?[01])\s+(-?[01])\s+(-?[01])\s*$/;
+    my @m = split(/\s+/);
+    shift @m;
+    $m{$ref} = [ @m ];
+    $rot{$ref} = 1 if !$m[0];
 }
 
 
@@ -95,19 +120,24 @@
 #
 
 for (@eeschema) {
-    my $ref = $1 if /^L \S+ (\S+)/;
+    $ref = $1 if /^L \S+ (\S+)/;
+    if (/^P (\d+) (\d+)/) {
+	$x0 = $1;
+	$y0 = $2;
+    }
     next unless /^F /;
     die "$_" unless
-      /^F \d+ "([^"]*)" ([HV]) (\d+) (\d+) (\d+) +(\d+) ([LC]) C/;
+      /^F \d+ "([^"]*)" ([HV]) (\d+) (\d+) (\d+) +(\d+) ([LC]) (C)/;
     ($s, $hv, $x, $y, $size, $flag, $hj, $vj) =
       ($1, $2, $3, $4, $5, $6, $7, $8);
+    $dx = $x-$x0;
+    $dy = $y-$y0;
+    $x = $x0+$dx*$m{$ref}[0]+$dy*$m{$ref}[1];
+    $y = $y0+$dx*$m{$ref}[2]+$dy*$m{$ref}[3];
     next if $flag != 0;
     $w = $size*0.8*length $s;
-    if ($hv eq "H") {
-	&block($hj eq "L" ? $x : $x-$w/2, $y-$size/2, $w, $size);
-    } else {
-	&block($x-$size/2, $hj eq "L" ? $y : $y-$w/2, $size, $w);
-    }
+    # we don't need to consider H/V
+    &block($hj eq "L" ? $x : $x-$w/2, $y-$size/2, $w, $size);
 }
 
 #
@@ -142,7 +172,10 @@
 	    $seen{$_} = 1;
 	}
 	undef @f;
-	&put($x, $y, $rot{$ref}, @u) if !$rot{$ref};
+	&put($x, $y, $ref, @u);
     }
+    if (/\$EndSCHEMATC/) {
+	print $wnl;
+    }
     print "$_\n";
 }

Modified: trunk/gta02-core/bom/parser.pl
===================================================================
--- trunk/gta02-core/bom/parser.pl	2010-02-07 08:27:45 UTC (rev 5824)
+++ trunk/gta02-core/bom/parser.pl	2010-02-07 10:11:07 UTC (rev 5825)
@@ -318,7 +318,7 @@
 sub eeschema
 {
     push(@eeschema, $_[0]);
-    if ($_[0] =~ /^\$EndSCHEMATIC/) {
+    if ($_[0] =~ /^\$EndSCHEMATC/) {
 	$mode = *skip;
 	undef $raw;
     }




More information about the commitlog mailing list