Commit 0cb6cd8c authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: in intermediate netlist generation: remove redundant pins list by...

Eeschema: in intermediate netlist generation: remove redundant pins list by component, and make Dick happy.
Known bug in intermediate netlist generation: multi parts per package have their common pins listed more than once in nets section. Will be fixed.
parent 34094e77
EESchema-LIBRARY Version 2.3 Date: 17/05/2010 10:14:05 EESchema-LIBRARY Version 2.3 Date: 09/02/2011 18:36:39
# #
# 74LS125 # 74LS125
# #
......
EESchema Schematic File Version 2 date 17/05/2010 10:14:05 EESchema Schematic File Version 2 date 09/02/2011 18:36:39
LIBS:power LIBS:power
LIBS:device LIBS:device
LIBS:conn LIBS:conn
...@@ -25,12 +25,12 @@ LIBS:cypress ...@@ -25,12 +25,12 @@ LIBS:cypress
LIBS:siliconi LIBS:siliconi
LIBS:contrib LIBS:contrib
LIBS:sonde xilinx-cache LIBS:sonde xilinx-cache
EELAYER 23 0 EELAYER 25 0
EELAYER END EELAYER END
$Descr A4 11700 8267 $Descr A4 11700 8267
Sheet 1 1 Sheet 1 1
Title "CABLE PARALLELE III" Title "CABLE PARALLELE III"
Date "3 may 2007" Date "9 feb 2011"
Rev "1" Rev "1"
Comp "" Comp ""
Comment1 "" Comment1 ""
...@@ -48,17 +48,17 @@ Wire Wire Line ...@@ -48,17 +48,17 @@ Wire Wire Line
Wire Wire Line Wire Wire Line
6400 4200 5900 4200 6400 4200 5900 4200
$Comp $Comp
L GND #PWR01 L GND #PWR111
U 1 1 3EBF81B1 U 1 1 4D52D0AC
P 6300 4650 P 6300 4650
F 0 "#PWR01" H 6300 4650 40 0001 C CNN F 0 "#PWR111" H 6300 4650 40 0001 C CNN
F 1 "GND" H 6300 4580 40 0001 C CNN F 1 "GND" H 6300 4580 40 0001 C CNN
1 6300 4650 1 6300 4650
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
$Comp $Comp
L C C4 L C C4
U 1 1 3EBF81A7 U 1 1 4D52D0AA
P 6300 4450 P 6300 4450
F 0 "C4" H 6350 4550 50 0000 L CNN F 0 "C4" H 6350 4550 50 0000 L CNN
F 1 "100pF" H 6350 4350 50 0000 L CNN F 1 "100pF" H 6350 4350 50 0000 L CNN
...@@ -67,7 +67,7 @@ F 1 "100pF" H 6350 4350 50 0000 L CNN ...@@ -67,7 +67,7 @@ F 1 "100pF" H 6350 4350 50 0000 L CNN
$EndComp $EndComp
$Comp $Comp
L R R13 L R R13
U 1 1 3EBF819B U 1 1 4D52D0A6
P 6650 4200 P 6650 4200
F 0 "R13" V 6730 4200 50 0000 C CNN F 0 "R13" V 6730 4200 50 0000 C CNN
F 1 "100" V 6650 4200 50 0000 C CNN F 1 "100" V 6650 4200 50 0000 C CNN
...@@ -134,37 +134,37 @@ Wire Wire Line ...@@ -134,37 +134,37 @@ Wire Wire Line
Wire Wire Line Wire Wire Line
8400 3700 8400 2750 8400 3700 8400 2750
$Comp $Comp
L PWR_FLAG #FLG02 L PWR_FLAG #FLG102
U 1 1 3EBF848F U 1 1 3EBF848F
P 6200 1050 P 6200 1050
F 0 "#FLG02" H 6200 1320 30 0001 C CNN F 0 "#FLG102" H 6200 1320 30 0001 C CNN
F 1 "PWR_FLAG" H 6200 1280 30 0000 C CNN F 1 "PWR_FLAG" H 6200 1280 30 0000 C CNN
1 6200 1050 1 6200 1050
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
$Comp $Comp
L VCC #PWR03 L VCC #PWR106
U 1 1 3EBF8479 U 1 1 3EBF8479
P 5900 1050 P 5900 1050
F 0 "#PWR03" H 5900 1150 30 0001 C CNN F 0 "#PWR106" H 5900 1150 30 0001 C CNN
F 1 "VCC" H 5900 1150 30 0000 C CNN F 1 "VCC" H 5900 1150 30 0000 C CNN
1 5900 1050 1 5900 1050
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
$Comp $Comp
L GND #PWR04 L GND #PWR101
U 1 1 3EBF8458 U 1 1 3EBF8458
P 800 7300 P 800 7300
F 0 "#PWR04" H 800 7300 40 0001 C CNN F 0 "#PWR101" H 800 7300 40 0001 C CNN
F 1 "GND" H 800 7230 40 0001 C CNN F 1 "GND" H 800 7230 40 0001 C CNN
1 800 7300 1 800 7300
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
$Comp $Comp
L PWR_FLAG #FLG05 L PWR_FLAG #FLG101
U 1 1 3EBF843C U 1 1 3EBF843C
P 800 7300 P 800 7300
F 0 "#FLG05" H 800 7570 30 0001 C CNN F 0 "#FLG101" H 800 7570 30 0001 C CNN
F 1 "PWR_FLAG" H 800 7530 30 0000 C CNN F 1 "PWR_FLAG" H 800 7530 30 0000 C CNN
1 800 7300 1 800 7300
1 0 0 -1 1 0 0 -1
...@@ -179,10 +179,10 @@ Wire Wire Line ...@@ -179,10 +179,10 @@ Wire Wire Line
Wire Wire Line Wire Wire Line
2500 2700 2200 2700 2500 2700 2200 2700
$Comp $Comp
L GND #PWR06 L GND #PWR104
U 1 1 3EBF8100 U 1 1 4D52D0A5
P 2500 2750 P 2500 2750
F 0 "#PWR06" H 2500 2750 40 0001 C CNN F 0 "#PWR104" H 2500 2750 40 0001 C CNN
F 1 "GND" H 2500 2680 40 0001 C CNN F 1 "GND" H 2500 2680 40 0001 C CNN
1 2500 2750 1 2500 2750
1 0 0 -1 1 0 0 -1
...@@ -200,10 +200,10 @@ Wire Wire Line ...@@ -200,10 +200,10 @@ Wire Wire Line
Text Label 9450 3500 0 60 ~ 0 Text Label 9450 3500 0 60 ~ 0
PWR(3,3-5V) PWR(3,3-5V)
$Comp $Comp
L GND #PWR07 L GND #PWR114
U 1 1 3EBF8376 U 1 1 3EBF8376
P 10050 3600 P 10050 3600
F 0 "#PWR07" H 10050 3600 40 0001 C CNN F 0 "#PWR114" H 10050 3600 40 0001 C CNN
F 1 "GND" H 10050 3530 40 0001 C CNN F 1 "GND" H 10050 3530 40 0001 C CNN
1 10050 3600 1 10050 3600
0 1 1 0 0 1 1 0
...@@ -219,10 +219,10 @@ TD0-DONE/P ...@@ -219,10 +219,10 @@ TD0-DONE/P
Text Label 7700 2550 0 60 ~ 0 Text Label 7700 2550 0 60 ~ 0
PWR(3,3-5V) PWR(3,3-5V)
$Comp $Comp
L GND #PWR08 L GND #PWR113
U 1 1 3EBF8376 U 1 1 4D52D0AF
P 8500 2650 P 8500 2650
F 0 "#PWR08" H 8500 2650 40 0001 C CNN F 0 "#PWR113" H 8500 2650 40 0001 C CNN
F 1 "GND" H 8500 2580 40 0001 C CNN F 1 "GND" H 8500 2580 40 0001 C CNN
1 8500 2650 1 8500 2650
0 1 1 0 0 1 1 0
...@@ -266,10 +266,10 @@ Connection ~ 6500 1050 ...@@ -266,10 +266,10 @@ Connection ~ 6500 1050
Wire Wire Line Wire Wire Line
6500 1100 6500 1050 6500 1100 6500 1050
$Comp $Comp
L GND #PWR09 L GND #PWR112
U 1 1 3EBF82CF U 1 1 3EBF82CF
P 6500 1500 P 6500 1500
F 0 "#PWR09" H 6500 1500 40 0001 C CNN F 0 "#PWR112" H 6500 1500 40 0001 C CNN
F 1 "GND" H 6500 1430 40 0001 C CNN F 1 "GND" H 6500 1430 40 0001 C CNN
1 6500 1500 1 6500 1500
1 0 0 -1 1 0 0 -1
...@@ -299,10 +299,10 @@ Wire Wire Line ...@@ -299,10 +299,10 @@ Wire Wire Line
Wire Wire Line Wire Wire Line
6400 1900 5900 1900 6400 1900 5900 1900
$Comp $Comp
L GND #PWR010 L GND #PWR110
U 1 1 3EBF81B1 U 1 1 4D52D0AD
P 6300 3750 P 6300 3750
F 0 "#PWR010" H 6300 3750 40 0001 C CNN F 0 "#PWR110" H 6300 3750 40 0001 C CNN
F 1 "GND" H 6300 3680 40 0001 C CNN F 1 "GND" H 6300 3680 40 0001 C CNN
1 6300 3750 1 6300 3750
1 0 0 -1 1 0 0 -1
...@@ -318,7 +318,7 @@ F 1 "100pF" H 6350 3450 50 0000 L CNN ...@@ -318,7 +318,7 @@ F 1 "100pF" H 6350 3450 50 0000 L CNN
$EndComp $EndComp
$Comp $Comp
L R R12 L R R12
U 1 1 3EBF819B U 1 1 4D52D0A7
P 6650 3300 P 6650 3300
F 0 "R12" V 6730 3300 50 0000 C CNN F 0 "R12" V 6730 3300 50 0000 C CNN
F 1 "100" V 6650 3300 50 0000 C CNN F 1 "100" V 6650 3300 50 0000 C CNN
...@@ -326,17 +326,17 @@ F 1 "100" V 6650 3300 50 0000 C CNN ...@@ -326,17 +326,17 @@ F 1 "100" V 6650 3300 50 0000 C CNN
0 1 1 0 0 1 1 0
$EndComp $EndComp
$Comp $Comp
L GND #PWR011 L GND #PWR109
U 1 1 3EBF81B1 U 1 1 4D52D0AE
P 6300 3050 P 6300 3050
F 0 "#PWR011" H 6300 3050 40 0001 C CNN F 0 "#PWR109" H 6300 3050 40 0001 C CNN
F 1 "GND" H 6300 2980 40 0001 C CNN F 1 "GND" H 6300 2980 40 0001 C CNN
1 6300 3050 1 6300 3050
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
$Comp $Comp
L C C2 L C C2
U 1 1 3EBF81A7 U 1 1 4D52D0AB
P 6300 2850 P 6300 2850
F 0 "C2" H 6350 2950 50 0000 L CNN F 0 "C2" H 6350 2950 50 0000 L CNN
F 1 "100pF" H 6350 2750 50 0000 L CNN F 1 "100pF" H 6350 2750 50 0000 L CNN
...@@ -345,7 +345,7 @@ F 1 "100pF" H 6350 2750 50 0000 L CNN ...@@ -345,7 +345,7 @@ F 1 "100pF" H 6350 2750 50 0000 L CNN
$EndComp $EndComp
$Comp $Comp
L R R11 L R R11
U 1 1 3EBF819B U 1 1 4D52D0A8
P 6650 2600 P 6650 2600
F 0 "R11" V 6730 2600 50 0000 C CNN F 0 "R11" V 6730 2600 50 0000 C CNN
F 1 "100" V 6650 2600 50 0000 C CNN F 1 "100" V 6650 2600 50 0000 C CNN
...@@ -365,26 +365,26 @@ Wire Wire Line ...@@ -365,26 +365,26 @@ Wire Wire Line
Wire Wire Line Wire Wire Line
6200 1050 6200 1100 6200 1050 6200 1100
$Comp $Comp
L GND #PWR012 L GND #PWR107
U 1 1 3EBF81B3 U 1 1 3EBF81B3
P 6200 1600 P 6200 1600
F 0 "#PWR012" H 6200 1600 40 0001 C CNN F 0 "#PWR107" H 6200 1600 40 0001 C CNN
F 1 "GND" H 6200 1530 40 0001 C CNN F 1 "GND" H 6200 1530 40 0001 C CNN
1 6200 1600 1 6200 1600
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
$Comp $Comp
L GND #PWR013 L GND #PWR108
U 1 1 3EBF81B1 U 1 1 3EBF81B1
P 6300 2350 P 6300 2350
F 0 "#PWR013" H 6300 2350 40 0001 C CNN F 0 "#PWR108" H 6300 2350 40 0001 C CNN
F 1 "GND" H 6300 2280 40 0001 C CNN F 1 "GND" H 6300 2280 40 0001 C CNN
1 6300 2350 1 6300 2350
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
$Comp $Comp
L C C3 L C C3
U 1 1 3EBF81A7 U 1 1 4D52D0A9
P 6300 2150 P 6300 2150
F 0 "C3" H 6350 2250 50 0000 L CNN F 0 "C3" H 6350 2250 50 0000 L CNN
F 1 "100pF" H 6350 2050 50 0000 L CNN F 1 "100pF" H 6350 2050 50 0000 L CNN
...@@ -450,19 +450,19 @@ Wire Wire Line ...@@ -450,19 +450,19 @@ Wire Wire Line
Wire Wire Line Wire Wire Line
2500 1700 2200 1700 2500 1700 2200 1700
$Comp $Comp
L GND #PWR014 L GND #PWR103
U 1 1 3EBF8100 U 1 1 3EBF8100
P 2500 1750 P 2500 1750
F 0 "#PWR014" H 2500 1750 40 0001 C CNN F 0 "#PWR103" H 2500 1750 40 0001 C CNN
F 1 "GND" H 2500 1680 40 0001 C CNN F 1 "GND" H 2500 1680 40 0001 C CNN
1 2500 1750 1 2500 1750
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
$Comp $Comp
L GND #PWR015 L GND #PWR105
U 1 1 3EBF80DD U 1 1 3EBF80DD
P 4650 2000 P 4650 2000
F 0 "#PWR015" H 4650 2000 40 0001 C CNN F 0 "#PWR105" H 4650 2000 40 0001 C CNN
F 1 "GND" H 4650 1930 40 0001 C CNN F 1 "GND" H 4650 1930 40 0001 C CNN
1 4650 2000 1 4650 2000
1 0 0 -1 1 0 0 -1
...@@ -531,10 +531,10 @@ Wire Wire Line ...@@ -531,10 +531,10 @@ Wire Wire Line
Wire Wire Line Wire Wire Line
1700 7200 1150 7200 1700 7200 1150 7200
$Comp $Comp
L GND #PWR016 L GND #PWR102
U 1 1 3EBF7F0D U 1 1 3EBF7F0D
P 1150 7300 P 1150 7300
F 0 "#PWR016" H 1150 7300 40 0001 C CNN F 0 "#PWR102" H 1150 7300 40 0001 C CNN
F 1 "GND" H 1150 7230 40 0001 C CNN F 1 "GND" H 1150 7230 40 0001 C CNN
1 1150 7300 1 1150 7300
1 0 0 -1 1 0 0 -1
...@@ -653,7 +653,7 @@ F 1 "100" V 3950 3300 50 0000 C CNN ...@@ -653,7 +653,7 @@ F 1 "100" V 3950 3300 50 0000 C CNN
$EndComp $EndComp
$Comp $Comp
L R R8 L R R8
U 1 1 3EBF7D33 U 1 1 4D52D0A4
P 3950 2900 P 3950 2900
F 0 "R8" V 4030 2900 50 0000 C CNN F 0 "R8" V 4030 2900 50 0000 C CNN
F 1 "100" V 3950 2900 50 0000 C CNN F 1 "100" V 3950 2900 50 0000 C CNN
...@@ -662,7 +662,7 @@ F 1 "100" V 3950 2900 50 0000 C CNN ...@@ -662,7 +662,7 @@ F 1 "100" V 3950 2900 50 0000 C CNN
$EndComp $EndComp
$Comp $Comp
L R R7 L R R7
U 1 1 3EBF7D31 U 1 1 4D52D0A3
P 3950 2600 P 3950 2600
F 0 "R7" V 4030 2600 50 0000 C CNN F 0 "R7" V 4030 2600 50 0000 C CNN
F 1 "100" V 3950 2600 50 0000 C CNN F 1 "100" V 3950 2600 50 0000 C CNN
......
...@@ -941,10 +941,6 @@ XNODE* EXPORT_HELP::makeGenericComponents() ...@@ -941,10 +941,6 @@ XNODE* EXPORT_HELP::makeGenericComponents()
wxString sLib = wxT( "lib" ); wxString sLib = wxT( "lib" );
wxString sPart = wxT( "part" ); wxString sPart = wxT( "part" );
wxString sNames = wxT( "names" ); wxString sNames = wxT( "names" );
wxString sPinNum = wxT( "num" );
wxString sPinNetname = wxT( "netname" );
wxString sPinNetcode = wxT( "netcode" );
m_ReferencesAlreadyFound.Clear(); m_ReferencesAlreadyFound.Clear();
...@@ -957,7 +953,7 @@ XNODE* EXPORT_HELP::makeGenericComponents() ...@@ -957,7 +953,7 @@ XNODE* EXPORT_HELP::makeGenericComponents()
{ {
for( EDA_ITEM* schItem = path->LastDrawList(); schItem; schItem = schItem->Next() ) for( EDA_ITEM* schItem = path->LastDrawList(); schItem; schItem = schItem->Next() )
{ {
SCH_COMPONENT* comp = findNextComponentAndCreatPinList( schItem, path ); SCH_COMPONENT* comp = findNextComponent( schItem, path );
if( !comp ) if( !comp )
break; // No component left break; // No component left
...@@ -1021,26 +1017,6 @@ XNODE* EXPORT_HELP::makeGenericComponents() ...@@ -1021,26 +1017,6 @@ XNODE* EXPORT_HELP::makeGenericComponents()
timeStamp.Printf( sTSFmt, comp->m_TimeStamp ); timeStamp.Printf( sTSFmt, comp->m_TimeStamp );
xcomp->AddChild( node( sTStamp, timeStamp ) ); xcomp->AddChild( node( sTStamp, timeStamp ) );
// Add pins list for this component.
// Useful to build netlist which have pads connection inside the footprint description
// (Spice, OrcadPCB2 ...)
XNODE* xpinslist;
xcomp->AddChild( xpinslist = node( sPins ) );
for( unsigned ii = 0; ii < m_SortedComponentPinList.size(); ii++ )
{
NETLIST_OBJECT* Pin = m_SortedComponentPinList[ii];
if( !Pin )
continue;
XNODE* xpin;
xpinslist->AddChild( xpin = node( sPin ) );
wxString text;
xpin->AddAttribute( sPinNum, Pin->GetPinNumText() );
sprintPinNetName( &text, wxT( "N-%.6d" ), Pin );
xpin->AddAttribute( sPinNetname, text );
text.Printf( wxT( "%d" ), Pin->GetNet() );
xpin->AddAttribute( sPinNetcode, text );
}
} }
} }
......
...@@ -377,9 +377,9 @@ void NETLIST_DIALOG::AddNewPluginPanel( wxCommandEvent& event ) ...@@ -377,9 +377,9 @@ void NETLIST_DIALOG::AddNewPluginPanel( wxCommandEvent& event )
wxFileName fn( FullFileName ); wxFileName fn( FullFileName );
wxString ext = fn.GetExt(); wxString ext = fn.GetExt();
if( ext == wxT("xsl" ) ) if( ext == wxT("xsl" ) )
cmdLine.Printf(wxT("xsltproc -o %%O \"%s\" %%I"), GetChars(FullFileName) ); cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), GetChars(FullFileName) );
else if( ext == wxT("exe" ) || ext.IsEmpty() ) else if( ext == wxT("exe" ) || ext.IsEmpty() )
cmdLine.Printf(wxT("\"%s\" > %%O < %%I"), GetChars(FullFileName) ); cmdLine.Printf(wxT("\"%s\" > \"%%O\" < \"%%I\""), GetChars(FullFileName) );
else else
cmdLine.Printf(wxT("\"%s\""), GetChars(FullFileName) ); cmdLine.Printf(wxT("\"%s\""), GetChars(FullFileName) );
......
...@@ -14,28 +14,50 @@ ...@@ -14,28 +14,50 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/> <xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
<!-- Netlist header --> <!--
Netlist header
Creates the entire netlist
(can be seen as equivalent to main function in C
-->
<xsl:template match="/export"> <xsl:template match="/export">
<xsl:text>( { EESchema Netlist Version 1.1 </xsl:text> <xsl:text>( { EESchema Netlist Version 1.1 </xsl:text>
<xsl:apply-templates select="design/date"/> <!-- Generate line .TIM <time> --> <!-- Generate line .TIM <time> -->
<xsl:apply-templates select="design/tool"/> <!-- Generate line .APP <eeschema version> --> <xsl:apply-templates select="design/date"/>
<!-- Generate line eeschema version ... -->
<xsl:apply-templates select="design/tool"/>
<xsl:text>}&nl;</xsl:text> <xsl:text>}&nl;</xsl:text>
<!-- Generate the list of components -->
<xsl:apply-templates select="components/comp"/> <!-- Generate list of components --> <xsl:apply-templates select="components/comp"/> <!-- Generate list of components -->
<!-- end of file -->
<xsl:text>)&nl;*&nl;</xsl:text> <xsl:text>)&nl;*&nl;</xsl:text>
</xsl:template> </xsl:template>
<!-- Generate id in header like "eeschema (2010-08-17 BZR 2450)-unstable" --> <!--
Generate id in header like "eeschema (2010-08-17 BZR 2450)-unstable"
-->
<xsl:template match="tool"> <xsl:template match="tool">
<xsl:apply-templates/> <xsl:apply-templates/>
</xsl:template> </xsl:template>
<!-- Generate date in header like "20/08/2010 10:45:33" --> <!--
Generate date in header like "20/08/2010 10:45:33"
-->
<xsl:template match="date"> <xsl:template match="date">
<xsl:apply-templates/> <xsl:apply-templates/>
<xsl:text>&nl;</xsl:text> <xsl:text>&nl;</xsl:text>
</xsl:template> </xsl:template>
<!-- for each component --> <!--
This template read each component
(path = /export/components/comp)
creates lines:
( 3EBF7DBD $noname U1 74LS125
... pin list ...
)
and calls "create_pin_list" template to build the pin list
-->
<xsl:template match="comp"> <xsl:template match="comp">
<xsl:text> ( </xsl:text> <xsl:text> ( </xsl:text>
<xsl:choose> <xsl:choose>
...@@ -67,24 +89,122 @@ ...@@ -67,24 +89,122 @@
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:text>&nl;</xsl:text> <xsl:text>&nl;</xsl:text>
<xsl:apply-templates select="pins/pin"/> <xsl:call-template name="Search_pin_list" >
<xsl:with-param name="cmplib_id" select="libsource/@part"/>
<xsl:with-param name="cmp_ref" select="@ref"/>
</xsl:call-template>
<xsl:text> )&nl;</xsl:text> <xsl:text> )&nl;</xsl:text>
</xsl:template> </xsl:template>
<!-- for each pin in a component --> <!--
<xsl:template match="pin"> This template search for a given lib component description in list
lib component descriptions are in /export/libparts,
and each description start at ./libpart
We search here for the list of pins of the given component
This template has 2 parameters:
"cmplib_id" (reference in libparts)
"cmp_ref" (schematic reference of the given component)
-->
<xsl:template name="Search_pin_list" >
<xsl:param name="cmplib_id" select="0" />
<xsl:param name="cmp_ref" select="0" />
<xsl:for-each select="/export/libparts/libpart">
<xsl:if test = "@part = $cmplib_id ">
<xsl:apply-templates name="build_pin_list" select="pins/pin">
<xsl:with-param name="cmp_ref" select="$cmp_ref"/>
</xsl:apply-templates>
</xsl:if>
</xsl:for-each>
</xsl:template>
<!--
This template writes the pin list of a component
from the pin list of the library description
The pin list from library description is something like
<pins>
<pin num="1" type="passive"/>
<pin num="2" type="passive"/>
</pins>
Output pin list is ( pin num = net name )
something like
( 1 = VCC )
( 2 = GND )
-->
<xsl:template name="build_pin_list" match="pin">
<xsl:param name="cmp_ref" select="0" />
<!-- write pin numner and separator -->
<xsl:text> ( </xsl:text> <xsl:text> ( </xsl:text>
<xsl:value-of select="@num"/> <xsl:value-of select="@num"/>
<xsl:text> = </xsl:text> <xsl:text> = </xsl:text>
<!-- search net name in nets section and write it: -->
<xsl:variable name="pinNum" select="@num" />
<xsl:for-each select="/export/nets/net">
<!-- net name is output only if there is more than one pin in net
else use "?" as net name, so count items in this net
-->
<xsl:variable name="pinCnt" select="count(node)" />
<xsl:apply-templates name="Search_pin_netname" select="node">
<xsl:with-param name="cmp_ref" select="$cmp_ref"/>
<xsl:with-param name="pin_cnt_in_net" select="$pinCnt"/>
<xsl:with-param name="pin_num"> <xsl:value-of select="$pinNum"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:for-each>
<!-- close line -->
<xsl:text> )&nl;</xsl:text>
</xsl:template>
<!--
This template writes the pin netname of a given pin of a given component
from the nets list
The nets list description is something like
<nets>
<net code="1" name="GND">
<node ref="J1" pin="20"/>
<node ref="C2" pin="2"/>
</net>
<net code="2" name="">
<node ref="U2" pin="11"/>
</net>
</nets>
This template has 2 parameters:
"cmp_ref" (schematic reference of the given component)
"pin_num" (pin number)
-->
<xsl:template name="Search_pin_netname" match="node">
<xsl:param name="cmp_ref" select="0" />
<xsl:param name="pin_num" select="0" />
<xsl:param name="pin_cnt_in_net" select="0" />
<xsl:if test = "@ref = $cmp_ref ">
<xsl:if test = "@pin = $pin_num">
<!-- net name is output only if there is more than one pin in net
else use "?" as net name
-->
<xsl:if test = "$pin_cnt_in_net>1">
<xsl:choose> <xsl:choose>
<xsl:when test = "@netname != '' "> <!-- if a net has a name, use it,
<xsl:apply-templates select="@netname"/> else build a name from its net code
-->
<xsl:when test = "../@name != '' ">
<xsl:value-of select="../@name"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:text>?</xsl:text> <xsl:text>$N-0</xsl:text><xsl:value-of select="../@code"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:text> )&nl;</xsl:text> </xsl:if>
<xsl:if test = "$pin_cnt_in_net &lt;2">
<xsl:text>?</xsl:text>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--XSL style sheet to EESCHEMA Generic Netlist Format to CADSTAR netlist format
Copyright (C) 2010, SoftPLC Corporation.
GPL v2.
How to use:
https://lists.launchpad.net/kicad-developers/msg05157.html
-->
<!DOCTYPE xsl:stylesheet [
<!ENTITY nl "&#xd;&#xa;"> <!--new line CR, LF -->
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
<!-- Netlist header -->
<xsl:template match="/export">
<xsl:text>.HEA&nl;</xsl:text>
<xsl:apply-templates select="design/date"/> <!-- Generate line .TIM <time> -->
<xsl:apply-templates select="design/tool"/> <!-- Generate line .APP <eeschema version> -->
<xsl:text>&nl;</xsl:text>
<xsl:apply-templates select="components/comp"/> <!-- Generate list of components -->
<xsl:text>&nl;&nl;</xsl:text>
<xsl:apply-templates select="nets/net"/> <!-- Generate list of nets and connections -->
<xsl:text>&nl;.END&nl;</xsl:text>
</xsl:template>
<!-- Generate line .APP "eeschema (2010-08-17 BZR 2450)-unstable" -->
<xsl:template match="tool">
<xsl:text>.APP "</xsl:text>
<xsl:apply-templates/>
<xsl:text>"&nl;</xsl:text>
</xsl:template>
<!-- Generate line .TIM 20/08/2010 10:45:33 -->
<xsl:template match="date">
<xsl:text>.TIM </xsl:text>
<xsl:apply-templates/>
<xsl:text>&nl;</xsl:text>
</xsl:template>
<!-- for each component -->
<!-- create lines like
.ADD_COM U3 74LS541 (when no footprint name specified)
.ADD_COM JP1 CONN_8X2 pin_array_8x2 pin_array_8x2 (with a specified footprint name)
-->
<xsl:template match="comp">
<xsl:text>.ADD_COM </xsl:text>
<xsl:value-of select="@ref"/>
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test = "value != '' ">
<xsl:apply-templates select="value"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>?</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test = "footprint != '' ">
<xsl:text> </xsl:text>
<xsl:apply-templates select="footprint"/>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&nl;</xsl:text>
</xsl:template>
<!-- for each net -->
<!-- create lines like
.ADD_TER U3.9 /PC-RST
.TER U3.8
BUS1.2
.ADD_TER BUS1.14 /PC-IOR
.TER U3.7
-->
<xsl:template match="net">
<!-- nets are output only if there is more than one pin in net -->
<xsl:if test="count(node)>1">
<xsl:variable name="netname">
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test = "@name != '' ">
<xsl:value-of select="@name"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>N-</xsl:text>
<xsl:value-of select="@code"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&nl;</xsl:text>
</xsl:variable>
<xsl:apply-templates select="node" mode="first"/>
<xsl:value-of select="$netname"/>
<xsl:apply-templates select="node" mode="others"/>
</xsl:if>
</xsl:template>
<!-- for each node -->
<xsl:template match="node" mode="first">
<xsl:if test="position()=1">
<xsl:text>.ADD_TER </xsl:text>
<xsl:value-of select="@ref"/>
<xsl:text>.</xsl:text>
<xsl:value-of select="@pin"/>
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="node" mode="others">
<xsl:choose>
<xsl:when test='position()=1'>
</xsl:when>
<xsl:when test='position()=2'>
<xsl:text>.TER </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="position()>1">
<xsl:value-of select="@ref"/>
<xsl:text>.</xsl:text>
<xsl:value-of select="@pin"/>
<xsl:text>&nl;</xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment