implement "Create the next-instruction logic" and "Create a model of the instruction fetch/decode control system" #5

Merged
programmerjake merged 19 commits from programmerjake/cpu:next-pc into master 2025-12-17 07:55:08 +00:00

This adds all the logic for running the fetch/decode and branch prediction stuff, except that the actual memory fetches and instruction decoding pipe isn't part of this set of tasks.

This uses 3 different predictors:

  • a branch target buffer
  • a branch predictor that uses a hash of the pc and branch history to index a table of 2-bit branch predictors
  • a call/return stack predictor

It has interfaces to the input and output of the fetch/decode pipe and also has an interface to the rename/dispatch/execute/retire logic to feed instructions in and get retired instructions out, handling any cancels generated.

It supports superscalar instruction fetch, though it is currently limited to one branch per cycle.
the test uses a fetch block size of 8 bytes and a maximum throughput of 2 instructions per cycle.

It also has the logic needed to clear the state on reset, not depending on FPGAs being able to initialize SRAM on startup.

I have it running a simple recursive-descent expression parser as a non-trivial demo program that has calls and branches and conditional branches.

It can very much use more optimization, but implementing this has taken much longer than planned, so now that the tests pass and everything works I think this is good enough for now and more optimization can be done at some later point.

Fixes: libre-chip/grant-tracking#13
Fixes: libre-chip/grant-tracking#10

This adds all the logic for running the fetch/decode and branch prediction stuff, except that the actual memory fetches and instruction decoding pipe isn't part of this set of tasks. This uses 3 different predictors: * a branch target buffer * a branch predictor that uses a hash of the pc and branch history to index a table of 2-bit branch predictors * a call/return stack predictor It has interfaces to the input and output of the fetch/decode pipe and also has an interface to the rename/dispatch/execute/retire logic to feed instructions in and get retired instructions out, handling any cancels generated. It supports superscalar instruction fetch, though it is currently limited to one branch per cycle. the test uses a fetch block size of 8 bytes and a maximum throughput of 2 instructions per cycle. It also has the logic needed to clear the state on reset, not depending on FPGAs being able to initialize SRAM on startup. I have it running a simple recursive-descent expression parser as a non-trivial demo program that has calls and branches and conditional branches. It can very much use more optimization, but implementing this has taken much longer than planned, so now that the tests pass and everything works I think this is good enough for now and more optimization can be done at some later point. Fixes: libre-chip/grant-tracking#13 Fixes: libre-chip/grant-tracking#10
programmerjake added 13 commits 2025-12-15 10:53:18 +00:00
programmerjake added 1 commit 2025-12-15 11:01:12 +00:00
add missing copyright header and check-copyright.sh support for .mermaid
Some checks failed
/ test (pull_request) Failing after 18m42s
bc9a3a5ce7
programmerjake added 1 commit 2025-12-16 05:41:36 +00:00
programmerjake added 1 commit 2025-12-16 10:32:33 +00:00
WIP fixing bugs
Some checks failed
/ test (pull_request) Failing after 18m46s
59da0aec06
programmerjake added 1 commit 2025-12-17 07:07:02 +00:00
next_pc works afaict
Some checks failed
/ test (pull_request) Has been cancelled
d5a7d9dd9e
programmerjake added 1 commit 2025-12-17 07:10:57 +00:00
add link to other NLnet task and note lack of optimization
Some checks failed
/ test (pull_request) Has been cancelled
2de4a67360
programmerjake added 1 commit 2025-12-17 07:26:18 +00:00
fix vcd to match test output
All checks were successful
/ test (pull_request) Successful in 27m4s
/ test (push) Successful in 26m56s
3b5104c8fa
programmerjake changed title from WIP: implement "Create the next-instruction logic" and "Create a model of the instruction fetch/decode control system" to implement "Create the next-instruction logic" and "Create a model of the instruction fetch/decode control system" 2025-12-17 07:46:06 +00:00
programmerjake merged commit 3b5104c8fa into master 2025-12-17 07:55:08 +00:00
programmerjake deleted branch next-pc 2025-12-17 07:55:08 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: libre-chip/cpu#5
No description provided.