-
Notifications
You must be signed in to change notification settings - Fork 78
Implement vset* and vector CSRs #467
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
|
I used the vector_state() function from vec.idl (hope I used it right) to get the LMUL and SEW variables, but how do I use lmul_type to modify the operation of state.log2_multiplier? Would I do something like: ? Additionally, how should I create the CSR files for the required CSRs? Like was mentioned in our meeting, those are pretty important and should probably get done first if they don't already exist (I couldn't find any so I assume no?). And then is what I did correct in terms of using the CSRs in the operation() field, syntax wise? |
|
Shall we mark this as "draft" for now? (There's a button on the right.) |
I don't see the button but sure yeah |
There's a "convert to draft" link in the "Reviewers" section for me, at least. There's also a dropdown for the green "Create pull request" button that offers a "Create draft pull request". Just FYI. :-) |
arch/inst/V/vsetivli.yaml
Outdated
| if (xs1 < VLMAX){ | ||
| CSR[vl] = uimm; | ||
| } else { | ||
| CSR[vl] = VLMAX; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to capture the two other cases listed in the spec:
ceil(AVL / 2) ≤ vl ≤ VLMAX if AVL < (2 * VLMAX)
If uimm/AVL is less than 2*VLMAX, then the setting of vl is implementation-dependent, subject to the above constraint. We need to add a parameter to the V extension to capture some probable behaviors, with a fallback on unpredictable(). Something like RVV_VL_WHEN_AVL_LT_DOUBLE_VLMAX, with possible values "ceil(AVL/2)", "VLMAX", "custom".
vl = VLMAX if AVL ≥ (2 * VLMAX)
arch/inst/V/vsetivli.yaml
Outdated
| CSR[vl] = VLMAX; | ||
| } | ||
| CSR[vtype] = zimm11; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check for illegal vtype, and set vill if so.
|
@dhower-qc added at least the skeleton for CSRs, but have some questions on the following:
|
arch/csr/V/vl.yaml
Outdated
| and supporting SEW=8 would need at least six bits in vl to hold the values 0-32 | ||
| (VLEN=32, with LMUL=8 and SEW=8, yields VLMAX=32). | ||
| type: RO #?? | ||
| reset_value: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UNDEFINED_LEGAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how was this resolved?
|
Ok I think I've successfully rebased my branch, took some effort due to the directory structure changes, but I got it. Now when I run ./do test:idl, I get the following error: Am I missing something in my setup? |
|
Try: (or "rv64" or the other configs in |
|
ok... progress. IDL doesn't seem to like me using the widening operation that depends on the vector state (line 29). |
Using this list of enums seems strange to me. Can it be described as a function like |
|
@dhower-qc ./do test:idl and smoke are both passing now for cfgs rv32/64. Had a decent amount of compilation errors to clean up, but it's all fixed now. all that's missing now is 1 more review and the instruction tests we discussed this week, and we're ready to merge! |
spec/std/isa/csr/V/vstart.yaml
Outdated
| sw_write(csr_value): | | ||
| return csr_value.VALUE & (VLEN - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec says:
The vstart CSR is defined to have only enough writable bits to hold the largest element index (one less than the maximum VLMAX).
VLEN units are bits, but vstart units are elements.
This means that:
- The defined number of bits the largest to hold the biggest
VLMAX, which happens when LMUL is maxed out and SEW is minimum.(LMUL_MAX * VLEN / SEW_MIN). Assuming both LMUL_MAX and SEW_MIN are 8, the biggest VLMAX is 256. - When SEW/LMUL have different settings, there will be 'reserved' bits in vstart. It is undefined what happens when you write non-zero into the reserved bits, but there is a recommendation that it takes a takes a trap. This is a parameter that needs to be added.
| # SPDX-SnippetBegin | ||
| # SPDX-FileCopyrightText: 2017-2025 Contributors to the RISCV Sail Model <https://github.com/riscv/sail-riscv/blob/master/LICENCE> | ||
| # SPDX-License-Identifier: BSD-2-Clause | ||
| sail(): | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did this come from? If you wrote it, I admire the effort. We probably want to treat Sail content as a unit, and find a programmatic way to bring it all from the canonical Sail code at once (or continually, but not manually). Reluctantly, I suggest that you remove this code and leave the sail() method empty here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still needs attention.
Co-authored-by: Paul Clarke <[email protected]> Signed-off-by: Jennifer Dupaquier <[email protected]>
Co-authored-by: Paul Clarke <[email protected]> Signed-off-by: Jennifer Dupaquier <[email protected]>
Co-authored-by: Paul Clarke <[email protected]> Signed-off-by: Jennifer Dupaquier <[email protected]>
Co-authored-by: Paul Clarke <[email protected]> Signed-off-by: Jennifer Dupaquier <[email protected]>
Co-authored-by: Paul Clarke <[email protected]> Signed-off-by: Jennifer Dupaquier <[email protected]>
| $schema: "csr_schema.json#" | ||
| kind: csr | ||
| name: vxsat | ||
| long_name: Vector Fixed-Point Saturate Flag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| long_name: Vector Fixed-Point Saturate Flag | |
| long_name: Vector Fixed-Point Saturation Flag |
| $schema: "csr_schema.json#" | ||
| kind: csr | ||
| name: vcsr | ||
| long_name: Vector Control and Status Register |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| long_name: Vector Control and Status Register | |
| long_name: Vector Control and Status |
I'm basing this on the spec's convention to call the section for the register "[long_name] (mnemonic) Register", like:
Vector Type (
vtype) Register
Vector Length (vl) Register
Vector Byte Length (vlenb) Register
and so on. vcsr is listed thus:
Vector Control and Status (
vcsr) Register
Adding IDL support and instruction details for Vector Extension
2/27 work in progress, do not merge to main yet. PR is for review purposes only