Skip to content

Add Smcsrind and Sscsrind CSR YAML Files #590

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

Conversation

syedowaisalishah
Copy link
Contributor

This PR adds:

  • Extension YAML files for Smcsrind and Sscsrind

  • CSR YAMLs for:

    • MISELECT, MIREG to MIREG6
    • SISELECT, SIREG to SIREG6
    • VSISELECT, VSIREG to VSIREG6

    Closes Add Smcsrind/Sscsrind YAML #557

@dhower-qc
Copy link
Collaborator

Take a look at #594

With that patch, you should be able to write the sw_read/sw_write functions for the indirect CSRs

@syedowaisalishah
Copy link
Contributor Author

syedowaisalishah commented Apr 4, 2025

Thanks for the clarification, @dhower-qc. I've updated all relevant CSR fields to use:
reset_value: UNDEFINED_LEGAL.
I've reviewed the proposed schema changes in PR #594. Once it's merged, I plan to implement the sw_read() and sw_write() functions for the indirect CSRs as a follow-up.
I'll push the fixes shortly and re-request review once done.

Copy link
Collaborator

@ThinkOpenly ThinkOpenly left a comment

Choose a reason for hiding this comment

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

I left a lot of single comments instead of a review, so adding my review now. (Leaving a review needs a comment, so viola.)

Copy link
Collaborator

@AFOliveira AFOliveira left a comment

Choose a reason for hiding this comment

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

@syedowaisalishah There are several comments on this PR that likely have already been solved by recent changes, can you either answer them or resolve them so reviewers can know exactly what to look like when taking a second look at this PR? Also, Github will request that all of them are resolved when we want to merge.

@syedowaisalishah
Copy link
Contributor Author

@AFOliveira Thanks for the reminder! I'll go through all the comments, respond where needed, and resolve the ones that have been addressed by the recent changes. I'll make sure everything is clear for the reviewers before we proceed with the next review.

Copy link
Collaborator

@dhower-qc dhower-qc left a comment

Choose a reason for hiding this comment

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

The comments generally apply to all the files.

@ThinkOpenly
Copy link
Collaborator

@dhower-qc, is there a way to incorporate this:

The behavior upon accessing sireg* from M-mode or S-mode, while siselect holds a value that is not implemented at supervisor level, is UNSPECIFIED.

It is recommended that implementations raise an illegal instruction exception for such accesses, to facilitate possible emulation (by M-mode) of these accesses.

Given the "recommended" term, do we need an extension parameter?

@dhower-qc
Copy link
Collaborator

@dhower-qc, is there a way to incorporate this:

The behavior upon accessing sireg* from M-mode or S-mode, while siselect holds a value that is not implemented at supervisor level, is UNSPECIFIED.
It is recommended that implementations raise an illegal instruction exception for such accesses, to facilitate possible emulation (by M-mode) of these accesses.

Given the "recommended" term, do we need an extension parameter?

This is already handled as long as we call unimplemented_csr in IDL, since it's the same situation with direct CSR accesses. There is a TRAP_ON_UNIMPLEMENTED_CSR parameter, that does the following:

function unimplemented_csr {
  arguments Bits<INSTR_ENC_SIZE> encoding
  description {
    Either raises an IllegalInstruction exception or enters unpredictable state,
    depending on the setting of the TRAP_ON_UNIMPLEMENTED_CSR parameter.
  }
  body {
    if (TRAP_ON_UNIMPLEMENTED_CSR) {
      raise(ExceptionCode::IllegalInstruction, mode(), encoding);
    } else {
      unpredictable("Accessing an unimplmented CSR");
    }
  }
}

@syedowaisalishah
Copy link
Contributor Author

@dhower-qc I’ve applied all the requested updates across mireg[1–6].yaml, sireg[1–6].yaml, and vsireg[1–6].yaml:

  • Converted description fields to the structured format.

  • Added long_name to the VALUE field.

  • Implemented sw_read() and sw_write() methods, using the appropriate index in indirect_csr_lookup() for each file.

  • Corrected the description format for {m,v,s}select as well.

Copy link
Collaborator

@dhower-qc dhower-qc left a comment

Choose a reason for hiding this comment

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

Other than the small indentation request, looking good!!

@syedowaisalishah syedowaisalishah requested a review from dhower-qc May 5, 2025 15:34
Copy link
Collaborator

@dhower-qc dhower-qc left a comment

Choose a reason for hiding this comment

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

Looks good, assuming the regressions pass after pulling main.

Thanks for all the work!

@ThinkOpenly ThinkOpenly added this pull request to the merge queue May 5, 2025
Merged via the queue into riscv-software-src:main with commit 34157aa May 5, 2025
11 checks passed
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.

Add Smcsrind/Sscsrind YAML
4 participants