xactflow-archidesc 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_archidesc-0.1.0/LICENSE +164 -0
- xactflow_archidesc-0.1.0/PKG-INFO +186 -0
- xactflow_archidesc-0.1.0/README.md +157 -0
- xactflow_archidesc-0.1.0/pyproject.toml +58 -0
- xactflow_archidesc-0.1.0/setup.cfg +4 -0
- xactflow_archidesc-0.1.0/src/xactflow_archidesc/__init__.py +44 -0
- xactflow_archidesc-0.1.0/src/xactflow_archidesc/design.py +474 -0
- xactflow_archidesc-0.1.0/src/xactflow_archidesc/py.typed +0 -0
- xactflow_archidesc-0.1.0/src/xactflow_archidesc.egg-info/PKG-INFO +186 -0
- xactflow_archidesc-0.1.0/src/xactflow_archidesc.egg-info/SOURCES.txt +19 -0
- xactflow_archidesc-0.1.0/src/xactflow_archidesc.egg-info/dependency_links.txt +1 -0
- xactflow_archidesc-0.1.0/src/xactflow_archidesc.egg-info/entry_points.txt +2 -0
- xactflow_archidesc-0.1.0/src/xactflow_archidesc.egg-info/requires.txt +6 -0
- xactflow_archidesc-0.1.0/src/xactflow_archidesc.egg-info/top_level.txt +1 -0
- xactflow_archidesc-0.1.0/tests/test_add_ip.py +133 -0
- xactflow_archidesc-0.1.0/tests/test_connect.py +94 -0
- xactflow_archidesc-0.1.0/tests/test_connect_bus.py +160 -0
- xactflow_archidesc-0.1.0/tests/test_end_to_end.py +53 -0
- xactflow_archidesc-0.1.0/tests/test_fixtures.py +3 -0
- xactflow_archidesc-0.1.0/tests/test_importer.py +75 -0
- xactflow_archidesc-0.1.0/tests/test_ipinstance.py +48 -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,186 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: xactflow-archidesc
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: XactFlow importer plugin that serializes an architecture description into an ipxact.Design.
|
|
5
|
+
Author: Maxime Travaillard
|
|
6
|
+
License-Expression: LGPL-3.0-only
|
|
7
|
+
Project-URL: Repository, https://github.com/IP-XACT/XactFlow-archidesc
|
|
8
|
+
Project-URL: Issues, https://github.com/IP-XACT/XactFlow-archidesc/issues
|
|
9
|
+
Keywords: IP-XACT,IEEE 1685,XML,Compiler,XactFlow,Architecture,Design,Importer
|
|
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
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest; extra == "dev"
|
|
27
|
+
Requires-Dist: xactflow-design; extra == "dev"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# xactflow-archidesc
|
|
31
|
+
|
|
32
|
+
A [XactFlow](https://github.com/IP-XACT/XactFlow) importer plugin that turns a design described
|
|
33
|
+
in a Python script (which IPs it uses, and how they are connected) into an `ipxact.Design` object,
|
|
34
|
+
built on [`ipxact-compiler`](https://github.com/IP-XACT/ipxact-compiler)'s
|
|
35
|
+
[IEEE 1685-2022](https://standards.ieee.org/ieee/1685/10307/) object model.
|
|
36
|
+
|
|
37
|
+
IP-XACT `design` files are not made to be handwritten. With this package, a short script lists
|
|
38
|
+
the IP instances, the bus connections between them, and any direct signal connections. The
|
|
39
|
+
importer runs the script and returns the `Design`, which XactFlow's `elaborate()` can then check
|
|
40
|
+
against the IP-XACT rules.
|
|
41
|
+
|
|
42
|
+
The full description of the format is in
|
|
43
|
+
[`doc/python-design-description.md`](doc/python-design-description.md). It describes the tool
|
|
44
|
+
as it is meant to work once finished, so the current version can differ from it in small ways.
|
|
45
|
+
The differences known today are listed in [Known limitations](#known-limitations).
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install xactflow-archidesc
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For local development, `requirements-dev.txt` overrides `ipxact-compiler`, `xactflow` and
|
|
54
|
+
`xactflow-design` to local installations. It can be modified to adapt the paths or to keep any
|
|
55
|
+
of them on PyPI.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install -r requirements-dev.txt -e .
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Requires Python >= 3.9.
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
A design script builds a `Design` from an IP library and keeps it in a module-level variable
|
|
66
|
+
named `design`:
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from pathlib import Path
|
|
70
|
+
|
|
71
|
+
from xactflow import Library
|
|
72
|
+
from xactflow_archidesc import Design
|
|
73
|
+
|
|
74
|
+
library = Library.scan(Path(__file__).parent / "ip")
|
|
75
|
+
design = Design("example.org:soc:example:0.1", library)
|
|
76
|
+
|
|
77
|
+
cpu = design.add_ip("cpu", "example.org:ip:cpu:1.0", transforms=["tmrg"])
|
|
78
|
+
uart = design.add_ip("uart", "example.org:ip:uart:1.0", parameters={"BAUDRATE": 115200})
|
|
79
|
+
timer = design.add_ip("timer", "example.org:ip:timer:1.0")
|
|
80
|
+
debug = design.add_ip("debug", "example.org:ip:debug_module:1.0")
|
|
81
|
+
bus = design.add_ip("bus", "example.org:ip:interconnect:1.0")
|
|
82
|
+
|
|
83
|
+
design.connect_bus(cpu, bus)
|
|
84
|
+
design.connect_bus(bus.bus("m0"), uart, base_addr=0x4001_0000, size=0x1000)
|
|
85
|
+
design.connect_bus(bus, timer, base_addr=0x4002_0000, size=0x1000)
|
|
86
|
+
|
|
87
|
+
design.connect(debug.debug_req_o, cpu.debug_req_i)
|
|
88
|
+
design.connect(cpu.debug_resp_o, debug.debug_resp_i)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
A runnable version of this script, with its IP library, is in
|
|
92
|
+
[`tests/fixtures/soc.py`](tests/fixtures/soc.py).
|
|
93
|
+
|
|
94
|
+
In short:
|
|
95
|
+
|
|
96
|
+
- `add_ip(name, vlnv, ...)` adds an IP instance, with optional `parameters` overrides and
|
|
97
|
+
`transforms`.
|
|
98
|
+
- `connect_bus(a, b, ...)` connects a bus interface of `a` to one of `b`. It picks them by
|
|
99
|
+
itself, or uses the one named with `instance.bus("name")`. `base_addr`/`size` place a target
|
|
100
|
+
in the address map.
|
|
101
|
+
- `connect(source, target)` connects two ports. `instance.some_port` is short for
|
|
102
|
+
`instance.port("some_port")`.
|
|
103
|
+
|
|
104
|
+
Each call checks its arguments right away, so a mistake is reported on the line that made it.
|
|
105
|
+
All the details are in [the format description](doc/python-design-description.md#the-design-object).
|
|
106
|
+
|
|
107
|
+
Once installed, the importer registers itself under the `xactflow.importers` entry point group
|
|
108
|
+
as `archidesc`, so it runs as a XactFlow CLI command. With `xactflow-design` installed too,
|
|
109
|
+
`--then` hands the result straight to that exporter. To try it on the example of this repo,
|
|
110
|
+
create a virtual environment and install the package in it first. The `xactflow` command only
|
|
111
|
+
exists inside that environment, so activate it again in each new terminal:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
python3 -m venv .venv && source .venv/bin/activate
|
|
115
|
+
pip install -e ".[dev]"
|
|
116
|
+
xactflow archidesc tests/fixtures/soc.py --then design --output out/
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
This writes `out/example.xml`, named after the design's VLNV name.
|
|
120
|
+
|
|
121
|
+
Or as a library, for example to elaborate the design first:
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
from pathlib import Path
|
|
125
|
+
|
|
126
|
+
from xactflow import Library, elaborate
|
|
127
|
+
from xactflow_archidesc import ArchiDescImporter
|
|
128
|
+
from xactflow_design import DesignExporter
|
|
129
|
+
|
|
130
|
+
design = ArchiDescImporter().import_(Path("soc.py"))
|
|
131
|
+
elaborated = elaborate(design, Library.scan("ip"))
|
|
132
|
+
DesignExporter().export(design, Path("out"))
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The script runs like `python soc.py` would: a helper module next to it can be imported, and a
|
|
136
|
+
relative path in it is read from the current folder. `Path(__file__).parent` gives paths
|
|
137
|
+
that do not depend on where the command is run from. The importer takes no options.
|
|
138
|
+
|
|
139
|
+
## Design notes
|
|
140
|
+
|
|
141
|
+
- **Vendor extensions.** Two things this format records have no place in IP-XACT, so they are
|
|
142
|
+
written as vendor extensions in the `https://github.com/IP-XACT/XactFlow` namespace:
|
|
143
|
+
`<xactflow:transforms>` on a component instance, listing the transformations in order, and
|
|
144
|
+
`<xactflow:addressMapping baseAddr="..." size="..."/>` on the target side of a bus
|
|
145
|
+
connection (a target or mirrored initiator interface).
|
|
146
|
+
- **Transformations are not applied here.** A separate tool, a transformer, reads
|
|
147
|
+
`<xactflow:transforms>`, applies the transformations and returns the changed `Design`.
|
|
148
|
+
- **Parameter overrides follow the standard.** Only a parameter with a `parameterId` and
|
|
149
|
+
`resolve="user"` can be overridden. The standard says an `immediate` parameter (the default)
|
|
150
|
+
cannot be changed through configuration.
|
|
151
|
+
- **Connection names are unique.** A bus connection is named `<a>_to_<b>` and a port connection
|
|
152
|
+
`<instance>_<port>_to_<instance>_<port>`. A number is added when a name is already taken, by
|
|
153
|
+
any kind of connection.
|
|
154
|
+
- **Monitors.** Connecting a monitor interface adds a `monitorInterconnection`. The interface it
|
|
155
|
+
watches stays free for a normal connection.
|
|
156
|
+
|
|
157
|
+
## Known limitations
|
|
158
|
+
|
|
159
|
+
- `connect_bus` compares the bus VLNV of the two interfaces, but not the parameter values set
|
|
160
|
+
on the bus type (a data width, for example). Comparing them needs XactFlow to evaluate
|
|
161
|
+
those values first. This should be changed in a future update.
|
|
162
|
+
- XactFlow's `elaborate()` does not use the parameter overrides from `add_ip` yet. They are
|
|
163
|
+
written to the design and exported, but not applied during elaboration.
|
|
164
|
+
- `connect` checks direction only for wire ports. Two transactional or two structured ports
|
|
165
|
+
are connected with no further check, only a mix of the two kinds is refused.
|
|
166
|
+
- `connect` does not compare port widths.
|
|
167
|
+
- A design describes one level only. Hierarchical designs, a real address mapping (instead of
|
|
168
|
+
the `addressMapping` placeholder) and protocol bridges are not handled yet, see the open
|
|
169
|
+
questions at the end of [the format description](doc/python-design-description.md).
|
|
170
|
+
|
|
171
|
+
## Development
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
python3 -m venv .venv
|
|
175
|
+
source .venv/bin/activate
|
|
176
|
+
pip install -r requirements-dev.txt -e .
|
|
177
|
+
pytest
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The tests use a small IP library in `tests/fixtures/library`. `tests/test_end_to_end.py` runs
|
|
181
|
+
the example script through the importer, elaborates the result, exports it with
|
|
182
|
+
`xactflow-design` and reads the file back.
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
LGPL-3.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# xactflow-archidesc
|
|
2
|
+
|
|
3
|
+
A [XactFlow](https://github.com/IP-XACT/XactFlow) importer plugin that turns a design described
|
|
4
|
+
in a Python script (which IPs it uses, and how they are connected) into an `ipxact.Design` object,
|
|
5
|
+
built on [`ipxact-compiler`](https://github.com/IP-XACT/ipxact-compiler)'s
|
|
6
|
+
[IEEE 1685-2022](https://standards.ieee.org/ieee/1685/10307/) object model.
|
|
7
|
+
|
|
8
|
+
IP-XACT `design` files are not made to be handwritten. With this package, a short script lists
|
|
9
|
+
the IP instances, the bus connections between them, and any direct signal connections. The
|
|
10
|
+
importer runs the script and returns the `Design`, which XactFlow's `elaborate()` can then check
|
|
11
|
+
against the IP-XACT rules.
|
|
12
|
+
|
|
13
|
+
The full description of the format is in
|
|
14
|
+
[`doc/python-design-description.md`](doc/python-design-description.md). It describes the tool
|
|
15
|
+
as it is meant to work once finished, so the current version can differ from it in small ways.
|
|
16
|
+
The differences known today are listed in [Known limitations](#known-limitations).
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install xactflow-archidesc
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
For local development, `requirements-dev.txt` overrides `ipxact-compiler`, `xactflow` and
|
|
25
|
+
`xactflow-design` to local installations. It can be modified to adapt the paths or to keep any
|
|
26
|
+
of them on PyPI.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install -r requirements-dev.txt -e .
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Requires Python >= 3.9.
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
A design script builds a `Design` from an IP library and keeps it in a module-level variable
|
|
37
|
+
named `design`:
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from pathlib import Path
|
|
41
|
+
|
|
42
|
+
from xactflow import Library
|
|
43
|
+
from xactflow_archidesc import Design
|
|
44
|
+
|
|
45
|
+
library = Library.scan(Path(__file__).parent / "ip")
|
|
46
|
+
design = Design("example.org:soc:example:0.1", library)
|
|
47
|
+
|
|
48
|
+
cpu = design.add_ip("cpu", "example.org:ip:cpu:1.0", transforms=["tmrg"])
|
|
49
|
+
uart = design.add_ip("uart", "example.org:ip:uart:1.0", parameters={"BAUDRATE": 115200})
|
|
50
|
+
timer = design.add_ip("timer", "example.org:ip:timer:1.0")
|
|
51
|
+
debug = design.add_ip("debug", "example.org:ip:debug_module:1.0")
|
|
52
|
+
bus = design.add_ip("bus", "example.org:ip:interconnect:1.0")
|
|
53
|
+
|
|
54
|
+
design.connect_bus(cpu, bus)
|
|
55
|
+
design.connect_bus(bus.bus("m0"), uart, base_addr=0x4001_0000, size=0x1000)
|
|
56
|
+
design.connect_bus(bus, timer, base_addr=0x4002_0000, size=0x1000)
|
|
57
|
+
|
|
58
|
+
design.connect(debug.debug_req_o, cpu.debug_req_i)
|
|
59
|
+
design.connect(cpu.debug_resp_o, debug.debug_resp_i)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
A runnable version of this script, with its IP library, is in
|
|
63
|
+
[`tests/fixtures/soc.py`](tests/fixtures/soc.py).
|
|
64
|
+
|
|
65
|
+
In short:
|
|
66
|
+
|
|
67
|
+
- `add_ip(name, vlnv, ...)` adds an IP instance, with optional `parameters` overrides and
|
|
68
|
+
`transforms`.
|
|
69
|
+
- `connect_bus(a, b, ...)` connects a bus interface of `a` to one of `b`. It picks them by
|
|
70
|
+
itself, or uses the one named with `instance.bus("name")`. `base_addr`/`size` place a target
|
|
71
|
+
in the address map.
|
|
72
|
+
- `connect(source, target)` connects two ports. `instance.some_port` is short for
|
|
73
|
+
`instance.port("some_port")`.
|
|
74
|
+
|
|
75
|
+
Each call checks its arguments right away, so a mistake is reported on the line that made it.
|
|
76
|
+
All the details are in [the format description](doc/python-design-description.md#the-design-object).
|
|
77
|
+
|
|
78
|
+
Once installed, the importer registers itself under the `xactflow.importers` entry point group
|
|
79
|
+
as `archidesc`, so it runs as a XactFlow CLI command. With `xactflow-design` installed too,
|
|
80
|
+
`--then` hands the result straight to that exporter. To try it on the example of this repo,
|
|
81
|
+
create a virtual environment and install the package in it first. The `xactflow` command only
|
|
82
|
+
exists inside that environment, so activate it again in each new terminal:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
python3 -m venv .venv && source .venv/bin/activate
|
|
86
|
+
pip install -e ".[dev]"
|
|
87
|
+
xactflow archidesc tests/fixtures/soc.py --then design --output out/
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
This writes `out/example.xml`, named after the design's VLNV name.
|
|
91
|
+
|
|
92
|
+
Or as a library, for example to elaborate the design first:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from pathlib import Path
|
|
96
|
+
|
|
97
|
+
from xactflow import Library, elaborate
|
|
98
|
+
from xactflow_archidesc import ArchiDescImporter
|
|
99
|
+
from xactflow_design import DesignExporter
|
|
100
|
+
|
|
101
|
+
design = ArchiDescImporter().import_(Path("soc.py"))
|
|
102
|
+
elaborated = elaborate(design, Library.scan("ip"))
|
|
103
|
+
DesignExporter().export(design, Path("out"))
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The script runs like `python soc.py` would: a helper module next to it can be imported, and a
|
|
107
|
+
relative path in it is read from the current folder. `Path(__file__).parent` gives paths
|
|
108
|
+
that do not depend on where the command is run from. The importer takes no options.
|
|
109
|
+
|
|
110
|
+
## Design notes
|
|
111
|
+
|
|
112
|
+
- **Vendor extensions.** Two things this format records have no place in IP-XACT, so they are
|
|
113
|
+
written as vendor extensions in the `https://github.com/IP-XACT/XactFlow` namespace:
|
|
114
|
+
`<xactflow:transforms>` on a component instance, listing the transformations in order, and
|
|
115
|
+
`<xactflow:addressMapping baseAddr="..." size="..."/>` on the target side of a bus
|
|
116
|
+
connection (a target or mirrored initiator interface).
|
|
117
|
+
- **Transformations are not applied here.** A separate tool, a transformer, reads
|
|
118
|
+
`<xactflow:transforms>`, applies the transformations and returns the changed `Design`.
|
|
119
|
+
- **Parameter overrides follow the standard.** Only a parameter with a `parameterId` and
|
|
120
|
+
`resolve="user"` can be overridden. The standard says an `immediate` parameter (the default)
|
|
121
|
+
cannot be changed through configuration.
|
|
122
|
+
- **Connection names are unique.** A bus connection is named `<a>_to_<b>` and a port connection
|
|
123
|
+
`<instance>_<port>_to_<instance>_<port>`. A number is added when a name is already taken, by
|
|
124
|
+
any kind of connection.
|
|
125
|
+
- **Monitors.** Connecting a monitor interface adds a `monitorInterconnection`. The interface it
|
|
126
|
+
watches stays free for a normal connection.
|
|
127
|
+
|
|
128
|
+
## Known limitations
|
|
129
|
+
|
|
130
|
+
- `connect_bus` compares the bus VLNV of the two interfaces, but not the parameter values set
|
|
131
|
+
on the bus type (a data width, for example). Comparing them needs XactFlow to evaluate
|
|
132
|
+
those values first. This should be changed in a future update.
|
|
133
|
+
- XactFlow's `elaborate()` does not use the parameter overrides from `add_ip` yet. They are
|
|
134
|
+
written to the design and exported, but not applied during elaboration.
|
|
135
|
+
- `connect` checks direction only for wire ports. Two transactional or two structured ports
|
|
136
|
+
are connected with no further check, only a mix of the two kinds is refused.
|
|
137
|
+
- `connect` does not compare port widths.
|
|
138
|
+
- A design describes one level only. Hierarchical designs, a real address mapping (instead of
|
|
139
|
+
the `addressMapping` placeholder) and protocol bridges are not handled yet, see the open
|
|
140
|
+
questions at the end of [the format description](doc/python-design-description.md).
|
|
141
|
+
|
|
142
|
+
## Development
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
python3 -m venv .venv
|
|
146
|
+
source .venv/bin/activate
|
|
147
|
+
pip install -r requirements-dev.txt -e .
|
|
148
|
+
pytest
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The tests use a small IP library in `tests/fixtures/library`. `tests/test_end_to_end.py` runs
|
|
152
|
+
the example script through the importer, elaborates the result, exports it with
|
|
153
|
+
`xactflow-design` and reads the file back.
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
LGPL-3.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "xactflow-archidesc"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "XactFlow importer plugin that serializes an architecture description into an ipxact.Design."
|
|
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
|
+
]
|
|
20
|
+
keywords = [
|
|
21
|
+
"IP-XACT", "IEEE 1685", "XML", "Compiler",
|
|
22
|
+
"XactFlow", "Architecture", "Design", "Importer",
|
|
23
|
+
]
|
|
24
|
+
classifiers = [
|
|
25
|
+
"Development Status :: 3 - Alpha",
|
|
26
|
+
"Programming Language :: Python :: 3",
|
|
27
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
28
|
+
"Programming Language :: Python :: 3.9",
|
|
29
|
+
"Programming Language :: Python :: 3.10",
|
|
30
|
+
"Programming Language :: Python :: 3.11",
|
|
31
|
+
"Programming Language :: Python :: 3.12",
|
|
32
|
+
"Programming Language :: Python :: 3.13",
|
|
33
|
+
"Programming Language :: Python :: 3.14",
|
|
34
|
+
"Topic :: Scientific/Engineering",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Repository = "https://github.com/IP-XACT/XactFlow-archidesc"
|
|
39
|
+
Issues = "https://github.com/IP-XACT/XactFlow-archidesc/issues"
|
|
40
|
+
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
dev = [
|
|
43
|
+
"pytest",
|
|
44
|
+
# For the end-to-end test, exporting to XML for visual verification.
|
|
45
|
+
"xactflow-design",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[project.entry-points."xactflow.importers"]
|
|
49
|
+
archidesc = "xactflow_archidesc:ArchiDescImporter"
|
|
50
|
+
|
|
51
|
+
[tool.setuptools.dynamic]
|
|
52
|
+
version = {attr = "xactflow_archidesc.__version__"}
|
|
53
|
+
|
|
54
|
+
[tool.setuptools.packages.find]
|
|
55
|
+
where = ["src"]
|
|
56
|
+
|
|
57
|
+
[tool.setuptools.package-data]
|
|
58
|
+
xactflow_archidesc = ["py.typed"]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
2
|
+
|
|
3
|
+
import runpy
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import ipxact
|
|
8
|
+
from xactflow import Importer
|
|
9
|
+
|
|
10
|
+
from .design import BusInterfaceRef, Design, IPInstance, PortRef
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ArchiDescImporter(Importer):
|
|
14
|
+
"""Runs a Python design description script and returns the ipxact.Design it describes.
|
|
15
|
+
|
|
16
|
+
The script must define a module-level variable named `design`, holding a Design. It runs
|
|
17
|
+
like `python script.py` would: its own folder is importable while it runs.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
name = "archidesc"
|
|
21
|
+
|
|
22
|
+
def import_(self, source_path: Path, **options: object) -> ipxact.Design:
|
|
23
|
+
if options:
|
|
24
|
+
raise ValueError(f"the archidesc importer takes no options, got: {', '.join(options)}")
|
|
25
|
+
source_path = Path(source_path)
|
|
26
|
+
if not source_path.is_file():
|
|
27
|
+
raise ValueError(f"{source_path} is not a file")
|
|
28
|
+
sys.path.insert(0, str(source_path.parent))
|
|
29
|
+
try:
|
|
30
|
+
namespace = runpy.run_path(str(source_path))
|
|
31
|
+
finally:
|
|
32
|
+
sys.path.remove(str(source_path.parent))
|
|
33
|
+
if "design" not in namespace:
|
|
34
|
+
raise ValueError(f"{source_path} must define a module-level variable 'design'")
|
|
35
|
+
design = namespace["design"]
|
|
36
|
+
if not isinstance(design, Design):
|
|
37
|
+
kind = type(design)
|
|
38
|
+
raise ValueError(
|
|
39
|
+
f"{source_path}: 'design' must be a xactflow_archidesc.Design, got {kind.__module__}.{kind.__qualname__}"
|
|
40
|
+
)
|
|
41
|
+
return design.build()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
__all__ = ["__version__", "ArchiDescImporter", "BusInterfaceRef", "Design", "IPInstance", "PortRef"]
|