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

extract CSR numbers #33

Open
ThinkOpenly opened this issue Jun 25, 2024 · 5 comments
Open

extract CSR numbers #33

ThinkOpenly opened this issue Jun 25, 2024 · 5 comments
Assignees

Comments

@ThinkOpenly
Copy link
Owner

ThinkOpenly commented Jun 25, 2024

Thanks to 7738de1, we are extracting register names and types:

  "registers": [ 
    { "name": "mcounteren", "type": "Counteren" },
    { "name": "scounteren", "type": "Counteren" },
    { "name": "mcountinhibit", "type": "Counterin" },
    { "name": "fcsr", "type": "Fcsr" },

Some of the "special registers" are associated with a number. In model/riscv_csr_map.sail:

mapping clause csr_name_map = 0x306  <-> "mcounteren"
mapping clause csr_name_map = 0x106  <-> "scounteren"
mapping clause csr_name_map = 0x320  <-> "mcountinhibit"
mapping clause csr_name_map = 0x003  <-> "fcsr"

We should extract these numbers and add them to their respective register data.

@aryansharma6827
Copy link

hi i am Aryan Sharma currently learning this codebase i would like to work in this issue please assign it to me.

@ThinkOpenly
Copy link
Owner Author

I have assigned you, @aryansharma6827 , but please ask questions and I'll ask that you provide occasional updates on progress. If you do feel that you will be unwilling or unable to continue, I ask that you let me know.

@aryansharma6827
Copy link

can you please elaborate the issue and how to proceed further.

@ThinkOpenly
Copy link
Owner Author

We now emit the following in the JSON output:

  "registers": [ 
    { "name": "mcounteren", "type": "Counteren" },
    { "name": "scounteren", "type": "Counteren" },
    { "name": "mcountinhibit", "type": "Counterin" },
    { "name": "fcsr", "type": "Fcsr" },
[...]

There is additional information (the associated register numbers for CSRs) that should be included. The information can be found in model/riscv_csr_map.sail:

mapping clause csr_name_map = 0x306  <-> "mcounteren"
mapping clause csr_name_map = 0x106  <-> "scounteren"
mapping clause csr_name_map = 0x320  <-> "mcountinhibit"
mapping clause csr_name_map = 0x003  <-> "fcsr"
[...]

So, the resulting JSON should be enhanced to include this additional information:

  "registers": [ 
    { "name": "mcounteren", "type": "Counteren", "number": "0x306" },
    { "name": "scounteren", "type": "Counteren", "number": "0x106" },
    { "name": "mcountinhibit", "type": "Counterin", "number": "0x320" },
    { "name": "fcsr", "type": "Fcsr", "number": "0x003" },
[...]

This additional information is encoded in a scattered mapping as a series of mapping clause statements. mapping clause AST elements are handled (in src/sail_json_backend/json.ml) in parse_mapcl. You can see stanzas for handling "encdec" and "assembly" mapping clause statements. The work for this issue would entail adding another stanza for "csr_name_map" clauses, storing the number as the value associated with a key which would be the register name.

The other part of the work is adding the "number" field when emitting the registers as JSON. This would entail enhancements to json_of_registers.

I hope that helps.

@Abhivic000
Copy link

Abhivic000 commented Jul 31, 2024

Hi, I'm Abhishek Singh. I'm currently working on this issue and have identified the necessary changes. If the assignee is unable to continue, please reassign it to me.

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

No branches or pull requests

3 participants