Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enh] generate SVD CSR enumeratedValue based on fields values #1790

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chmousset
Copy link
Contributor

The SVD schema supports listing possible values for CSR fields, as can be seen in Keil's example.

Ideally, all existing field documented should be formatted as SVD schema expects it.
However, invalid values are filtered out using the schema's regex, guaranteeing a valid SVD output will be generated regardless.

Here is a snippet of a generated SVD (from linux-on-litex-vexriscv)

        <peripheral>
            <name>SDRAM</name>
...
            <registers>
                <register>
                    <name>DFII_CONTROL</name>
...
                    <fields>
                        <field>
                            <name>sel</name>
...
                            <enumeratedValues>
                                <enumeratedValue>
                                    <name>Software</name>
                                    <description>Software (CPU) control.</description>
                                    <value>0b0</value>
                                </enumeratedValue>
                                <enumeratedValue>
                                    <name>Hardware</name>
                                    <description>Hardware control (default).</description>
                                    <value>0b1</value>
                                </enumeratedValue>
                            </enumeratedValues>

@mithro mithro requested review from xobs and bunnie September 26, 2023 17:10
@mithro
Copy link
Collaborator

mithro commented Sep 26, 2023

@xobs / @bunnie - As likely users of this, could you review it?

@xobs
Copy link
Collaborator

xobs commented Sep 27, 2023

There was a program that was presented at Latchup 2023 that I am having trouble finding now. It was a browser-based register explorer. When I checked before, it didn't support SVD files, but that was a pending request. I'd love to see what that does with this, and what the progress is on SVD import.

A practical and more common usecase would be svd2rust (https://docs.rs/svd-rs/0.14.2/svd_rs/enumeratedvalues/struct.EnumeratedValues.html), which appears to support enumerated values.

@chmousset
Copy link
Contributor Author

@xobs Thanks for the review

There was a program that was presented at Latchup 2023 that I am having trouble finding now. It was a browser-based register explorer.

https://github.com/SystemRDL/PeakRDL-html ?
Looks very nice with the register coding / decoding of values and fields.
Maybe it would be possible to output rdl from litex and / or integrating this interactive bit of HTML in LiteX's doc.
I might take a look at it next time I'm neck deep debugging CSR values!

A practical and more common usecase would be svd2rust (https://docs.rs/svd-rs/0.14.2/svd_rs/enumeratedvalues/struct.EnumeratedValues.html), which appears to support enumerated values.

it does!

...
    pub type DFII_CONTROL = crate::Reg<dfii_control::DFII_CONTROL_SPEC>;
    #[doc = "Control DFI signals common to all phases"]
    pub mod dfii_control {
        #[doc = "Register `DFII_CONTROL` reader"]
        pub type R = crate::R<DFII_CONTROL_SPEC>;
        #[doc = "Register `DFII_CONTROL` writer"]
        pub type W = crate::W<DFII_CONTROL_SPEC>;
        #[doc = "Field `sel` reader - None"]
        pub type SEL_R = crate::BitReader<SEL_A>;
        #[doc = "None\n\nValue on reset: 1"]
        #[derive(Clone, Copy, Debug, PartialEq, Eq)]
        pub enum SEL_A {
            #[doc = "0: Software (CPU) control."]
            SOFTWARE = 0,
            #[doc = "1: Hardware control (default)."]
            HARDWARE = 1,
        }
...

@xobs
Copy link
Collaborator

xobs commented Sep 27, 2023

That's the one! I discovered https://github.com/SystemRDL/PeakRDL-svd/blob/main/docs/dev_notes.txt but there hasn't been any movement there in a few months...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants