xml: Slight change in VPR XML format. Support a format for pb_type which doesn't require repeating the name many times. Use the xmlsort style sheet to generate the old XML version. The changes are; * Remove the requirement to give an interconnect a name. * Moving from attributes for input/output to "port" tags. * Decompose the old 'PB_TYPE.PORT[BIT]' into attributes on "port" tag. * "Port" tags have a 'from' attribute. If left blank it defaults to the current pb_type. Before; ```xml <direct input="XXXX.CLOCK_ENABLE" output="in_cen.EN" name="XXXX"> ``` After; ```xml <direct> <port name="CLOCK_ENABLE" type="input"/> <port name="EN" type="output" from="in_cen"/> </direct> ``` Disadvantages: * This is more verbose. Advantages: * The 'default to current pb_type' means that you can do; ```xml <pb_type name="tristate" num_pb="1"> <xi:include href="../tri/io_tri.pb_type.xml" xpointer="xpointer(pb_type/child::node())"/> </pb_type> ``` Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
diff --git a/xmlsort.xsl b/xmlsort.xsl index b61d473..49c1749 100644 --- a/xmlsort.xsl +++ b/xmlsort.xsl
@@ -12,13 +12,57 @@ <xsl:copy> <!-- Sort the attributes by name and remove the xml:base attribute --> <xsl:for-each select="@*[name()!='xml:base']"> - <xsl:sort select="name( . )"/> - <xsl:attribute name="{local-name()}"><xsl:value-of select="normalize-space(.)"/></xsl:attribute> + <xsl:sort select="name( . )"/> + <xsl:attribute name="{local-name()}"><xsl:value-of select="normalize-space(.)"/></xsl:attribute> </xsl:for-each> <xsl:apply-templates/> </xsl:copy> </xsl:template> + <!-- Allow from attribute which gives you a relative to a given pb_type --> + <xsl:template name="from-pb_type"> + <xsl:choose> + <xsl:when test="@from='current'"><xsl:value-of select="ancestor::pb_type[1]/@name"/></xsl:when> + <xsl:when test="@from"><xsl:value-of select="@from"/></xsl:when> + <xsl:otherwise><xsl:value-of select="ancestor::pb_type[1]/@name"/></xsl:otherwise> + </xsl:choose> + </xsl:template> + + <!-- + Convert + * <port name=XXX> to XXX + * <port name=XXX bit=Y> to XXX[Y] + * <port name=XXX bit_msb=M bit_lsb=L> to XXX[M:L] + --> + <xsl:template name="port-value"><xsl:value-of select="@name"/><xsl:choose><xsl:when test="@bit">[<xsl:value-of select="@bit"/>]</xsl:when><xsl:when test="@bit-msb">[<xsl:value-of select="@bit-msb"/>:<xsl:value-of select="@bit-lsb"/>]</xsl:when><xsl:otherwise></xsl:otherwise></xsl:choose></xsl:template> + + <!-- + Convert + <interconnect><XXX><port type='input' ...><port type='output' ...></XXX><YYY../></interconnect> + to + <interconnect><XXX input='...' output='...'><YYY../></XXX></interconnect> + --> + <xsl:template match="interconnect/*/port[@type='input']"> + <xsl:attribute name="input"><xsl:call-template name="from-pb_type"/>.<xsl:call-template name="port-value"/></xsl:attribute> + </xsl:template> + <xsl:template match="interconnect/*/port[@type='output']"> + <xsl:attribute name="name"><xsl:call-template name="from-pb_type"/>-<xsl:call-template name="port-value"/></xsl:attribute> + <xsl:attribute name="output"><xsl:call-template name="from-pb_type"/>.<xsl:call-template name="port-value"/></xsl:attribute> + </xsl:template> + <!-- + Convert + <loc ...><port ...><port ...></loc> + to + <loc ...>BLOCK.PORT BLOCK.PORT</loc> + --> + <xsl:template match="loc/port"><xsl:text> + </xsl:text><xsl:call-template name="from-pb_type"/>.<xsl:call-template name="port-value"/> + </xsl:template> + <xsl:template match="loc/port[last()]"><xsl:text> + </xsl:text><xsl:call-template name="from-pb_type"/>.<xsl:call-template name="port-value"/><xsl:text> + </xsl:text> + </xsl:template> + <!-- Remove duplicate model nodes --> <xsl:key name="model-by-name" match="model" use="@name" /> <xsl:template match="models">