lowRISC / opentitan

OpenTitan: Open source silicon root of trust
https://www.opentitan.org
Apache License 2.0
2.45k stars 733 forks source link

[reggen, regtool] Request for IEEE1685-2022/Accellera IPXACT XML Schema Generation Support in `regtool` #22933

Open opensource-elearning opened 2 months ago

opensource-elearning commented 2 months ago

Description

Dear Maintainers,

I am writing to request the addition of support for generating IEEE/Accellera IPXACT XML Schema in regtool.

Background:

IPXACT is an XML-based standard (IEEE 1685-2022) for packaging, integrating, and reusing IP within tool flows. It provides a common language for representing IP metadata, enabling interoperability between different tools and platforms.

Benefits of IPXACT Support in regtool:

Current Limitations:

While regtool currently supports generating various formats, it does not include support for IPXACT XML Schemas. This limits the interoperability and reusability of regtool-generated IP metadata.

Request:

I kindly request that the regtool team consider adding support for generating IEEE/Accellera IPXACT XML Schemas. This feature would greatly enhance the utility of regtool for IP design and management.

Additional Information/References:

https://www.accellera.org/downloads/standards/ip-xact https://ieeexplore.ieee.org/document/10054520 https://www.accellera.org/images/downloads/standards/ip-xact/1685-2022-VE-1.0-Specification.zip

Thank you for your time and consideration. I look forward to hearing from you soon.

jwnrt commented 2 months ago

I'd like to throw in PeakRDL as an alternative path for getting closer to better IP interoperability. It's designed for SystemRDL files but has an importer to consume IPXACT (and convert to SystemRDL).

Yesterday I tried this importer plugin for our regtool Hjson format: https://github.com/Risto97/PeakRDL-opentitan. It worked pretty well for a few blocks, but still needs some work to cover everything our Hjson supports.

opensource-elearning commented 2 months ago

@jwnrt , thanks for your response.

https://github.com/Risto97/PeakRDL-opentitan provides an example for converting SystemRDL to HJSON format, but it doesn't provide a example command for converting HJSON to SystemRDL. I've also checked the limitations of PeakRDL-opentitan.

Are we planning to adopt PeakRDL as our main line tool and drop reggen/regtool? We could then use only SystemRDL format in OpenTitan.

Alternatively, reggen/regtool could provide robust support for converting HJSON to SystemRDL and SystemRDL to HJSON, and we could focus on maintaining only two formats: HJSON and SystemRDL. This would provide an alternative to the IEEE IPXACT format, as PeakRDL includes an IPXACT format exporter.

jwnrt commented 2 months ago

Are we planning to adopt PeakRDL as our main line tool and drop reggen/regtool? We could then use only SystemRDL format in OpenTitan.

There are no plans for this currently but (not speaking for the project) it would be my personal preference. We're working on Earl Grey PROD RTL releases at the moment so wouldn't want to be changing regtool right now.

it doesn't provide a example command for converting HJSON to SystemRDL.

The command I used was:

peakrdl systemrdl hw/ip/uart/data/uart.hjson -o uart.rdl

To run it on every block, I used:

for block in $(find hw/ip -mindepth 1 -maxdepth 1 -type d -exec basename {} \;); do
    peakrdl systemrdl \
        "hw/ip/${block}/data/${block}.hjson" \
        -o \
        "hw/ip/${block}/data/${block}.rdl"
done

As you say, there are limitations. I made the following patch to the systemrdl compiler, but many more changes would be needed to get every blocks parsing.

diff --git a/systemrdl/importer.py b/systemrdl/importer.py
index ff73bca..7bb6f2e 100644
--- a/systemrdl/importer.py
+++ b/systemrdl/importer.py
@@ -274,6 +274,8 @@ class RDLImporter:
         if isinstance(parent, comp.Addrmap):
             if isinstance(child, comp.AddressableComponent):
                 bad = False
+            elif isinstance(child, comp.Signal):
+                bad = False
         elif isinstance(parent, comp.Regfile):
             if isinstance(child, (comp.Regfile, comp.Reg)):
                 bad = False
benoitdenkinger commented 2 months ago

Hello,

I'm also very interested by converting the regtool hjson format to SystemRDL. I'll support PeakRDL-opentitan for now.

Does the regtool can generate something more than the register files (that's all I've used if for)? Because I see the interrupts and top signals can also be declared. I'm asking because currently I'm using SystemRDL to describe register files but also to generate all the interconnections between the IP blocks of an SoC (with a PeakRDL plugin which is not yet released). However, SystemRDL is not meant for that and IPXACT seems to be better suited, but more complex.

On the long run the goal would be to move to IPXACT, which is used by the industry (e.g., Xilinx, Cadence, Synopsys) and also the Kactus project. If there is an effort in that direction, I'll be happy to contribute.

jwnrt commented 2 months ago

Does the regtool can generate something more than the register files (that's all I've used if for)? Because I see the interrupts and top signals can also be declared.

There are a few other generators in the OpenTitan repo that consume these hjson files like topgen, tlgen, and ipgen. It's worth checking if those generate what you're asking for.

However, SystemRDL is not meant for that and IPXACT seems to be better suited, but more complex.

Oh, that's a shame, I was hoping SystemRDL could cover all our use cases. Good to see IPXACT has wide support, but it doesn't look very human-writable. I suppose it's designed to be edited from vendors' GUI tools?

benoitdenkinger commented 2 months ago

There are a few other generators in the OpenTitan repo that consume these hjson files like topgen, tlgen, and ipgen. It's worth checking if those generate what you're asking for.

Thanks, It actually looks very similar to the tools I have for SystemRDL. For the short term I'll keep my flow running with SystemRDL as I have an implementation to finalize.

Oh, that's a shame, I was hoping SystemRDL could cover all our use cases. Good to see IPXACT has wide support, but it doesn't look very human-writable.

Yes, XML is not really meant for human (reading or writing). hjson or SystemRDL is much better from that point of view. SystemRDL can be extended with custom properties and use to do similar things than OpenTitan generator tools. But it was not meant for that so the processing of these extra properties is not always easy and the generation process I have now is not very elegant (and easy to use).

I suppose it's designed to be edited from vendors' GUI tools?

Yes probably. Kactus is an open-source project (with a GUI interface) meant to generate IPXACT components and interconnect them.

opensource-elearning commented 2 months ago

Are we planning to adopt PeakRDL as our main line tool and drop reggen/regtool? We could then use only SystemRDL format in OpenTitan.

There are no plans for this currently but (not speaking for the project) it would be my personal preference. We're working on Earl Grey PROD RTL releases at the moment so wouldn't want to be changing regtool right now.

it doesn't provide a example command for converting HJSON to SystemRDL.

The command I used was:

peakrdl systemrdl hw/ip/uart/data/uart.hjson -o uart.rdl

To run it on every block, I used:

for block in $(find hw/ip -mindepth 1 -maxdepth 1 -type d -exec basename {} \;); do
    peakrdl systemrdl \
        "hw/ip/${block}/data/${block}.hjson" \
        -o \
        "hw/ip/${block}/data/${block}.rdl"
done

As you say, there are limitations. I made the following patch to the systemrdl compiler, but many more changes would be needed to get every blocks parsing.

diff --git a/systemrdl/importer.py b/systemrdl/importer.py
index ff73bca..7bb6f2e 100644
--- a/systemrdl/importer.py
+++ b/systemrdl/importer.py
@@ -274,6 +274,8 @@ class RDLImporter:
         if isinstance(parent, comp.Addrmap):
             if isinstance(child, comp.AddressableComponent):
                 bad = False
+            elif isinstance(child, comp.Signal):
+                bad = False
         elif isinstance(parent, comp.Regfile):
             if isinstance(child, (comp.Regfile, comp.Reg)):
                 bad = False

Dear @jwnrt,

Given your extensive experience and expertise in various industries, coupled with your proficiency in multiple programming languages, you may be well-equipped to handle the complexities of implementing multiple changes and debugging tasks.

However, from the perspective of junior engineers or freshers, it can be challenging to navigate the complexities of modifying multiple plugins and then reverting to check the results.

We believe that enhancing the reggen/regtool utility to generate standard outputs in either SystemRDL or IPXACT (an XML-based templated form of SystemRDL) would be highly beneficial to all users.

If you could kindly assist in identifying the appropriate reggen/regtool owners and facilitate their evaluation of the feasibility of implementing SystemRDL or IPXACT format output from hjson, we would be most grateful.

jwnrt commented 2 months ago

However, from the perspective of junior engineers or freshers, it can be challenging to navigate the complexities of modifying multiple plugins and then reverting to check the results.

Sorry if my comments were confusing! I don't find these tools very easy to use myself.

If you could kindly assist in identifying the appropriate reggen/regtool owners and facilitate their evaluation of the feasibility of implementing SystemRDL or IPXACT format output from hjson, we would be most grateful.

I'm not sure if the regtool has a single owner, but based on its commits maybe @rswarbrick would be able to answer your questions if he has time