Skip to content

Commit d184098

Browse files
authored
v0.6.0
2 parents 6f04444 + 702ecf9 commit d184098

26 files changed

+2215
-357
lines changed

doc/Catalog.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.. _CATALOG:
2+
3+
Catalog
4+
#######
5+
6+
.. attention::
7+
8+
🚧 This implementation is work in progress. 🚧
9+
10+
.. code-block:: python
11+
12+
from pyEDAA.IPXACT.Catalog import Catalog
13+
14+
filePath = Path("Catalog.xml")
15+
catalog = Catalog(filePath, parse=True)

doc/Component.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.. _COMPONENT:
2+
3+
Component
4+
#########
5+
6+
.. attention::
7+
8+
🚧 This implementation is work in progress. 🚧
9+
10+
.. code-block:: python
11+
12+
from pyEDAA.IPXACT.Component import Component
13+
14+
filePath = Path("Catalog.xml")
15+
catalog = Component(filePath, parse=True)
16+
17+
18+
Features
19+
========
20+
21+
* Extract filesets
22+
23+
* Extract files

doc/Design.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.. _DESIGN:
2+
3+
Design
4+
######
5+
6+
.. attention::
7+
8+
🚧 This implementation is work in progress. 🚧
9+
10+
.. code-block:: python
11+
12+
from pyEDAA.IPXACT.Design import Design
13+
14+
filePath = Path("Catalog.xml")
15+
catalog = Design(filePath, parse=True)

doc/FurtherResources.rst

Lines changed: 0 additions & 15 deletions
This file was deleted.

doc/Introduction.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.. _INTRO:
2+
3+
Introduction
4+
############
5+
6+
*pyEDAA.IPXACT* provides a Document Object Model (DOM) for reading and writing IP-XACT XML files.
7+
8+
.. attention::
9+
10+
As IP-XACT defines a gigantic data model, only a portion of this data model is currently implemented. The
11+
implementation focuses on the most valuable parts. Contributions are welcome.
12+
13+
14+
.. _INTRO/History:
15+
16+
History
17+
=======
18+
19+
The beginnings of this EDA² layer were released as :pypi:`pyIPXACT`. The package was then integrated into the EDA² layer
20+
family and renamed to pyEDAA.IPXACT. The embedded XML schema definitions are provided by
21+
`Accellera <https://www.accellera.org/>`__. As these schema files might be interesting for other users too, they have
22+
been extracted and provided in a standalone repository called :gh:`edaa-org/IPXACT-Schema`.
23+
24+
25+
.. _INTRO/Further:
26+
27+
Further Resources
28+
=================
29+
30+
* :pypi:`peakrdl-ipxact`
31+
32+
* :pypi:`ralbot-ipxact` was renamed to *peakrdl-ipxact*.
33+
34+
* :pypi:`ipxact2systemverilog`
35+
* :gh:`iDoka/ipxact-cli-tools`
36+
* :gh:`olofk/ipyxact`
37+
* :gh:`kactus2`
38+
39+
* `research.tuni.fi/system-on-chip/tool <https://research.tuni.fi/system-on-chip/tools/>`__

doc/index.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,10 @@ License
227227
:caption: Main Documentation
228228
:hidden:
229229

230-
Tutorial
231-
FurtherResources
230+
Introduction
231+
Catalog
232+
Component
233+
Design
232234

233235
.. raw:: latex
234236

pyEDAA/IPXACT/Catalog.py

Lines changed: 33 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@
3232
from pathlib import Path
3333
from sys import version_info
3434
from textwrap import dedent
35-
from typing import List, Dict
35+
from typing import List, Dict, Optional as Nullable, ClassVar
3636

37-
from lxml.etree import XMLParser, XML, XMLSchema, ElementTree, QName
37+
from lxml.etree import QName, _Element
3838

3939
from pyTooling.Decorators import export, readonly
4040
from pyTooling.Common import getFullyQualifiedName
4141

42-
from pyEDAA.IPXACT import RootElement, VLNV, IPXACTException, __URI_MAP__, __DEFAULT_SCHEMA__, IPXACTSchema, Element
42+
from pyEDAA.IPXACT import NamedElement, RootElement, VLNV, IPXACTException, __DEFAULT_SCHEMA__, IPXACTSchema, Element
4343
from pyEDAA.IPXACT.Component import Component
4444

4545

4646
@export
47-
class IpxactFile(Element):
47+
class IpxactFile(NamedElement):
4848
"""Represents a IP-XACT file."""
4949

5050
_name: str #: Name
@@ -135,7 +135,8 @@ def ToXml(self, indent: int = 0, schema: IPXACTSchema = __DEFAULT_SCHEMA__):
135135
class Catalog(RootElement):
136136
"""Represents an IP-XACT catalog."""
137137

138-
_description: str
138+
_rootTagName: ClassVar[str] = "catalog"
139+
139140
_abstractionDefinitions: List
140141
_abstractors: List
141142
_busInterfaces: List
@@ -145,10 +146,13 @@ class Catalog(RootElement):
145146
_designs: List
146147
_generatorChains: List
147148

148-
def __init__(self, vlnv: VLNV, description: str):
149-
super().__init__(vlnv)
150-
151-
self._description = description
149+
def __init__(
150+
self,
151+
catalogFile: Nullable[Path] = None,
152+
parse: bool = False,
153+
vlnv: Nullable[VLNV] = None,
154+
description: Nullable[str] = None
155+
):
152156
self._abstractionDefinitions = []
153157
self._abstractors = []
154158
self._busInterfaces = []
@@ -158,73 +162,27 @@ def __init__(self, vlnv: VLNV, description: str):
158162
self._designs = []
159163
self._generatorChains = []
160164

161-
@classmethod
162-
def FromFile(cls, filePath : Path):
163-
"""Constructs an instance of ``Catalog`` from a file."""
164-
165-
if not filePath.exists():
166-
raise IPXACTException(f"IPXACT file '{filePath}' not found.") from FileNotFoundError(str(filePath))
167-
168-
try:
169-
with filePath.open("rb") as fileHandle:
170-
content = fileHandle.read()
171-
except OSError as ex:
172-
raise IPXACTException(f"Couldn't open '{filePath}'.") from ex
173-
174-
xmlParser = XMLParser(remove_blank_text=True, encoding="utf-8")
175-
root = XML(content, parser=xmlParser, base_url=filePath.resolve().as_uri()) # - relative paths are not supported
176-
rootTag = QName(root.tag)
177-
178-
if rootTag.localname != "catalog":
179-
raise IPXACTException("The input IP-XACT file is not a catalog file.")
180-
181-
namespacePrefix = root.prefix
182-
namespaceURI = root.nsmap[namespacePrefix]
183-
if namespaceURI in __URI_MAP__:
184-
ipxactSchema = __URI_MAP__[namespaceURI]
165+
super().__init__(catalogFile, parse, vlnv, description)
166+
167+
def Parse(self, element: _Element) -> None:
168+
elementLocalname = QName(element).localname
169+
if elementLocalname == "catalogs":
170+
for ipxactFileElement in element:
171+
self.AddItem(IpxactFile.FromXml(ipxactFileElement))
172+
elif elementLocalname == "abstractionDefinitions":
173+
pass
174+
elif elementLocalname == "components":
175+
pass
176+
elif elementLocalname == "abstractors":
177+
pass
178+
elif elementLocalname == "designs":
179+
pass
180+
elif elementLocalname == "designConfigurations":
181+
pass
182+
elif elementLocalname == "generatorChains":
183+
pass
185184
else:
186-
raise IPXACTException(f"The input IP-XACT file uses an unsupported namespace: '{namespaceURI}'.")
187-
188-
try:
189-
with ipxactSchema.LocalPath.open("rb") as fileHandle:
190-
schema = fileHandle.read()
191-
except OSError as ex:
192-
raise IPXACTException(f"Couldn't open IP-XACT schema '{ipxactSchema.LocalPath}' for {namespacePrefix} ({namespaceURI}).") from ex
193-
194-
schemaRoot = XML(schema, parser=xmlParser, base_url=ipxactSchema.LocalPath.as_uri())
195-
schemaTree = ElementTree(schemaRoot)
196-
xmlSchema = XMLSchema(schemaTree)
197-
198-
try:
199-
xmlSchema.assertValid(root)
200-
except Exception as ex:
201-
raise IPXACTException("The input IP-XACT file is not valid.") from ex
202-
203-
items = []
204-
for rootElements in root:
205-
element = QName(rootElements)
206-
if element.localname == "vendor":
207-
vendor = rootElements.text
208-
elif element.localname == "library":
209-
library = rootElements.text
210-
elif element.localname == "name":
211-
name = rootElements.text
212-
elif element.localname == "version":
213-
version = rootElements.text
214-
elif element.localname == "description":
215-
description = rootElements.text
216-
elif element.localname == "catalogs":
217-
for ipxactFileElement in rootElements:
218-
items.append(IpxactFile.FromXml(ipxactFileElement))
219-
else:
220-
raise IPXACTException(f"Unsupported tag '{element.localname}' at root-level.")
221-
222-
vlnv = VLNV(vendor=vendor, library=library, name=name, version=version)
223-
catalog = cls(vlnv, description=description)
224-
for item in items:
225-
catalog.AddItem(item)
226-
227-
return catalog
185+
raise IPXACTException(f"Unsupported tag '{elementLocalname}' at root-level.")
228186

229187
def AddItem(self, item) -> None:
230188
if isinstance(item, IpxactFile):

0 commit comments

Comments
 (0)