Skip to content

Commit

Permalink
XML: xml schema updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
rbscloud committed Oct 29, 2013
1 parent f175039 commit d5da298
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 82 deletions.
113 changes: 68 additions & 45 deletions xmlNotes/Aegean.xsd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">

<!-- Definition of simple elements -->
<xs:element name="core" type="xs:string"/>
<!--<xs:element name="core" type="xs:string"/>-->

<!-- Definition of simple types-->

Expand Down Expand Up @@ -39,15 +39,18 @@
<!-- Definition of attributes -->
<xs:attribute name="version" type="xs:string"/>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="width" type="xs:integer"/>
<xs:attribute name="height" type="xs:integer"/>
<xs:attribute name="phits" type="xs:integer"/>
<xs:attribute name="bandwidth" type="xs:integer"/>
<xs:attribute name="node_id" type="xs:string"/>
<xs:attribute name="proc_id" type="xs:integer"/>
<xs:attribute name="width" type="xs:positiveInteger"/>
<xs:attribute name="height" type="xs:positiveInteger"/>
<xs:attribute name="phits" type="xs:nonNegativeInteger"/>
<xs:attribute name="bandwidth" type="xs:nonNegativeInteger"/>
<xs:attribute name="id" type="xs:ID"/>
<xs:attribute name="id_ref" type="xs:IDREF"/>
<xs:attribute name="iptype" type="xs:ID"/>
<xs:attribute name="iptype_ref" type="xs:IDREF"/>
<xs:attribute name="core_id" type="address"/>
<xs:attribute name="cached" type="xs:boolean"/>
<xs:attribute name="routerDepth" type="xs:integer"/>
<xs:attribute name="linkDepth" type="xs:integer"/>
<xs:attribute name="routerDepth" type="xs:nonNegativeInteger"/>
<xs:attribute name="linkDepth" type="xs:nonNegativeInteger"/>

<xs:attribute name="entry_point" type="address"/>
<xs:attribute name="start" type="address"/>
Expand All @@ -65,7 +68,7 @@

<!-- Definition of complex elements -->

<!-- A process of the application -->
<!-- A memory region -->
<xs:element name="mem">
<xs:complexType mixed="true">
<xs:attribute ref="end" use="required"/>
Expand All @@ -74,30 +77,24 @@
</xs:complexType>
</xs:element>

<!-- An entry point for a processor -->

<!-- A process of the application -->
<xs:element name="process">
<xs:complexType>
<xs:attribute ref="proc_id" use="required"/>
<xs:attribute ref="node_id" use="required"/>
</xs:complexType>
</xs:element>

<!-- An entry point for a processor -->
<!-- An entry point for an ipcore -->
<xs:element name="entry">
<xs:complexType>
<xs:attribute ref="node_id" use="required"/>
<xs:attribute ref="entry_point" use="required"/>
<xs:attribute ref="id_ref" use="required"/>
<xs:attribute name="entity" type="xs:string" />
<xs:attribute name="parameters" type="xs:string" />
<xs:attribute name="srcfile" type="xs:anyURI" />
</xs:complexType>
</xs:element>

<!-- The nodes of the platform -->
<xs:element name="node">
<xs:complexType>
<xs:attribute ref="node_id" use="required"/>
<xs:attribute ref="id" use="required"/>
<xs:attribute ref="loc" use="required"/>
<xs:attribute ref="ntype" use="required"/>
<xs:attribute ref="iptype_ref" use="required"/>
<xs:attribute ref="core_id" use="optional"/>
</xs:complexType>
</xs:element>

Expand All @@ -108,7 +105,7 @@
<xs:attribute ref="dest" use="required"/>
<xs:attribute ref="linkDepth" use="required"/>
</xs:complexType>
</xs:element>
</xs:element>

<xs:element name="channel">
<xs:complexType>
Expand All @@ -127,6 +124,43 @@
</xs:complexType>
</xs:element>

<xs:element name="patmos">
<xs:complexType>
<xs:all>
<xs:element name="MCache">
<xs:complexType>
<xs:attribute name="size" type="xs:nonNegativeInteger" use="required" />
<xs:attribute name="blocks" type="xs:nonNegativeInteger" use="required" />
<xs:attribute name="repl" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="DCache">
<xs:complexType>
<xs:attribute name="size" type="xs:nonNegativeInteger" use="required" />
<xs:attribute name="assoc" type="xs:nonNegativeInteger" use="required" />
<xs:attribute name="repl" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="SCache">
<xs:complexType>
<xs:attribute name="size" type="xs:nonNegativeInteger" use="required" />
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>

<xs:element name="ipcore">
<xs:complexType>
<xs:sequence>
<xs:element ref="patmos" maxOccurs="1" minOccurs="0" />
</xs:sequence>
<xs:attribute ref="iptype" use="required" />
<xs:attribute name="entity" type="xs:string" />
<xs:attribute name="srcfile" type="xs:anyURI" />
</xs:complexType>
</xs:element>

<xs:element name="topology">
<xs:complexType>
<xs:sequence>
Expand All @@ -147,10 +181,10 @@
</xs:element>

<!-- A description of the processes -->
<xs:element name="processes">
<xs:element name="ipcores">
<xs:complexType>
<xs:sequence>
<xs:element ref="process" maxOccurs="unbounded"/>
<xs:element ref="ipcore" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Expand All @@ -175,13 +209,13 @@
</xs:complexType>
</xs:element>

<!-- A decription of the hardware platform. -->
<!-- A description of the hardware platform. -->
<xs:element name="platform">
<xs:complexType>
<xs:sequence>
<xs:element ref="nodes"/>
<xs:element ref="topology"/>
<xs:element ref="map"/>
<xs:element ref="nodes"/>
<xs:element ref="ipcores"/>
</xs:sequence>
<xs:attribute ref="name" use="required"/>
<xs:attribute ref="width" use="required"/>
Expand All @@ -193,33 +227,22 @@
<xs:element name="application">
<xs:complexType>
<xs:sequence>
<xs:element ref="processes"/>
<xs:element ref="entries"/>
<xs:element ref="communication"/>
<xs:element ref="map"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<!-- A detaile description of the cores of the platform-->
<xs:element name="cores">
<xs:complexType>
<xs:sequence>
<xs:element ref="core"/>
</xs:sequence>
</xs:complexType>
</xs:element>


<!-- The top-level tag describing the full configuration-->
<xs:element name="configuration">
<xs:element name="aegean">
<xs:complexType>
<xs:sequence>
<xs:element ref="platform"/>
<xs:element ref="application"/>
<xs:element ref="cores"/>
</xs:sequence>
<xs:attribute ref="version" use="required"/>
</xs:complexType>
</xs:element>

</xs:schema>
</xs:schema>
49 changes: 31 additions & 18 deletions xmlNotes/Config_format.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,47 @@
<?xml version="1.0"?>
<configuration version="1.1">
<?xml version="1.0" encoding="utf-8"?>

<aegean version="0.1">

<platform name="Agean" width="2" height="2">
<nodes>
<node node_id="id_t" loc="(0,0)" ntype="patmos"/>
</nodes>

<!-- <topology type="bitorus"/"mesh"/"custom" routerDepth="k" linkDepth="k"> -->
<topology ttype="bitorus" routerDepth="1" linkDepth="0">
<topology ttype="custom" routerDepth="1" linkDepth="0">
<link src="(0,0)" dest="(0,1)" linkDepth="0" />
</topology>
<map>
<mem start="0xfff000" end="0xffff00" cached="false" >Description of the given memory area.</mem>
</map>

<nodes>
<node id="pat0" loc="(0,0)" iptype_ref="patmos_xx" core_id="0x00" />
<node id="hw_acc0" loc="(0,1)" iptype_ref="hw_acc" />
</nodes>

<ipcores>
<ipcore iptype="patmos_xx">
<patmos>
<MCache size="1024" blocks="32" repl="FIFO" />
<DCache size="0" assoc="1" repl="LRU" />
<SCache size="1024" />
</patmos>
</ipcore>
<!-- entity (VHDL term) / module (Verilog term) / component (Chisel) -->
<ipcore iptype="hw_acc" entity="foo" srcfile="file:///test2.vhd" />
</ipcores>

</platform>

<application>
<processes>
<process proc_id="1" node_id="id_t"/>
</processes>

<entries>
<entry node_id="id_t" entry_point="0x000000"/>
<entry id_ref="pat0" entity="main" parameters="0 1" srcfile="file:///test2.c"/>
</entries>

<!-- <communication type="all2all"/"custom" phits="s"> -->
<communication ctype="all2all" phits="1">
<channel from="(0,1)" to="(1,2)" bandwidth="1" phits="1"/>
</communication>

<map>
<mem start="0xfff000" end="0xffff00" cached="false" >Description of the given memory area.</mem>
</map>
</application>

<cores>
<core>
</core>
</cores>
</configuration>
</aegean>
38 changes: 19 additions & 19 deletions xmlNotes/xml_test.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
import sys
from lxml import etree
from io import StringIO
from subprocess import call

#f = open('../Poseidon/Config_format.xml')
#root = etree.XML(f.read())
#root = etree.parse("../Poseidon/Config_format.xml")
print(sys.argv)
root = etree.parse(sys.argv[1])
def parseXML(filename):
tree = etree.parse(filename)
xmlschema_doc = etree.parse("Aegean.xsd")
xmlschema = etree.XMLSchema(xmlschema_doc)
xmlschema.assertValid(tree)
if xmlschema.validate(tree):
return tree

for element in root.iter():
if (element.tag is etree.Comment) or (not element.text) or (not element.text.strip()):
print(element.tag)
else:
print("%s - %s" % (element.tag, element.text))

#tree = parseXML(sys.argv[1])
tree = parseXML("Config_format.xml")
aegean = tree.getroot()

platform = list(aegean)[0]
application = list(aegean)[1]

xmlschema_doc = etree.parse("Aegean.xsd")
xmlschema = etree.XMLSchema(xmlschema_doc)
for element in tree.iter():
if (element.tag is etree.Comment) or (not element.text) or (not element.text.strip()):
print(element.tag)
else:
print("%s - %s" % (element.tag, element.text))

xmlschema.assertValid(root)

#if xmlschema.validate(root):
# print("XML file validated.")
#else:
# print("XML file invalid")
#
call(["ls","-l"])

0 comments on commit d5da298

Please sign in to comment.