systemrdl / peakrdl-cheader Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
@amykyta3 I use new C header generator, i find C header generate file doesn't have suffix,i modify below code, text in bold. Could you help make sure it?
`
class HeaderGenerator(RDLListener):
def init(self, ds: DesignState) -> None:
self.ds = ds
self.defined_namespace: Set[str]
self.defined_namespace = set()
self.indent_level = 0
self.root_node: AddrmapNode
self.root_node = None
self.f: TextIO
self.f = None # type: ignore
def run(self, path: str, top_nodes: List[AddrmapNode]) -> None:
**header_path = path + ".h"**
with open(header_path, "w", encoding='utf-8') as f:
`
I am looking for a C based register HAL, I understand that there are plans to add an exporter fo the PeakRDL tool to do this.
Do you have any advice as to how to approach this? Do you have any design notes or examples of the style of headers and macros you expect? Any gotchas or deal breakers?
I am asking because it makes sense that if we take this on that it is able to be contributed to the project.
We are running into a problem that is exposed when we export a bunch of headers for bus slaves that all have a common regfile. If we export an entire bus structures register map as a single header, it is not a problem because the common regfile struct has a _<random_string> tacked on as a post-fix.
Essentially what we have is a bunch of registers that's are the same for every one of our custom bus slaves. These are for slave identification at runtime, cross-checking version codes for SW/HW API compatibility, etc.
We import this regfile from a different .rdl file and instance the regfile at address 0 of every bus slave.
The problem occurs when I export individual headers for each bus slave. I cannot include several of these headers in a single C project due to the name collision of the identical structs generated for each slave in each header.
I don't know a good way of fixing this. Maybe we can have a command line argument for generating all included regfiles as a seperate .h file?
python3 -m pip install peakrdl-cheader
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement peakrdl-cheader (from versions: none)
ERROR: No matching distribution found for peakrdl-cheader
WARNING: You are using pip version 20.2.3; however, version 22.2.2 is available.
You should consider upgrading via the '/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip' command.
Please note that I was able to install other PeakRDL packages (ipxact, regblock etc).
Multidimensional arrays generate declarations like [X, Y, Z]
instead of [X][Y][Z]
:
PeakRDL-cheader/src/peakrdl_cheader/header_generator.py
Lines 318 to 322 in db696fc
Currently not implemented.
Register arrays where the stride is greater than the regwidth.
The struct methodology works well for memory mapped registers, however sometimes FPGA registers are not memory mapped to a processor and can only be accessed via indirect addressing.
In this case it would be useful to have #defines with absolute/relative offsets of the registers instead of packed structs.
When running peakrdl_cheader ./docs/rdl/ip_core.rdl --outdir export/c
, Peakrdl IPXACT plugin 'Peakrdl-ipxact' cannot be found under peakrdl.ipxact, but can be found under peakrdl_ipxact
File "<path>/.venv/lib/python3.11/site-packages/peakrdl_cheader/peakcheader.py", line 11, in <module>
from peakrdl.ipxact import IPXACTImporter # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'peakrdl.ipxact'
In Python Shell, running shows module does not exist under peakrdl.ipxact
(with peakrdl-ipxact
pip installed):
>>> from importlib.util import find_spec; find_spec("peakrdl.ipxact") or "Does not exist"
"Does not exist"
However, the module name works under peakrdl_ipxact
>>> from importlib.util import find_spec; find_spec("peakrdl_ipxact") or "Does not exist"
ModuleSpec(name='peakrdl_ipxact', loader=<_frozen_importlib_external.SourceFileLoader object at 0x1007a6810>, origin='/<path>/.venv/lib/python3.11/site-packages/peakrdl_ipxact/__init__.py', submodule_search_locations=['/<path>/.venv/lib/python3.11/site-packages/peakrdl_ipxact'])
The module reference can be seen to be peakrdl_ipxact, however, I'm not sure if the main peakrdl
at some point had the ipxact under its namespace. I haven't followed the history long enough to know if this was changed, or, if this is difference in environments.
To maintain backwards compatibility (if desired), a check can be performed on line 11 of peakcheader.py which module should be imported.
# Line 11
import importlib
from importlib.util import find_spec
if find_spec("peakrdl.ipxact"):
from peakrdl.ipxact import IPXACTImporter # type: ignore
elif find_spec("peakrdl_ipxact"):
from peakrdl_ipxact import IPXACTImporter # type: ignore
else:
raise ModuleNotFoundError("Cannot find PeakRDL IPXACT Module")
I'm sure a more pythonic way could be written. If you are busy, I could submit the PR if needed.
Python 3.11.2
Pip 22.3.1
Mac M1 running in x86_64 (Rosetta) Environment
antlr4-python3-runtime==4.11.1
colorama==0.4.6
git-me-the-url==2.1.0
gitdb==4.0.10
GitPython==3.1.31
hectare==0.2.4
Jinja2==3.1.2
Markdown==3.4.3
MarkupSafe==2.1.2
peakrdl==0.8.0
peakrdl-cheader==0.0.1
peakrdl-html==2.10.0
peakrdl-ipxact==3.4.1
peakrdl-regblock==0.12.0
peakrdl-systemrdl==0.3.0
peakrdl-uvm==2.3.0
pysphere==0.1.7
python-markdown-math==0.8
PyYAML==6.0
smmap==5.0.0
systemrdl-compiler==1.25.6
See example in SystemRDL/systemrdl-compiler#193
Current implementation will silently emit colliding output, or even reuse an incorrect typedef.
Monitor for this and emit an error if it occurs.
Ideas for fix:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.