-
Notifications
You must be signed in to change notification settings - Fork 1
spec: rework CPU for smaller footprint #624
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
40cc0bc
spec: Draft CPU rework, still missing updates for all ALU chips, DECO…
RobinJadoul eaffb54
Decoding for the new CPU
RobinJadoul 97c17ce
Bitwise using BYTE_ALU
RobinJadoul c003b61
Update old chips for the new CPU
RobinJadoul dd81c6b
Fix decode for MEMORY signed flag
RobinJadoul cc50d00
Add input range check to SHIFTs typ
RobinJadoul 720512c
MEMORY signature HL -> WL
RobinJadoul ce1a06a
Clarify SHIFTW decoding
RobinJadoul 5158513
Further updates and new chips for the new CPU
RobinJadoul d90ebc6
Fix arg2 muxes
RobinJadoul 8c0b399
Link instruction length to CPU32
RobinJadoul 761abbd
Apply easy changes from code review
RobinJadoul 013b865
Address more review comments
RobinJadoul f3b041d
Fix CPU32 register interactions
RobinJadoul 88fc8cf
Fix CPUs PC write multiplicity
RobinJadoul 7d14501
Fix HALT's interaction with the CPU padding
RobinJadoul 9b30b9e
Add some optional extra arith constraints to enforce the "easy" assum…
RobinJadoul a495f8e
Combine assumptions constraints
RobinJadoul 322bfbc
Remove todo comments that got a tracking issue
RobinJadoul 1dee915
word_instr gate for read_registerX out of caution
RobinJadoul c9540a5
Fix JAL(R) decoding and ALU
RobinJadoul dad2eea
Placate the type checker
RobinJadoul b1b51c9
Represent instruction length as half
RobinJadoul fdcf023
Update spec/src/cpu.toml
RobinJadoul 9be4ecd
fixes
RobinJadoul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #import "/book.typ": book-page, rj | ||
| #import "/src.typ": load_config, load_chip | ||
| #import "/chip.typ": ( | ||
| render_chip_assumptions, | ||
| render_chip_variable_table, | ||
| total_nr_variables, | ||
| total_nr_instantiated_columns, | ||
| compute_nr_interactions, | ||
| render_constraint_table, | ||
| render_chip_padding_table, | ||
| ) | ||
|
|
||
| #let config = load_config() | ||
| #let chip = load_chip("src/bytewise.toml", config) | ||
|
|
||
| #show: book-page(chip.name) | ||
| #let bytewise = raw(chip.name) | ||
|
|
||
| The #bytewise chip is an ALU chip that decomposes the input `DWordWL` values into bytes and | ||
| performs a `BITWISE` operation pairwise (AND, OR, XOR). | ||
| The `BITWISE` lookup inherently performs a range check, so no further constraints are necessary. | ||
|
|
||
| = Variables | ||
| #let nr_variables = total_nr_variables(chip) | ||
| #let nr_columns = total_nr_instantiated_columns(chip, config) | ||
| #let nr_interactions = compute_nr_interactions(chip) | ||
|
|
||
| The #bytewise chip is comprised of #nr_variables variables that are expressed using #nr_columns columns and leverages #nr_interactions interaction(s): | ||
| #render_chip_variable_table(chip, config) | ||
|
|
||
| = Constraints | ||
|
|
||
| #render_constraint_table(chip, config) | ||
|
|
||
| = Padding | ||
|
|
||
| The chip can be padded with the following values: | ||
| #render_chip_padding_table(chip, config) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #import "/book.typ": book-page, rj | ||
| #import "/src.typ": load_config, load_chip | ||
| #import "/chip.typ": ( | ||
| render_chip_assumptions, | ||
| render_chip_variable_table, | ||
| render_chip_padding_table, | ||
| render_constraint_table, | ||
| compute_nr_interactions, | ||
| total_nr_instantiated_columns, | ||
| total_nr_variables, | ||
| ) | ||
|
|
||
| #let config = load_config() | ||
| #let chip = load_chip("src/cpu32.toml", config) | ||
|
|
||
| #show: book-page(chip.name) | ||
| #let cpu32 = raw(chip.name) | ||
|
|
||
| The #cpu32 chip is used to delegate the 32-bit instructions of the RV64I instruction set | ||
| from the main CPU table (@cpu). | ||
| All 32-bit instructions are ALU-only instructions, so the BRANCH, MEMORY and ECALL paths need no elaboration. | ||
| The timestamp and PC have already been read by the CPU table at this point, and need no further checking; | ||
| the PC for the next instruction will also already be handled by CPU. | ||
|
|
||
| The structure follows the regular ALU path, with some extra variables and constraints to contain the required sign extensions. | ||
|
|
||
| = Variables | ||
| #let nr_variables = total_nr_variables(chip) | ||
| #let nr_columns = total_nr_instantiated_columns(chip, config) | ||
| #let nr_interactions = compute_nr_interactions(chip) | ||
|
|
||
| The #cpu32 chip is comprised of #nr_variables variables that are expressed using #nr_columns columns and leverages #nr_interactions interaction(s): | ||
| #render_chip_variable_table(chip, config) | ||
|
|
||
| = Assumptions | ||
|
|
||
| #render_chip_assumptions(chip, config) | ||
|
|
||
| Some of the assumptions can be checked with only arithmetic constraints, so we | ||
| provide these below. | ||
|
|
||
| #render_constraint_table(chip, config, groups: "assumptions") | ||
|
|
||
| = Constraints | ||
|
|
||
| Most constraints correspond to those already present in the CPU, and we present them here first, | ||
| including some updates to the range checking corresponding to the differing types. | ||
|
|
||
| #render_constraint_table(chip, config, groups: ("decode", "range", "alu", "mem", "logup")) | ||
|
|
||
| Then, we have the constraints corresponding to the sign-extension and definition of `arg1`, `arg2` and `rd`. | ||
| This includes a step where we extract the `signed` bit from the `alu_flags`, as this determines | ||
| whether to sign extend the inputs or not. | ||
|
|
||
| #render_constraint_table(chip, config, groups: "ext") | ||
|
|
||
| = Padding | ||
|
|
||
| The table can be padded with the following values: | ||
| #render_chip_padding_table(chip, config) | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.