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

add checks on slack bits #217

Merged
merged 15 commits into from
Jul 11, 2024
Merged

add checks on slack bits #217

merged 15 commits into from
Jul 11, 2024

Conversation

yoichi-nexus
Copy link
Contributor

@yoichi-nexus yoichi-nexus commented Jul 10, 2024

@michel-nexus noticed that the unused bits can be checked to be a specific value, like in RISC-V ISA. This PR implements this idea.

Copy link

vercel bot commented Jul 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nexus-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 11, 2024 4:06pm

Before this commit, one function called aop() was responsible for
parsing arithmetic instructions both with and without immediate
values. After this commit, aop() is responsible for instructions
without immediate values. A new function aopi() takes over the
arithmetic instructions with immediate values.

Arithmetic instructions with/without immediate values have
different kind of checks with respect to funct7 bits. Two separate
functions are easier to read.
@yoichi-nexus yoichi-nexus marked this pull request as ready for review July 11, 2024 13:43
yoichi-nexus added a commit that referenced this pull request Jul 11, 2024
The corresponding changes are being made in #217
Copy link
Contributor

@sjudson sjudson left a comment

Choose a reason for hiding this comment

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

Overall this looks great.

assert_eq!(opcode(word), OPC_ALUI);
let res = match (funct3(word), funct7(word)) {
(0b000, _) => ADD,
(0b001, 0b0000000) => SLL,
Copy link
Contributor

Choose a reason for hiding this comment

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

We should document here with a comment that funct7 happens to capture the same set of bits as the imm[11:6] chunk that distinguishes the type of intermediate-based shift (slli vs. srli vs. srai).

Otherwise at first glance it looks like we're parsing them wrong since they don't include a funct7 chunk.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comments.

Copy link
Contributor

Choose a reason for hiding this comment

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

These weren't really the comments I was looking for. What was confusing wasn't the _ matching on the lines that use the full intermediate, what was confusing was the explicit matching for the shifts (since they don't use funct7 at all). If you can add (technicallly imm[11:5]) like above that'd be great.

vm/src/rv32/parse.rs Show resolved Hide resolved
vm/src/circuit/riscv.rs Outdated Show resolved Hide resolved
vm/src/circuit/riscv.rs Show resolved Hide resolved
Copy link
Contributor

@sjudson sjudson left a comment

Choose a reason for hiding this comment

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

One last minor quibble, but otherwise looks good.

vm/src/circuit/riscv.rs Show resolved Hide resolved
assert_eq!(opcode(word), OPC_ALUI);
let res = match (funct3(word), funct7(word)) {
(0b000, _) => ADD,
(0b001, 0b0000000) => SLL,
Copy link
Contributor

Choose a reason for hiding this comment

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

These weren't really the comments I was looking for. What was confusing wasn't the _ matching on the lines that use the full intermediate, what was confusing was the explicit matching for the shifts (since they don't use funct7 at all). If you can add (technicallly imm[11:5]) like above that'd be great.

@yoichi-nexus
Copy link
Contributor Author

One last minor quibble, but otherwise looks good.

I did a few more git push'es to give better approximation in comment formulation.

vm/src/rv32/parse.rs Show resolved Hide resolved
(0b010, _ /* imm[11:5] can be any */) => SLT,
(0b011, _ /* imm[11:5] can be any */) => SLTU,
(0b100, _ /* imm[11:5] can be any */) => XOR,
(0b101, 0b0000000 /* shift amount is required to be small */) => SRL,
Copy link
Contributor

Choose a reason for hiding this comment

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

Also I'm confused by the "small" part, this value doesn't have anything to do with the shift amount, right? It's a fixed value to indicate the type of shift, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can argue both ways, but I'll just say something else, like, SLLI requires special value here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@yoichi-nexus yoichi-nexus merged commit d216a62 into main Jul 11, 2024
7 checks passed
@yoichi-nexus yoichi-nexus deleted the stricter-format-checks branch July 11, 2024 16:16
yoichi-nexus added a commit that referenced this pull request Jul 11, 2024
The corresponding changes are being made in #217
yoichi-nexus added a commit that referenced this pull request Jul 15, 2024
The corresponding changes are being made in #217
yoichi-nexus added a commit that referenced this pull request Jul 15, 2024
The corresponding changes are being made in #217
yoichi-nexus added a commit that referenced this pull request Jul 15, 2024
The corresponding changes are being made in #217
yoichi-nexus added a commit that referenced this pull request Jul 15, 2024
The corresponding changes are being made in #217
yoichi-nexus added a commit that referenced this pull request Jul 16, 2024
The corresponding changes are being made in #217
yoichi-nexus added a commit that referenced this pull request Jul 16, 2024
The corresponding changes are being made in #217
yoichi-nexus added a commit that referenced this pull request Jul 16, 2024
The corresponding changes are being made in #217
yoichi-nexus added a commit that referenced this pull request Jul 16, 2024
The corresponding changes are being made in #217
yoichi-nexus added a commit that referenced this pull request Jul 16, 2024
The corresponding changes are being made in #217
yoichi-nexus added a commit that referenced this pull request Jul 16, 2024
The corresponding changes are being made in #217
yoichi-nexus added a commit that referenced this pull request Jul 16, 2024
* Spec initial pass

* Remove translation

* Update instruction list

* Updating instruction layout table

(I'm appending changes to this commit until the update completes.)

* Update prose

* Describe auipc instruction

* Describe lui instruction

* Fix typo

* Describe unimp instruction

* Describe fence instruction

* Another pass on the prose

* Add vm architecture drawio file

with permission of Michel Abdalla

* Update architecture diagram

Just one input tape for private input for now.

* Another pass

* Review

* Review: ecall and ebreak take rd register selector

* Strictor bit pattern as in RISC-V

The corresponding changes are being made in #217

* Explicitly describe the sizes of immediates

* Opcode vs mnemonic changes

* Rephrase sign/zero extension

* lw doesn't perform any extension, zero or signed

* More specific wording on which byte/half-word gets stored

* Add missing angle brackets

* Modify version numbers

* Addressing review comments

* Change version sequences in the roadmap
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