Add Load/Store Unit #16

Merged
programmerjake merged 4 commits from programmerjake/cpu:load_store into master 2026-08-07 05:55:58 +00:00

This covers all the logic between the rename/execute/retire circuits and the d-cache, this includes the store queue, store-to-load forwarding, speculatively loading from the cache, managing dependencies between loads/stores, etc.

The d-cache just has to handle running loads/stores of sets of bytes in proper sequence, as well as a separate speculative load interface (which only returns data for cache hits). There's also space in the d-cache interface for reporting writes/flushes caused by i/o devices or other cpu cores, but actually handling those is left for another PR for libre-chip/grant-tracking#20.

It tests by making random sequences of up to 8 loads/stores and running them and randomly causing cancels (within the limits of what the load/store unit was told about if instructions are speculative) and then when all instructions have retired it verifies that the final memory state matches what's expected (which includes both cacheable memory's values as well as the exact sequence of I/O reads/writes). it runs that test sequence 40 times with different random seeds.

I added ExecuteToUnitInterface::other_units_cant_cause_cancels_before to the rename/execute/retire logic to tell units when the only thing that can cancel a µOp is the same unit it's in, this allows more efficient load/store pipelining because the load/store unit doesn't have to wait for a load/store to be fully non-speculative before running it since it can cause globally-visible side-effects which can't happen until the CPU knows it isn't mis-speculated.

I also added a flag for uncacheable load/stores to LoadStoreMOp.

Closes: libre-chip/grant-tracking#17
Closes: libre-chip/grant-tracking#18

This covers all the logic between the rename/execute/retire circuits and the d-cache, this includes the store queue, store-to-load forwarding, speculatively loading from the cache, managing dependencies between loads/stores, etc. The d-cache just has to handle running loads/stores of sets of bytes in proper sequence, as well as a separate speculative load interface (which only returns data for cache hits). There's also space in the d-cache interface for reporting writes/flushes caused by i/o devices or other cpu cores, but actually handling those is left for another PR for https://git.libre-chip.org/libre-chip/grant-tracking/issues/20. It tests by making random sequences of up to 8 loads/stores and running them and randomly causing cancels (within the limits of what the load/store unit was told about if instructions are speculative) and then when all instructions have retired it verifies that the final memory state matches what's expected (which includes both cacheable memory's values as well as the exact sequence of I/O reads/writes). it runs that test sequence 40 times with different random seeds. I added `ExecuteToUnitInterface::other_units_cant_cause_cancels_before` to the rename/execute/retire logic to tell units when the only thing that can cancel a µOp is the same unit it's in, this allows more efficient load/store pipelining because the load/store unit doesn't have to wait for a load/store to be fully non-speculative before running it since it can cause globally-visible side-effects which can't happen until the CPU knows it isn't mis-speculated. I also added a flag for uncacheable load/stores to `LoadStoreMOp`. Closes: https://git.libre-chip.org/libre-chip/grant-tracking/issues/17 Closes: https://git.libre-chip.org/libre-chip/grant-tracking/issues/18
programmerjake added 3 commits 2026-07-31 04:24:17 +00:00
programmerjake added 1 commit 2026-07-31 23:52:19 +00:00
WIP: adding ExecuteToUnitInterface::is_no_longer_speculative_prediction
Some checks failed
/ test (pull_request) Failing after 2m42s
59970cd316
programmerjake force-pushed load_store from 59970cd316 to 7038be9268 2026-08-01 01:56:26 +00:00 Compare
programmerjake changed title from Add Load/Store Unit to WIP: Add Load/Store Unit 2026-08-01 01:57:03 +00:00
programmerjake force-pushed load_store from 7038be9268 to 6e3486bfbb 2026-08-04 04:17:00 +00:00 Compare
programmerjake force-pushed load_store from 6e3486bfbb to acecc74ea0 2026-08-05 03:06:27 +00:00 Compare
programmerjake force-pushed load_store from acecc74ea0 to 405ed7b6c5 2026-08-06 04:52:36 +00:00 Compare
programmerjake force-pushed load_store from 405ed7b6c5 to 017eff9e97 2026-08-07 04:59:14 +00:00 Compare
programmerjake changed title from WIP: Add Load/Store Unit to Add Load/Store Unit 2026-08-07 05:54:42 +00:00
programmerjake merged commit 017eff9e97 into master 2026-08-07 05:55:58 +00:00
programmerjake deleted branch load_store 2026-08-07 05:58:53 +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#16
No description provided.