Code Monkey home page Code Monkey logo

peakrdl-cheader's Introduction

peakrdl-cheader's People

Contributors

krcb197 avatar amykyta3 avatar

Stargazers

Alex Lao avatar Jacob Leemaster avatar  avatar Joyen Benitto avatar Roo avatar Ya-Chau Yang avatar

Watchers

Alex H avatar  avatar Roo avatar  avatar

peakrdl-cheader's Issues

Installation failing

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).

C Register HAL

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.

Problem with using multiple cheaders which share imported regfiles

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?

During export, check for identifier collisions in output

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:

  • Temporarily generate prefixes using non-underscore characters that are impossible to specify in RDL source.
  • Use the above prefix as the source of truth to uniquely identify a type name
  • Replace special delimiter chars with underscores and check if it collides with an existing scope prefix elsewhere.

C header generate file doesn't have suffix

@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:

`

Peakrdl IPXACT - No module named 'peakrdl.ipxact'

Problem

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.

Solution

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.

Environment:

Python 3.11.2
Pip 22.3.1
Mac M1 running in x86_64 (Rosetta) Environment

Pip List

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.