Skip to content

Conversation

wwwwwwOwO
Copy link

This PR focuses on the configuration aspect extracted from #982, the features:

  • Configuration setup in config file and riscv_extensions.sail, ordered by category and then alphabetically
  • Check extension dependencies in riscv_validate_config.sail and riscv_vext_control.sail

Follow-up PRs will address instruction-level support logic.

@wwwwwwOwO wwwwwwOwO requested a review from jordancarlin July 26, 2025 02:32
@wwwwwwOwO
Copy link
Author

Thanks for the feedback! I’ve made the changes and updated the riscv_vext_control.sail and README.

@wwwwwwOwO
Copy link
Author

0      Zvl*
         ↓           
1      Zve32x      F   D
       ↙      ↘
2  Zve32f     Zve64x           Zve32f
      ↘       ↙                   ↓
3      Zve64f      Zfhmin      Zvfhmin
         ↓           ↓
4      Zve64d      Zvfh
         ↓           
5        V
         ↓   
    Other Zv*

I've updated the currentlyEnabled_measure() in riscv_termination.sail, the graph reflects it logic.

Copy link
Collaborator

@jordancarlin jordancarlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependencies for the vector bit manipulation and cryptography extensions need to change too:

The Zvknhb and Zvbc Vector Crypto Extensions --and accordingly the composite extensions Zvkn, Zvknc, Zvkng, and Zvksc-- depend on Zve64x.

All of the other Vector Crypto Extensions depend on Zve32x.

Note: If Zve32x is supported then Zvkb or Zvbb provide support for EEW of 8, 16, and 32. If Zve64x is supported then Zvkb or Zvbb also add support for EEW 64.

@wwwwwwOwO
Copy link
Author

I’ve updated the currentlyEnabled() checks to reflect the new Zve32x/Zve64x requirements for these extensions.

As for:

Note: If Zve32x is supported then Zvkb or Zvbb provide support for EEW of 8, 16, and 32. If Zve64x is supported then Zvkb or Zvbb also add support for EEW 64.

I’ll handle those SEW constraints in the instruction-level changes.

@wwwwwwOwO
Copy link
Author

The dependencies for the vector bit manipulation and cryptography extensions need to change too:

The Zvknhb and Zvbc Vector Crypto Extensions --and accordingly the composite extensions Zvkn, Zvknc, Zvkng, and Zvksc-- depend on Zve64x.
All of the other Vector Crypto Extensions depend on Zve32x.
Note: If Zve32x is supported then Zvkb or Zvbb provide support for EEW of 8, 16, and 32. If Zve64x is supported then Zvkb or Zvbb also add support for EEW 64.

Thanks for pointing that out!
I've corrected the riscv_termination.sail, and accordingly updated the riscv_validate_config.sail and currentlyEnabled() for these extensions.

Copy link
Collaborator

@jordancarlin jordancarlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for getting these all added! LGTM, but I think we should wait until after the upcoming release before merging to avoid confusion because #1170 probably won’t be ready.

@jordancarlin
Copy link
Collaborator

@wwwwwwOwO Now that Zvfh is a distinct config option, the fli.h instruction from the Zfa extension needs to be supported when Zvfh or Zfh are supported. See this recent issue: riscv/riscv-isa-manual#2190.

@jordancarlin jordancarlin added configuration Additional configuration settings needed for the model extension Adds support for a RISC-V extension labels Aug 8, 2025
@wwwwwwOwO
Copy link
Author

@wwwwwwOwO Now that Zvfh is a distinct config option, the fli.h instruction from the Zfa extension needs to be supported when Zvfh or Zfh are supported. See this recent issue: riscv/riscv-isa-manual#2190.

Got it! I'll make changes for

mapping clause encdec = FLI_H(constantidx, rd)
  <-> 0b111_1010 @ 0b00001 @ constantidx @ 0b000 @ encdec_freg(rd) @ 0b101_0011
  when currentlyEnabled(Ext_Zfh) & currentlyEnabled(Ext_Zfa)

to

mapping clause encdec = FLI_H(constantidx, rd)
  <-> 0b111_1010 @ 0b00001 @ constantidx @ 0b000 @ encdec_freg(rd) @ 0b101_0011
  when (currentlyEnabled(Ext_Zfh) |  currentlyEnabled(Ext_Zvfh)) & currentlyEnabled(Ext_Zfa)

Because it is instruction-level change, I'll put it in #1170.

@pmundkur
Copy link
Collaborator

0      Zvl*
         ↓           
1      Zve32x      F   D
       ↙      ↘
2  Zve32f     Zve64x           Zve32f
      ↘       ↙                   ↓
3      Zve64f      Zfhmin      Zvfhmin
         ↓           ↓
4      Zve64d      Zvfh
         ↓           
5        V
         ↓   
    Other Zv*

I've updated the currentlyEnabled_measure() in riscv_termination.sail, the graph reflects it logic.

It would be good to put this nice diagram in riscv_termination.sail with suitable comments.

@nadime15
Copy link
Contributor

0      Zvl*
         ↓           
1      Zve32x      F   D
       ↙      ↘
2  Zve32f     Zve64x           Zve32f
      ↘       ↙                   ↓
3      Zve64f      Zfhmin      Zvfhmin
         ↓           ↓
4      Zve64d      Zvfh
         ↓           
5        V
         ↓   
    Other Zv*

It probably does not matter here, and as far as I can tell, this only applies to riscv_termination.sail anyway but in theory, the relationship is more nuanced: a given Zvl* does not enable all Zve* extensions (or the other way around, a given Zve* extension does not include all Zvl* extension). For example, Spike derives VLEN from Zvl and ELEN from Zve, so combinations like Zvl32b with Zve64d are invalid.

@wwwwwwOwO
Copy link
Author

Sorry, I closed the PR by accident, I'll try to reopen it.

@wwwwwwOwO wwwwwwOwO reopened this Sep 3, 2025
@wwwwwwOwO wwwwwwOwO requested a review from pmundkur September 6, 2025 01:32
Comment on lines +267 to +300
enum clause extension = Ext_Zvl32b
mapping clause extensionName = Ext_Zvl32b <-> "zvl32b"
function clause hartSupports(Ext_Zvl32b) = sizeof(vlen_exp) >= 5
enum clause extension = Ext_Zvl64b
mapping clause extensionName = Ext_Zvl64b <-> "zvl64b"
function clause hartSupports(Ext_Zvl64b) = sizeof(vlen_exp) >= 6
enum clause extension = Ext_Zvl128b
mapping clause extensionName = Ext_Zvl128b <-> "zvl128b"
function clause hartSupports(Ext_Zvl128b) = sizeof(vlen_exp) >= 7
enum clause extension = Ext_Zvl256b
mapping clause extensionName = Ext_Zvl256b <-> "zvl256b"
function clause hartSupports(Ext_Zvl256b) = sizeof(vlen_exp) >= 8
enum clause extension = Ext_Zvl512b
mapping clause extensionName = Ext_Zvl512b <-> "zvl512b"
function clause hartSupports(Ext_Zvl512b) = sizeof(vlen_exp) >= 9
enum clause extension = Ext_Zvl1024b
mapping clause extensionName = Ext_Zvl1024b <-> "zvl1024b"
function clause hartSupports(Ext_Zvl1024b) = sizeof(vlen_exp) >= 10
// Vector Extensions for Embedded Processors
enum clause extension = Ext_Zve32f
mapping clause extensionName = Ext_Zve32f <-> "zve32f"
function clause hartSupports(Ext_Zve32f) = config extensions.Zve32f.supported
enum clause extension = Ext_Zve32x
mapping clause extensionName = Ext_Zve32x <-> "zve32x"
function clause hartSupports(Ext_Zve32x) = config extensions.Zve32x.supported
enum clause extension = Ext_Zve64d
mapping clause extensionName = Ext_Zve64d <-> "zve64d"
function clause hartSupports(Ext_Zve64d) = config extensions.Zve64d.supported
enum clause extension = Ext_Zve64f
mapping clause extensionName = Ext_Zve64f <-> "zve64f"
function clause hartSupports(Ext_Zve64f) = config extensions.Zve64f.supported
enum clause extension = Ext_Zve64x
mapping clause extensionName = Ext_Zve64x <-> "zve64x"
function clause hartSupports(Ext_Zve64x) = config extensions.Zve64x.supported
Copy link
Contributor

@nadime15 nadime15 Sep 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it’s just me, but I think we should either let the user enable these extensions by explicitly setting vlen and (!) elen, or we implicitly set vlen and elen when using the Zve* and Zvl* extensions (like Spike does) and remove vlen and elen from the config file. Right now, this approach feels like a mix of both options, and elen doesn’t play a role at all anymore.

For example, if I set elen to 32 but enable Ext_Zve64x, what should elen actually be?

I also think the way currentlyEnabled(Ext_Zve*) is structured needs to change. For instance, enabling Zve64d should automatically enable all the Zve* subset extensions.

(Actually, we don’t need to enable all subset extensions, otherwise, the ISA string becomes unnecessarily long but at the very least, the user should be able to enable Zve64d without having to enable every subset extension manually)

Spike just updated its approach as well. Spike will set elen (and vlen if no Zvl* extension is provided) based on the Zve* extensions. So elen comes from Zve* and vlen from Zvl* or from Zve* (if no Zvl* is provided)

This is probably worth discussing in the Monday meeting @pmundkur

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that this is worth further discussion. I don't think we can remove VLEN as a config option and just use the Zvl* extensions though because that prevents anyone from using a VLEN greater than 1024. I know there are already implementations with VLEN greater than that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, Spike supports Zvl2048b and Zvl4096b, even though they haven’t been ratified yet. We might want to do the same here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wwwwwwOwO We discussed this in the meeting today. The overall conclusion was to remove ELEN from the config and instead set it to match whichever Zve* extension is enabled, basically like Spike, taking the maximum possible ELEN. For example, if Zve64f, Zve64d,Zve64x or V are enabled, set ELEN=64 otherwise for the other extensions, set ELEN=32.

But this will break the vector test case configurations in CI.

See

The good news is vector test cases are only supported when XLEN == ELEN. So, we could just replace ELEN with XLEN, and it should work.

If we decide to remove ELEN, I can patch these files myself, so you wont need to touch them.

@jordancarlin jordancarlin added the tgmm-agenda Tagged for the next Golden Model meeting agenda. label Sep 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Additional configuration settings needed for the model extension Adds support for a RISC-V extension tgmm-agenda Tagged for the next Golden Model meeting agenda.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants