r5800 - trunk/gta02-core/bom

werner at docs.openmoko.org werner at docs.openmoko.org
Thu Jan 28 09:25:09 CET 2010


Author: werner
Date: 2010-01-28 09:25:08 +0100 (Thu, 28 Jan 2010)
New Revision: 5800

Modified:
   trunk/gta02-core/bom/README
   trunk/gta02-core/bom/parser.pl
   trunk/gta02-core/bom/workflow.fig
Log:
Adding infrastructure for characteristics matching.



Modified: trunk/gta02-core/bom/README
===================================================================
--- trunk/gta02-core/bom/README	2010-01-26 22:11:00 UTC (rev 5799)
+++ trunk/gta02-core/bom/README	2010-01-28 08:25:08 UTC (rev 5800)
@@ -1,6 +1,50 @@
 ...
+- namespace
+- equivalences
+- ID matching
+- characteristics matching
+- inventory
 
 
+Part characteristics (.chr)
+---------------------------
+
+A part characteristics file lists the parameters of components.
+This information is then matched with the parameters specified in
+the schematics.
+
+The part characteristics file begins with a line containing only
+#CHR
+
+After this, each line contains the manufacturer (namespace), the
+part number, and a list of parameter=value entries. Fields are
+separated by spaces.
+
+Long lines can be wrapped by indenting the continuation lines.
+
+Blank lines and comments (#) are ignored.
+
+
+Substitutions (.sub)
+--------------------
+
+A substitutions file specifies rules for translating component
+parameters in schematics to part characteristics.
+
+matches -> actions !
+
+matches -> actions {
+    ...
+}
+
+(...) -> $n or ${n}
+$u -> canonicalize unit
+REF
+FP
+F1
+...
+
+
 Parts list (.par)
 ------------------
 

Modified: trunk/gta02-core/bom/parser.pl
===================================================================
--- trunk/gta02-core/bom/parser.pl	2010-01-26 22:11:00 UTC (rev 5799)
+++ trunk/gta02-core/bom/parser.pl	2010-01-28 08:25:08 UTC (rev 5800)
@@ -107,6 +107,115 @@
 }
 
 
+#
+# "chr" populates the following global variable:
+#
+# $chr{"namespace item-number"}{parameter} = value
+#
+# $last is used internally for continuation lines.
+#
+
+sub chr
+{
+    if (/^\s+/) {
+	my @f = split(/\s+/, $');
+    } else {
+	my @f = split(/\s+/);
+	my $ref = shift @f;
+	my $num = shift @f;
+	$last = "$ref $num";
+    }
+    for (@f) {
+	die unless /=/;
+	$chr{$last}{uc($1)} = $2;
+    }
+}
+
+
+#
+# "sub" populates the following global variables:
+#
+# $end[rule-number] = 0 / 1
+# $match[rule-number]{field} = pattern
+# $action[rule-number]{field} = value
+#
+# $match_stack[depth]{field} = pattern
+# $action_stack[depth]{field} = value
+# $may_cont = 0 / 1
+# $last
+#
+# to do:
+# - test this
+# - unit canonicalization
+# - glob to RE rewriting for pattern
+# - $n expansion for value
+#
+
+sub sub
+{
+    /^\s*/;
+    my $indent = $&;
+    my @f = split(/\s+/, $');
+    my $in = 0;		# indentation level
+    while (/^./ =~ $indent) {
+	if ($& eq " ") {
+	    $in++;
+	} elsif ($& eq "\t") {
+	    $in = ($in+8) & ~7;
+	} else {
+	    die;
+	}
+    }
+    if ($may_cont && $in > $last) {
+	pop(@match);
+	pop(@action);
+    } else {
+	$match_stack[0] = undef;
+	$action_stack[0] = undef;
+    }
+    $last = $in;
+    while (@f) {
+	my $f = shift @f;
+	last if $f eq "->" || $f eq "{" || $f eq "}" || $f eq "!";
+	if ($f =~ /=/) {
+	    $match_stack[0]{"REF"} = $f;
+	} else {
+	    $match_stack[0]{uc($`)} = $';
+	}
+    }
+    if ($f eq "->") {
+	while (@f) {
+	    my $f = shift @f;
+	    last if $f eq "{" || $f eq "!";
+	}
+	die unless /=/;
+	$action_stack[0]{uc($`)} = $';
+    }
+    $may_cont = 0;
+    if ($f eq "{") {
+	unshift(@match_stack, undef);
+	unshift(@action_stack, undef);
+    } elsif ($f eq "}") {
+	shift @match_stack;
+	shift @action_stack;
+    } else {
+	push(@end, $f eq "!");
+	$may_cont = $f ne "!";
+	my $n = $#end;
+	for $m (@match_stack) {
+	    for (keys %{ $_ }) {
+		$match[$n]{$_} = $m{$_};
+	    }
+	}
+	for $a (@action_stack) {
+	    for (keys %{ $_ }) {
+		$action[$n]{$_} = $m{$_};
+	    }
+	}
+    }
+}
+
+
 sub parse
 {
     $mode = *skip;
@@ -128,6 +237,17 @@
 	    $mode = *par;
 	    next;
 	}
+	if (/^#CHR\b/) {
+	    $mode = *chr;
+	    undef $last;
+	    next;
+	}
+	if (/^#SUB\b/) {
+	    $mode = *sub;
+	    undef $last;
+	    undef $may_cont;
+	    next;
+	}
 	s/#.*//;
 	next if /^\s*$/;
 	&$mode($_);

Modified: trunk/gta02-core/bom/workflow.fig
===================================================================
--- trunk/gta02-core/bom/workflow.fig	2010-01-26 22:11:00 UTC (rev 5799)
+++ trunk/gta02-core/bom/workflow.fig	2010-01-28 08:25:08 UTC (rev 5800)
@@ -7,22 +7,6 @@
 Single
 -2
 1200 2
-6 450 7200 6480 8775
-4 0 0 50 -1 12 12 0.0000 4 150 540 450 7380 .sch\001
-4 0 0 50 -1 12 12 0.0000 4 150 540 450 7605 .lst\001
-4 0 0 50 -1 12 12 0.0000 4 105 540 450 7830 .csv\001
-4 0 0 50 -1 12 12 0.0000 4 150 540 450 8055 .inv\001
-4 0 0 50 -1 12 12 0.0000 4 150 540 450 8280 .equ\001
-4 0 0 50 -1 12 12 0.0000 4 150 540 450 8505 .par\001
-4 0 0 50 -1 12 12 0.0000 4 150 540 450 8730 .ord\001
-4 0 0 50 -1 1 12 0.0000 4 195 2010 1350 7380 schematics (for KiCad)\001
-4 0 0 50 -1 1 12 0.0000 4 195 2220 1350 7605 BOM generated by KiCad\001
-4 0 0 50 -1 1 12 0.0000 4 195 2520 1350 8055 inventory with stock and cost\001
-4 0 0 50 -1 1 12 0.0000 4 195 3045 1350 7830 GTA02 EE component stock at FIC\001
-4 0 0 50 -1 1 12 0.0000 4 195 5130 1350 8280 part number equivalences, e.g., manufacturer vs. distributor\001
-4 0 0 50 -1 1 12 0.0000 4 195 2910 1350 8505 component to part number(s) map\001
-4 0 0 50 -1 1 12 0.0000 4 195 5025 1350 8730 list of parts to order, with price and component references\001
--6
 6 450 6075 3150 6750
 4 0 0 50 -1 14 12 0.0000 4 180 2700 450 6255 Source file (in SVN)\001
 4 0 0 50 -1 12 12 0.0000 4 150 1890 450 6480 Generated file\001
@@ -85,4 +69,26 @@
 4 1 0 50 -1 14 12 0.0000 4 195 1890 4950 1755 gta02-core.inv\001
 4 1 0 50 -1 12 12 0.0000 4 195 1890 7200 4680 gta02-core.par\001
 -6
+6 450 8100 6480 9225
+4 0 0 50 -1 12 12 0.0000 4 105 540 450 8280 .csv\001
+4 0 0 50 -1 12 12 0.0000 4 150 540 450 8505 .inv\001
+4 0 0 50 -1 12 12 0.0000 4 150 540 450 8730 .equ\001
+4 0 0 50 -1 12 12 0.0000 4 150 540 450 8955 .par\001
+4 0 0 50 -1 12 12 0.0000 4 150 540 450 9180 .ord\001
+4 0 0 50 -1 1 12 0.0000 4 195 2520 1350 8505 inventory with stock and cost\001
+4 0 0 50 -1 1 12 0.0000 4 195 3045 1350 8280 GTA02 EE component stock at FIC\001
+4 0 0 50 -1 1 12 0.0000 4 195 5130 1350 8730 part number equivalences, e.g., manufacturer vs. distributor\001
+4 0 0 50 -1 1 12 0.0000 4 195 2910 1350 8955 component to part number(s) map\001
+4 0 0 50 -1 1 12 0.0000 4 195 5025 1350 9180 list of parts to order, with price and component references\001
+-6
+6 450 7650 3465 8100
+4 0 0 50 -1 12 12 0.0000 4 150 540 450 7830 .chr\001
+4 0 0 50 -1 12 12 0.0000 4 150 540 450 8055 .sub\001
+4 0 0 50 -1 1 12 0.0000 4 195 1695 1350 7830 part characteristics\001
+4 0 0 50 -1 1 12 0.0000 4 195 2085 1350 8055 parameter substitutions\001
+-6
 4 0 0 50 -1 2 16 0.0000 4 255 3345 450 675 BOM Processing - Workflow\001
+4 0 0 50 -1 12 12 0.0000 4 150 540 450 7380 .sch\001
+4 0 0 50 -1 12 12 0.0000 4 150 540 450 7605 .lst\001
+4 0 0 50 -1 1 12 0.0000 4 195 2010 1350 7380 schematics (for KiCad)\001
+4 0 0 50 -1 1 12 0.0000 4 195 2220 1350 7605 BOM generated by KiCad\001




More information about the commitlog mailing list