Skip to content

Commit 83effcd

Browse files
Add documentation for LSU (#161)
1 parent 8d187b2 commit 83effcd

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

docs/lsu.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# LSU
2+
The design of the LSU is loosely based on the LSU implementation in [BOOM](https://docs.boom-core.org/en/latest/sections/load-store-unit.html) microarchitecture and the [E500](https://www.nxp.com/docs/en/reference-manual/E500CORERM.pdf) core.
3+
4+
### Ports
5+
in_lsu_insts <-- Input from Dispatch (Receive new memory instructions)
6+
7+
in_cache_lookup_ack <-- Input from DCache (Receive acknowledgement from cache if the data is present)
8+
9+
in_cache_lookup_req <-- Input from DCache (Receive data for the cache lookup request)
10+
11+
in_cache_free_req <-- Input from DCache (Cache lets the lsu know that its ready to accept new lookup requests)
12+
13+
out_cache_lookup_req --> Output to DCache (Send a cache lookup request for a particular address)
14+
15+
in_mmu_lookup_ack <-- Input from MMU (Receive acknowledgement from MMU of particular virtual address lookup)
16+
17+
in_mmu_lookup_req <-- Input from MMU (Receive physical address for the virtual address lookup request)
18+
19+
out_mmu_lookup_req --> Output to DCache (Send a VA to PA address translation request)
20+
21+
22+
### Configuration Parameters
23+
`ldst_inst_queue_size` - Size of the LSU instruction queue
24+
25+
`allow_speculative_load_exec` - Allow loads to proceed speculatively before all older store addresses are known.
26+
27+
`replay_buffer_size` - Size of the replay buffer. Defaults to the same size of the LSU instruction queue.
28+
29+
`replay_issue_delay` - Delay in cycles to replay the instruction.
30+
31+
`mmu_lookup_stage_length` - Number of cycles to complete a MMU lookup stage.
32+
33+
`cache_lookup_stage_length` - Number of cycles to complete a Cache lookup stage.
34+
35+
`cache_read_stage_length` - Number of cycles to complete a Cache read stage
36+
37+
### Available counters
38+
`lsu_insts_dispatched` - Number of LSU instructions dispatched
39+
40+
`stores_retired` - Number of stores retired
41+
42+
`lsu_insts_issued` - Number of LSU instructions issued
43+
44+
`replay_insts` - Number of Replay instructions issued
45+
46+
`lsu_insts_completed` - Number of LSU instructions completed
47+
48+
`lsu_flushes` - Number of instruction flushes at LSU
49+
50+
### Microarchitecture
51+
The Load Unit currently has only one pipeline. It has five distinct stages.The instructions always flow through the pipeline in the order mentioned below.
52+
53+
- ADDRESS_CALCULATION - The virtual address is calculated
54+
- MMU_LOOKUP - Translation of the VA to PA
55+
- CACHE_LOOKUP - Lookup data for the PA present in the cache
56+
- CACHE_READ - Receive data from the cache
57+
- COMPLETION - Final stage of the pipeline to cleanup and deallocate instructions
58+
59+
If the MMU or CACHE responds with a miss for the lookup requests, the instruction is removed from the pipeline.Once the units respond with an `ack`, the instruction is marked as ready to added back into the pipeline.
60+
61+
The completion stage is responsible to remove the instruction from the issue queue once the instruction has completed executing.
62+
63+
##### Typical Flow
64+
```
65+
handleOperandIssueCheck_ ->
66+
appendToReadyQueue_() ->
67+
issueInst_() ->
68+
handleAddressCalculation_() ->
69+
handleMMULookupReq_() ->
70+
handleCacheLookupReq_() ->
71+
handleCacheRead_() ->
72+
completeInst_()
73+
```
74+
#### Speculative Execution
75+
By default the LSU operates with `allow_speculative_execution`, which allows loads to proceed even if older load address is not know.
76+
77+
The replay queue is used to store the instruction if the instruction has a corresponding miss from the mmu or cache.
78+
The `replay_delay` specifies the delay until the request which was present in the replay queue needs to be added back into the pipeline.
79+
80+
Speculated Load instructions are removed from the pipeline if an older store receives its PA or there are existing older stores that are waiting in the queue, this prevents the load store hazard.
81+
82+
---
83+
### Others
84+
The LSU contains a virtual queue called the `ready_queue` to hold instructions which are ready to be pushed into the LSU pipeline.This queue is model specific queue and doesnt affect the microarchitecture of the LSU.Its used to reduce quering the LSU's instruction queue for a potentially ready instruction.
85+
It is based on a priority queue which sorts orders based on the age of the instruction.

0 commit comments

Comments
 (0)