2010-08-28 18:02:24 +00:00
|
|
|
<?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:
|
2011-03-02 11:03:06 +00:00
|
|
|
see eeschema.pdf, chapter 14
|
2010-08-28 18:02:24 +00:00
|
|
|
-->
|
|
|
|
|
|
|
|
<!DOCTYPE xsl:stylesheet [
|
|
|
|
<!ENTITY nl "
"> <!--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"/>
|
|
|
|
|
2011-02-10 08:27:36 +00:00
|
|
|
<!--
|
|
|
|
Netlist header
|
|
|
|
Creates the entire netlist
|
|
|
|
(can be seen as equivalent to main function in C
|
|
|
|
-->
|
2010-08-28 18:02:24 +00:00
|
|
|
<xsl:template match="/export">
|
|
|
|
<xsl:text>( { EESchema Netlist Version 1.1 </xsl:text>
|
2011-02-10 08:27:36 +00:00
|
|
|
<!-- Generate line .TIM <time> -->
|
|
|
|
<xsl:apply-templates select="design/date"/>
|
|
|
|
<!-- Generate line eeschema version ... -->
|
|
|
|
<xsl:apply-templates select="design/tool"/>
|
2010-08-28 18:02:24 +00:00
|
|
|
<xsl:text>}&nl;</xsl:text>
|
2011-02-10 08:27:36 +00:00
|
|
|
|
|
|
|
<!-- Generate the list of components -->
|
2010-08-28 18:02:24 +00:00
|
|
|
<xsl:apply-templates select="components/comp"/> <!-- Generate list of components -->
|
2011-02-10 08:27:36 +00:00
|
|
|
|
|
|
|
<!-- end of file -->
|
2010-08-28 18:02:24 +00:00
|
|
|
<xsl:text>)&nl;*&nl;</xsl:text>
|
|
|
|
</xsl:template>
|
|
|
|
|
2011-02-10 08:27:36 +00:00
|
|
|
<!--
|
|
|
|
Generate id in header like "eeschema (2010-08-17 BZR 2450)-unstable"
|
|
|
|
-->
|
2010-08-28 18:02:24 +00:00
|
|
|
<xsl:template match="tool">
|
|
|
|
<xsl:apply-templates/>
|
|
|
|
</xsl:template>
|
|
|
|
|
2011-02-10 08:27:36 +00:00
|
|
|
<!--
|
|
|
|
Generate date in header like "20/08/2010 10:45:33"
|
|
|
|
-->
|
2010-08-28 18:02:24 +00:00
|
|
|
<xsl:template match="date">
|
|
|
|
<xsl:apply-templates/>
|
|
|
|
<xsl:text>&nl;</xsl:text>
|
|
|
|
</xsl:template>
|
|
|
|
|
2011-02-10 08:27:36 +00:00
|
|
|
<!--
|
|
|
|
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
|
|
|
|
-->
|
2010-08-28 18:02:24 +00:00
|
|
|
<xsl:template match="comp">
|
|
|
|
<xsl:text> ( </xsl:text>
|
|
|
|
<xsl:choose>
|
|
|
|
<xsl:when test = "tstamp != '' ">
|
|
|
|
<xsl:apply-templates select="tstamp"/>
|
|
|
|
</xsl:when>
|
|
|
|
<xsl:otherwise>
|
|
|
|
<xsl:text>00000000</xsl:text>
|
|
|
|
</xsl:otherwise>
|
|
|
|
</xsl:choose>
|
|
|
|
<xsl:text> </xsl:text>
|
|
|
|
<xsl:choose>
|
|
|
|
<xsl:when test = "footprint != '' ">
|
|
|
|
<xsl:apply-templates select="footprint"/>
|
|
|
|
</xsl:when>
|
|
|
|
<xsl:otherwise>
|
|
|
|
<xsl:text>$noname</xsl:text>
|
|
|
|
</xsl:otherwise>
|
|
|
|
</xsl:choose>
|
|
|
|
<xsl:text> </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:text>&nl;</xsl:text>
|
2011-02-10 08:27:36 +00:00
|
|
|
<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>
|
2010-08-28 18:02:24 +00:00
|
|
|
<xsl:text> )&nl;</xsl:text>
|
|
|
|
</xsl:template>
|
|
|
|
|
2011-02-10 08:27:36 +00:00
|
|
|
<!--
|
|
|
|
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>
|
2011-02-10 17:49:04 +00:00
|
|
|
Output pin list is ( <pin num> <net name> )
|
2011-02-10 08:27:36 +00:00
|
|
|
something like
|
2011-02-10 17:49:04 +00:00
|
|
|
( 1 VCC )
|
|
|
|
( 2 GND )
|
2011-02-10 08:27:36 +00:00
|
|
|
-->
|
|
|
|
<xsl:template name="build_pin_list" match="pin">
|
|
|
|
<xsl:param name="cmp_ref" select="0" />
|
|
|
|
|
|
|
|
<!-- write pin numner and separator -->
|
|
|
|
<xsl:text> ( </xsl:text>
|
2010-08-28 18:02:24 +00:00
|
|
|
<xsl:value-of select="@num"/>
|
2011-02-10 17:49:04 +00:00
|
|
|
<xsl:text> </xsl:text>
|
2011-02-10 08:27:36 +00:00
|
|
|
|
|
|
|
<!-- 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 -->
|
2010-08-28 18:02:24 +00:00
|
|
|
<xsl:text> )&nl;</xsl:text>
|
|
|
|
</xsl:template>
|
|
|
|
|
2011-02-10 08:27:36 +00:00
|
|
|
<!--
|
|
|
|
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>
|
|
|
|
<!-- if a net has a name, use it,
|
|
|
|
else build a name from its net code
|
|
|
|
-->
|
|
|
|
<xsl:when test = "../@name != '' ">
|
|
|
|
<xsl:value-of select="../@name"/>
|
|
|
|
</xsl:when>
|
|
|
|
<xsl:otherwise>
|
|
|
|
<xsl:text>$N-0</xsl:text><xsl:value-of select="../@code"/>
|
|
|
|
</xsl:otherwise>
|
|
|
|
</xsl:choose>
|
|
|
|
</xsl:if>
|
|
|
|
<xsl:if test = "$pin_cnt_in_net <2">
|
|
|
|
<xsl:text>?</xsl:text>
|
|
|
|
</xsl:if>
|
|
|
|
</xsl:if>
|
|
|
|
</xsl:if>
|
|
|
|
|
|
|
|
</xsl:template>
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
</xsl:stylesheet>
|