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

[Draft] Script to generate instr_dict.json from riscv-opcodes using UDB data #327

Closed
wants to merge 0 commits into from

Conversation

BrianAnakPintar
Copy link
Contributor

This is a draft PR for #300

I included a instr_dict.json which I generated from riscv-opcodes which has data as of Nov 28, 2024

There's 2 main scripts involved here.

  1. generate_instr_dict.py: This script generates a file called data.json which is equivalent of the instr_dict.json from riscv-opcodes but using the data from UDB.
  2. sorter.py: This script generates 2 files which sorts data.json and instr_dict.json to make it easier to diff the 2 files.

Known issues:
I use this site to diff the 2 files and here are some immediate issues

  1. Sometimes there are more extensions in UDB than there are in riscv-opcodes. For example the instruction add.uw. Iirc, this is because 1 extension encapsulates the other extension.
  2. Missing instructions Vector Load/Store Segment Instruction mnemonics are missing #314
  3. Unknown ways to get variable_fields. I'm unsure on how to handle some cases like imm where it can range from either immxx where xx is just the size of the range but also deal with cases where imm turns into bimm12hi and bimm12lo for instructions like beq. There are more cases of these.
  4. rori contains incorrect encoding. I'll open a separate pull request for this.

These are currently the roadblocks that I am facing and I can't seem to resolve them. Feel free to give feedback or modify the script if necessary. There's also some redundant functions such as find_first_match which I previously used but no longer require, but I kept it for now in case anyone finds it useful. I also tried adding types to most of these functions to make it easier to follow through.

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.

1 participant