xactflow-component 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- xactflow_component-0.1.0/LICENSE +164 -0
- xactflow_component-0.1.0/PKG-INFO +167 -0
- xactflow_component-0.1.0/README.md +138 -0
- xactflow_component-0.1.0/pyproject.toml +57 -0
- xactflow_component-0.1.0/setup.cfg +4 -0
- xactflow_component-0.1.0/src/xactflow_component/__init__.py +38 -0
- xactflow_component-0.1.0/src/xactflow_component/businterface_writer.py +202 -0
- xactflow_component-0.1.0/src/xactflow_component/common_writer.py +476 -0
- xactflow_component-0.1.0/src/xactflow_component/component_sections_writer.py +164 -0
- xactflow_component-0.1.0/src/xactflow_component/component_writer.py +83 -0
- xactflow_component-0.1.0/src/xactflow_component/memorymap_writer.py +361 -0
- xactflow_component-0.1.0/src/xactflow_component/model_writer.py +93 -0
- xactflow_component-0.1.0/src/xactflow_component/ports_writer.py +198 -0
- xactflow_component-0.1.0/src/xactflow_component/py.typed +0 -0
- xactflow_component-0.1.0/src/xactflow_component.egg-info/PKG-INFO +167 -0
- xactflow_component-0.1.0/src/xactflow_component.egg-info/SOURCES.txt +21 -0
- xactflow_component-0.1.0/src/xactflow_component.egg-info/dependency_links.txt +1 -0
- xactflow_component-0.1.0/src/xactflow_component.egg-info/entry_points.txt +2 -0
- xactflow_component-0.1.0/src/xactflow_component.egg-info/requires.txt +6 -0
- xactflow_component-0.1.0/src/xactflow_component.egg-info/top_level.txt +1 -0
- xactflow_component-0.1.0/tests/test_component_writer.py +148 -0
- xactflow_component-0.1.0/tests/test_exporter.py +40 -0
- xactflow_component-0.1.0/tests/test_validation_errors.py +221 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
This version of the GNU Lesser General Public License incorporates
|
|
9
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
10
|
+
License, supplemented by the additional permissions listed below.
|
|
11
|
+
|
|
12
|
+
0. Additional Definitions.
|
|
13
|
+
|
|
14
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
15
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
16
|
+
General Public License.
|
|
17
|
+
|
|
18
|
+
"The Library" refers to a covered work governed by this License,
|
|
19
|
+
other than an Application or a Combined Work as defined below.
|
|
20
|
+
|
|
21
|
+
An "Application" is any work that makes use of an interface provided
|
|
22
|
+
by the Library, but which is not otherwise based on the Library.
|
|
23
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
24
|
+
of using an interface provided by the Library.
|
|
25
|
+
|
|
26
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
27
|
+
Application with the Library. The particular version of the Library
|
|
28
|
+
with which the Combined Work was made is also called the "Linked
|
|
29
|
+
Version".
|
|
30
|
+
|
|
31
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
32
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
33
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
34
|
+
based on the Application, and not on the Linked Version.
|
|
35
|
+
|
|
36
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
37
|
+
object code and/or source code for the Application, including any data
|
|
38
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
39
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
40
|
+
|
|
41
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
42
|
+
|
|
43
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
44
|
+
without being bound by section 3 of the GNU GPL.
|
|
45
|
+
|
|
46
|
+
2. Conveying Modified Versions.
|
|
47
|
+
|
|
48
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
49
|
+
facility refers to a function or data to be supplied by an Application
|
|
50
|
+
that uses the facility (other than as an argument passed when the
|
|
51
|
+
facility is invoked), then you may convey a copy of the modified
|
|
52
|
+
version:
|
|
53
|
+
|
|
54
|
+
a) under this License, provided that you make a good faith effort to
|
|
55
|
+
ensure that, in the event an Application does not supply the
|
|
56
|
+
function or data, the facility still operates, and performs
|
|
57
|
+
whatever part of its purpose remains meaningful, or
|
|
58
|
+
|
|
59
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
60
|
+
this License applicable to that copy.
|
|
61
|
+
|
|
62
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
63
|
+
|
|
64
|
+
The object code form of an Application may incorporate material from
|
|
65
|
+
a header file that is part of the Library. You may convey such object
|
|
66
|
+
code under terms of your choice, provided that, if the incorporated
|
|
67
|
+
material is not limited to numerical parameters, data structure
|
|
68
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
69
|
+
(ten or fewer lines in length), you do both of the following:
|
|
70
|
+
|
|
71
|
+
a) Give prominent notice with each copy of the object code that the
|
|
72
|
+
Library is used in it and that the Library and its use are
|
|
73
|
+
covered by this License.
|
|
74
|
+
|
|
75
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
76
|
+
document.
|
|
77
|
+
|
|
78
|
+
4. Combined Works.
|
|
79
|
+
|
|
80
|
+
You may convey a Combined Work under terms of your choice that,
|
|
81
|
+
taken together, effectively do not restrict modification of the
|
|
82
|
+
portions of the Library contained in the Combined Work and reverse
|
|
83
|
+
engineering for debugging such modifications, if you also do each of
|
|
84
|
+
the following:
|
|
85
|
+
|
|
86
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
87
|
+
the Library is used in it and that the Library and its use are
|
|
88
|
+
covered by this License.
|
|
89
|
+
|
|
90
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
91
|
+
document.
|
|
92
|
+
|
|
93
|
+
c) For a Combined Work that displays copyright notices during
|
|
94
|
+
execution, include the copyright notice for the Library among
|
|
95
|
+
these notices, as well as a reference directing the user to the
|
|
96
|
+
copies of the GNU GPL and this license document.
|
|
97
|
+
|
|
98
|
+
d) Do one of the following:
|
|
99
|
+
|
|
100
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
101
|
+
License, and the Corresponding Application Code in a form
|
|
102
|
+
suitable for, and under terms that permit, the user to
|
|
103
|
+
recombine or relink the Application with a modified version of
|
|
104
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
105
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
106
|
+
Corresponding Source.
|
|
107
|
+
|
|
108
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
109
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
110
|
+
a copy of the Library already present on the user's computer
|
|
111
|
+
system, and (b) will operate properly with a modified version
|
|
112
|
+
of the Library that is interface-compatible with the Linked
|
|
113
|
+
Version.
|
|
114
|
+
|
|
115
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
116
|
+
be required to provide such information under section 6 of the
|
|
117
|
+
GNU GPL, and only to the extent that such information is
|
|
118
|
+
necessary to install and execute a modified version of the
|
|
119
|
+
Combined Work produced by recombining or relinking the
|
|
120
|
+
Application with a modified version of the Linked Version. (If
|
|
121
|
+
you use option 4d0, the Installation Information must accompany
|
|
122
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
123
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
124
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
125
|
+
for conveying Corresponding Source.)
|
|
126
|
+
|
|
127
|
+
5. Combined Libraries.
|
|
128
|
+
|
|
129
|
+
You may place library facilities that are a work based on the
|
|
130
|
+
Library side by side in a single library together with other library
|
|
131
|
+
facilities that are not Applications and are not covered by this
|
|
132
|
+
License, and convey such a combined library under terms of your
|
|
133
|
+
choice, if you do both of the following:
|
|
134
|
+
|
|
135
|
+
a) Accompany the combined library with a copy of the same work based
|
|
136
|
+
on the Library, uncombined with any other library facilities,
|
|
137
|
+
conveyed under the terms of this License.
|
|
138
|
+
|
|
139
|
+
b) Give prominent notice with the combined library that part of it
|
|
140
|
+
is a work based on the Library, and explaining where to find the
|
|
141
|
+
accompanying uncombined form of the same work.
|
|
142
|
+
|
|
143
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
144
|
+
|
|
145
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
146
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
147
|
+
versions will be similar in spirit to the present version, but may
|
|
148
|
+
differ in detail to address new problems or concerns.
|
|
149
|
+
|
|
150
|
+
Each version is given a distinguishing version number. If the
|
|
151
|
+
Library as you received it specifies that a certain numbered version
|
|
152
|
+
of the GNU Lesser General Public License "or any later version"
|
|
153
|
+
applies to it, you have the option of following the terms and
|
|
154
|
+
conditions either of that published version or of any later version
|
|
155
|
+
published by the Free Software Foundation. If the Library as you
|
|
156
|
+
received it does not specify a version number of the GNU Lesser
|
|
157
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
158
|
+
General Public License ever published by the Free Software Foundation.
|
|
159
|
+
|
|
160
|
+
If the Library as you received it specifies that a proxy can decide
|
|
161
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
162
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
163
|
+
permanent authorization for you to choose that version for the
|
|
164
|
+
Library.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: xactflow-component
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: XactFlow exporter plugin that serializes an ipxact.Component into IEEE 1685-2022 IP-XACT XML.
|
|
5
|
+
Author: Maxime Travaillard
|
|
6
|
+
License-Expression: LGPL-3.0-only
|
|
7
|
+
Project-URL: Repository, https://github.com/IP-XACT/XactFlow-component
|
|
8
|
+
Project-URL: Issues, https://github.com/IP-XACT/XactFlow-component/issues
|
|
9
|
+
Keywords: IP-XACT,IEEE 1685,XML,Compiler,XactFlow,Component
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: xactflow
|
|
24
|
+
Requires-Dist: ipxact-compiler
|
|
25
|
+
Requires-Dist: lxml
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest; extra == "dev"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# xactflow-component
|
|
31
|
+
|
|
32
|
+
A [XactFlow](https://github.com/IP-XACT/XactFlow) exporter plugin that serializes an
|
|
33
|
+
`ipxact.Component` object into a valid [IEEE 1685-2022](https://standards.ieee.org/ieee/1685/10307/)
|
|
34
|
+
IP-XACT `component` XML document.
|
|
35
|
+
|
|
36
|
+
[`ipxact-compiler`](https://github.com/IP-XACT/ipxact-compiler) reads IP-XACT XML and hands back
|
|
37
|
+
Python objects, it never writes XML. This package is the other direction: given a `Component`,
|
|
38
|
+
it writes the XML back out.
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install xactflow-component
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
For local development, `requirements-dev.txt` overrides `ipxact-compiler` and `xactflow` to
|
|
47
|
+
local installations. It can be modified to adapt the paths or to keep either version on PyPI.
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install -r requirements-dev.txt -e .
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Requires Python >= 3.9.
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from pathlib import Path
|
|
59
|
+
|
|
60
|
+
import ipxact
|
|
61
|
+
from xactflow_component import ComponentExporter
|
|
62
|
+
|
|
63
|
+
component = ipxact.parse_file("apb_uart.xml") # or get one from an importer
|
|
64
|
+
ComponentExporter().export(component, Path("out"))
|
|
65
|
+
# writes out/apb_uart.xml
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The output file is named after the component's VLNV name (`<vlnv.name>.xml`) inside `output_dir`,
|
|
69
|
+
which is created if it does not exist.
|
|
70
|
+
|
|
71
|
+
Lower-level entry points are available for callers that want the tree or the bytes rather than a
|
|
72
|
+
file:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from xactflow_component import component_to_bytes, write_component, write_component_file
|
|
76
|
+
|
|
77
|
+
element = write_component(component) # the lxml ipxact:component root element
|
|
78
|
+
data = component_to_bytes(component) # pretty-printed bytes, with an XML declaration
|
|
79
|
+
path = write_component_file(component, "out.xml") # writes and returns the path
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Once installed, the exporter registers itself under the `xactflow.exporters` entry point group as
|
|
83
|
+
`component`, so `xactflow component ...` becomes available as a XactFlow CLI subcommand. Note that
|
|
84
|
+
XactFlow's CLI always elaborates a design before calling an exporter, so for now the way to use
|
|
85
|
+
this package is to call `ComponentExporter().export(...)` directly on a `Component`.
|
|
86
|
+
|
|
87
|
+
`export()` raises `TypeError` for anything that is not an `ipxact.Component`. Accepting an
|
|
88
|
+
`ElaboratedDesign` (flattening a resolved multi-instance design into one boundary component) is a
|
|
89
|
+
planned later addition, not an oversight.
|
|
90
|
+
|
|
91
|
+
## Design notes
|
|
92
|
+
|
|
93
|
+
- **Element order comes from the XSD, not from the dataclasses.** `componentType`'s sequence puts
|
|
94
|
+
`displayName`/`shortDescription`/`description` right after the VLNV and `typeDefinitions`/
|
|
95
|
+
`powerDomains` before `busInterfaces`, while the `Component` dataclass declares those fields
|
|
96
|
+
last. The same mismatch repeats in almost every nested type, because IP-XACT's `nameGroup` opens
|
|
97
|
+
an element while the corresponding Python fields are trailing optionals. Every writer here
|
|
98
|
+
follows the schema.
|
|
99
|
+
- **Expressions are written verbatim.** Anything typed `Expression` in `ipxact-compiler`
|
|
100
|
+
(`addressOffset`, `size`, `range`, `width`, `bitOffset`, `bitWidth`, ...) is a raw string and is
|
|
101
|
+
emitted unchanged, never evaluated or reformatted.
|
|
102
|
+
- **Vendor extensions stay identical.** Their content is not IP-XACT's to define, so each
|
|
103
|
+
fragment is re-inserted as parsed.
|
|
104
|
+
- **No `xsi:schemaLocation`.** The root element declares only the IP-XACT namespace, matching the
|
|
105
|
+
fixtures in `ipxact-compiler`. A document is identified by its namespace and root element, and a
|
|
106
|
+
hard-coded schema location would point at a path that does not exist on the reader's machine.
|
|
107
|
+
- **Defaults are omitted.** Attributes and elements whose value equals the schema default
|
|
108
|
+
(`resolve="immediate"`, `type="string"`, `misalignmentAllowed="true"`, `connectionRequired`
|
|
109
|
+
false, and so on) are left out, which keeps the output close to hand-written IP-XACT and still
|
|
110
|
+
round-trips exactly.
|
|
111
|
+
- **Required XSD choices raise `ValueError` when no arm is set, instead of emitting invalid
|
|
112
|
+
XML.** Several dataclasses share one field across XSD contexts with different required-ness,
|
|
113
|
+
or expose independent sibling fields that the schema only allows together. Rather than silently
|
|
114
|
+
writing an incomplete element for these, the writer raises a specific error naming the missing
|
|
115
|
+
field.
|
|
116
|
+
|
|
117
|
+
## Known gaps
|
|
118
|
+
|
|
119
|
+
These come from constructs the IEEE 1685-2022 schema requires but `ipxact-compiler`'s object model
|
|
120
|
+
deliberately does not carry. Such a component still round-trips through this writer and back
|
|
121
|
+
through the parser unchanged, but the XML it produces will not satisfy the XSD:
|
|
122
|
+
|
|
123
|
+
- **Banks have no `baseAddress`.** `ipxact.Bank` does not model one, while the schema's
|
|
124
|
+
`addressBankType` (a bank directly inside a `memoryMap`, `memoryRemap` or `localMemoryMap`)
|
|
125
|
+
requires it. Banks nested inside another bank are unaffected.
|
|
126
|
+
- **Structured ports have no `structPortTypeDefs`.** `ipxact.StructuredPort` leaves out the
|
|
127
|
+
language-specific type bindings that `portStructuredType` requires.
|
|
128
|
+
- **`externalTypeDefinitions` has an optional name.** The schema's `nameGroup` requires one.
|
|
129
|
+
- **`File.dependencies` is write-only.** `ipxact-compiler`'s `parse_file` does not read `dependency`
|
|
130
|
+
children of a `file` back, so setting them means the value is written but does not survive a
|
|
131
|
+
re-parse. (`FileSet.dependencies` round-trips normally.)
|
|
132
|
+
- **`MemoryArray.stride` on a register or register file is write-only.** This writer emits
|
|
133
|
+
`ipxact:stride` correctly, but `ipxact-compiler` reads it with a truth test on the element, which
|
|
134
|
+
is false for a childless element, so the value comes back as `None`. `bitStride` on a field is
|
|
135
|
+
unaffected.
|
|
136
|
+
|
|
137
|
+
The writer also does not invent content the object model leaves out, so a `Component` that is
|
|
138
|
+
under-specified relative to the schema produces XML that says so: a `register` with no fields, a
|
|
139
|
+
`memoryRemap` with no `modeRef`, a `channel` with fewer than two `busInterfaceRef`s, a `file` with
|
|
140
|
+
no `fileType`, or a `componentGenerator` with more than one `transportMethod` will each fail
|
|
141
|
+
validation rather than being silently patched up. Validating the output against `component.xsd` is
|
|
142
|
+
the way to catch that.
|
|
143
|
+
|
|
144
|
+
Other deliberate simplifications, all inherited from `ipxact-compiler`'s object model, so there is
|
|
145
|
+
nothing to write: `accessHandles`, `executableImage`, `powerConstraints`, `wireTypeDefs`/
|
|
146
|
+
`domainTypeDefs`/`signalTypeDefs`/`transTypeDefs`, `portPackets`, a port's `arrays`/`access`, a
|
|
147
|
+
`portMap`'s logical `range` and physical `partSelect`/`subPort`, `clearboxElementRefs`,
|
|
148
|
+
`fileSet/function`, a `file`'s `define`/`imageType`/`targetName`, `viewLinks`/`modeLinks`/
|
|
149
|
+
`resetTypeLinks`, a field's `aliasOf` alternative, and the `*DefinitionRef` type-definition
|
|
150
|
+
indirection on memory map elements.
|
|
151
|
+
|
|
152
|
+
## Development
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
pip install -r requirements-dev.txt -e .
|
|
156
|
+
pytest
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
The tests round-trip both `ipxact-compiler`'s `apb_uart.xml` fixture and hand-built components
|
|
160
|
+
through the writer and back through the parser, validate the written XML against `component.xsd`
|
|
161
|
+
with `lxml.etree.XMLSchema.assertValid`, and re-run `xactflow.SCR.run_single_doc_checks` on the
|
|
162
|
+
result. They expect `ipxact-compiler` and the IEEE 1685-2022 schema (`IEEE_1685-2022/schema/
|
|
163
|
+
1685-2022/`) as sibling checkouts; set `IPXACT_SCHEMA_DIR` to point the schema somewhere else.
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
LGPL-3.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# xactflow-component
|
|
2
|
+
|
|
3
|
+
A [XactFlow](https://github.com/IP-XACT/XactFlow) exporter plugin that serializes an
|
|
4
|
+
`ipxact.Component` object into a valid [IEEE 1685-2022](https://standards.ieee.org/ieee/1685/10307/)
|
|
5
|
+
IP-XACT `component` XML document.
|
|
6
|
+
|
|
7
|
+
[`ipxact-compiler`](https://github.com/IP-XACT/ipxact-compiler) reads IP-XACT XML and hands back
|
|
8
|
+
Python objects, it never writes XML. This package is the other direction: given a `Component`,
|
|
9
|
+
it writes the XML back out.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install xactflow-component
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
For local development, `requirements-dev.txt` overrides `ipxact-compiler` and `xactflow` to
|
|
18
|
+
local installations. It can be modified to adapt the paths or to keep either version on PyPI.
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install -r requirements-dev.txt -e .
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Requires Python >= 3.9.
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from pathlib import Path
|
|
30
|
+
|
|
31
|
+
import ipxact
|
|
32
|
+
from xactflow_component import ComponentExporter
|
|
33
|
+
|
|
34
|
+
component = ipxact.parse_file("apb_uart.xml") # or get one from an importer
|
|
35
|
+
ComponentExporter().export(component, Path("out"))
|
|
36
|
+
# writes out/apb_uart.xml
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The output file is named after the component's VLNV name (`<vlnv.name>.xml`) inside `output_dir`,
|
|
40
|
+
which is created if it does not exist.
|
|
41
|
+
|
|
42
|
+
Lower-level entry points are available for callers that want the tree or the bytes rather than a
|
|
43
|
+
file:
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from xactflow_component import component_to_bytes, write_component, write_component_file
|
|
47
|
+
|
|
48
|
+
element = write_component(component) # the lxml ipxact:component root element
|
|
49
|
+
data = component_to_bytes(component) # pretty-printed bytes, with an XML declaration
|
|
50
|
+
path = write_component_file(component, "out.xml") # writes and returns the path
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Once installed, the exporter registers itself under the `xactflow.exporters` entry point group as
|
|
54
|
+
`component`, so `xactflow component ...` becomes available as a XactFlow CLI subcommand. Note that
|
|
55
|
+
XactFlow's CLI always elaborates a design before calling an exporter, so for now the way to use
|
|
56
|
+
this package is to call `ComponentExporter().export(...)` directly on a `Component`.
|
|
57
|
+
|
|
58
|
+
`export()` raises `TypeError` for anything that is not an `ipxact.Component`. Accepting an
|
|
59
|
+
`ElaboratedDesign` (flattening a resolved multi-instance design into one boundary component) is a
|
|
60
|
+
planned later addition, not an oversight.
|
|
61
|
+
|
|
62
|
+
## Design notes
|
|
63
|
+
|
|
64
|
+
- **Element order comes from the XSD, not from the dataclasses.** `componentType`'s sequence puts
|
|
65
|
+
`displayName`/`shortDescription`/`description` right after the VLNV and `typeDefinitions`/
|
|
66
|
+
`powerDomains` before `busInterfaces`, while the `Component` dataclass declares those fields
|
|
67
|
+
last. The same mismatch repeats in almost every nested type, because IP-XACT's `nameGroup` opens
|
|
68
|
+
an element while the corresponding Python fields are trailing optionals. Every writer here
|
|
69
|
+
follows the schema.
|
|
70
|
+
- **Expressions are written verbatim.** Anything typed `Expression` in `ipxact-compiler`
|
|
71
|
+
(`addressOffset`, `size`, `range`, `width`, `bitOffset`, `bitWidth`, ...) is a raw string and is
|
|
72
|
+
emitted unchanged, never evaluated or reformatted.
|
|
73
|
+
- **Vendor extensions stay identical.** Their content is not IP-XACT's to define, so each
|
|
74
|
+
fragment is re-inserted as parsed.
|
|
75
|
+
- **No `xsi:schemaLocation`.** The root element declares only the IP-XACT namespace, matching the
|
|
76
|
+
fixtures in `ipxact-compiler`. A document is identified by its namespace and root element, and a
|
|
77
|
+
hard-coded schema location would point at a path that does not exist on the reader's machine.
|
|
78
|
+
- **Defaults are omitted.** Attributes and elements whose value equals the schema default
|
|
79
|
+
(`resolve="immediate"`, `type="string"`, `misalignmentAllowed="true"`, `connectionRequired`
|
|
80
|
+
false, and so on) are left out, which keeps the output close to hand-written IP-XACT and still
|
|
81
|
+
round-trips exactly.
|
|
82
|
+
- **Required XSD choices raise `ValueError` when no arm is set, instead of emitting invalid
|
|
83
|
+
XML.** Several dataclasses share one field across XSD contexts with different required-ness,
|
|
84
|
+
or expose independent sibling fields that the schema only allows together. Rather than silently
|
|
85
|
+
writing an incomplete element for these, the writer raises a specific error naming the missing
|
|
86
|
+
field.
|
|
87
|
+
|
|
88
|
+
## Known gaps
|
|
89
|
+
|
|
90
|
+
These come from constructs the IEEE 1685-2022 schema requires but `ipxact-compiler`'s object model
|
|
91
|
+
deliberately does not carry. Such a component still round-trips through this writer and back
|
|
92
|
+
through the parser unchanged, but the XML it produces will not satisfy the XSD:
|
|
93
|
+
|
|
94
|
+
- **Banks have no `baseAddress`.** `ipxact.Bank` does not model one, while the schema's
|
|
95
|
+
`addressBankType` (a bank directly inside a `memoryMap`, `memoryRemap` or `localMemoryMap`)
|
|
96
|
+
requires it. Banks nested inside another bank are unaffected.
|
|
97
|
+
- **Structured ports have no `structPortTypeDefs`.** `ipxact.StructuredPort` leaves out the
|
|
98
|
+
language-specific type bindings that `portStructuredType` requires.
|
|
99
|
+
- **`externalTypeDefinitions` has an optional name.** The schema's `nameGroup` requires one.
|
|
100
|
+
- **`File.dependencies` is write-only.** `ipxact-compiler`'s `parse_file` does not read `dependency`
|
|
101
|
+
children of a `file` back, so setting them means the value is written but does not survive a
|
|
102
|
+
re-parse. (`FileSet.dependencies` round-trips normally.)
|
|
103
|
+
- **`MemoryArray.stride` on a register or register file is write-only.** This writer emits
|
|
104
|
+
`ipxact:stride` correctly, but `ipxact-compiler` reads it with a truth test on the element, which
|
|
105
|
+
is false for a childless element, so the value comes back as `None`. `bitStride` on a field is
|
|
106
|
+
unaffected.
|
|
107
|
+
|
|
108
|
+
The writer also does not invent content the object model leaves out, so a `Component` that is
|
|
109
|
+
under-specified relative to the schema produces XML that says so: a `register` with no fields, a
|
|
110
|
+
`memoryRemap` with no `modeRef`, a `channel` with fewer than two `busInterfaceRef`s, a `file` with
|
|
111
|
+
no `fileType`, or a `componentGenerator` with more than one `transportMethod` will each fail
|
|
112
|
+
validation rather than being silently patched up. Validating the output against `component.xsd` is
|
|
113
|
+
the way to catch that.
|
|
114
|
+
|
|
115
|
+
Other deliberate simplifications, all inherited from `ipxact-compiler`'s object model, so there is
|
|
116
|
+
nothing to write: `accessHandles`, `executableImage`, `powerConstraints`, `wireTypeDefs`/
|
|
117
|
+
`domainTypeDefs`/`signalTypeDefs`/`transTypeDefs`, `portPackets`, a port's `arrays`/`access`, a
|
|
118
|
+
`portMap`'s logical `range` and physical `partSelect`/`subPort`, `clearboxElementRefs`,
|
|
119
|
+
`fileSet/function`, a `file`'s `define`/`imageType`/`targetName`, `viewLinks`/`modeLinks`/
|
|
120
|
+
`resetTypeLinks`, a field's `aliasOf` alternative, and the `*DefinitionRef` type-definition
|
|
121
|
+
indirection on memory map elements.
|
|
122
|
+
|
|
123
|
+
## Development
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pip install -r requirements-dev.txt -e .
|
|
127
|
+
pytest
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The tests round-trip both `ipxact-compiler`'s `apb_uart.xml` fixture and hand-built components
|
|
131
|
+
through the writer and back through the parser, validate the written XML against `component.xsd`
|
|
132
|
+
with `lxml.etree.XMLSchema.assertValid`, and re-run `xactflow.SCR.run_single_doc_checks` on the
|
|
133
|
+
result. They expect `ipxact-compiler` and the IEEE 1685-2022 schema (`IEEE_1685-2022/schema/
|
|
134
|
+
1685-2022/`) as sibling checkouts; set `IPXACT_SCHEMA_DIR` to point the schema somewhere else.
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
LGPL-3.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "xactflow-component"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "XactFlow exporter plugin that serializes an ipxact.Component into IEEE 1685-2022 IP-XACT XML."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "LGPL-3.0-only"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Maxime Travaillard"},
|
|
14
|
+
]
|
|
15
|
+
requires-python = ">=3.9"
|
|
16
|
+
dependencies = [
|
|
17
|
+
"xactflow",
|
|
18
|
+
"ipxact-compiler",
|
|
19
|
+
"lxml",
|
|
20
|
+
]
|
|
21
|
+
keywords = [
|
|
22
|
+
"IP-XACT", "IEEE 1685", "XML", "Compiler",
|
|
23
|
+
"XactFlow", "Component",
|
|
24
|
+
]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Development Status :: 3 - Alpha",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
29
|
+
"Programming Language :: Python :: 3.9",
|
|
30
|
+
"Programming Language :: Python :: 3.10",
|
|
31
|
+
"Programming Language :: Python :: 3.11",
|
|
32
|
+
"Programming Language :: Python :: 3.12",
|
|
33
|
+
"Programming Language :: Python :: 3.13",
|
|
34
|
+
"Programming Language :: Python :: 3.14",
|
|
35
|
+
"Topic :: Scientific/Engineering",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Repository = "https://github.com/IP-XACT/XactFlow-component"
|
|
40
|
+
Issues = "https://github.com/IP-XACT/XactFlow-component/issues"
|
|
41
|
+
|
|
42
|
+
[project.optional-dependencies]
|
|
43
|
+
dev = [
|
|
44
|
+
"pytest",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[project.entry-points."xactflow.exporters"]
|
|
48
|
+
component = "xactflow_component:ComponentExporter"
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.dynamic]
|
|
51
|
+
version = {attr = "xactflow_component.__version__"}
|
|
52
|
+
|
|
53
|
+
[tool.setuptools.packages.find]
|
|
54
|
+
where = ["src"]
|
|
55
|
+
|
|
56
|
+
[tool.setuptools.package-data]
|
|
57
|
+
xactflow_component = ["py.typed"]
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
__version__ = "0.1.0"
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import ipxact
|
|
8
|
+
from xactflow import Exporter
|
|
9
|
+
|
|
10
|
+
from .component_writer import component_to_bytes, write_component, write_component_file
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"ComponentExporter",
|
|
14
|
+
"__version__",
|
|
15
|
+
"component_to_bytes",
|
|
16
|
+
"write_component",
|
|
17
|
+
"write_component_file",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ComponentExporter(Exporter):
|
|
22
|
+
"""Serialize an ipxact.Component into an IEEE 1685-2022 IP-XACT component XML file.
|
|
23
|
+
|
|
24
|
+
The output file is named after the component's VLNV name into output_dir.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
name = "component"
|
|
28
|
+
|
|
29
|
+
def export(self, subject: object, output_dir: Path, **options: object) -> None:
|
|
30
|
+
if not isinstance(subject, ipxact.Component):
|
|
31
|
+
# ElaboratedDesign support (flattening a resolved multi-instance design into one
|
|
32
|
+
# boundary Component) is an agreed-on later addition.
|
|
33
|
+
raise TypeError(
|
|
34
|
+
f"xactflow-component only supports ipxact.Component, got {type(subject).__name__}"
|
|
35
|
+
)
|
|
36
|
+
output_dir = Path(output_dir)
|
|
37
|
+
output_dir.mkdir(parents=True, exist_ok=True)
|
|
38
|
+
write_component_file(subject, output_dir / f"{subject.vlnv.name}.xml")
|