Skip to content

Commit b01d7e2

Browse files
committed
added documentation
1 parent e949057 commit b01d7e2

File tree

2 files changed

+213
-0
lines changed

2 files changed

+213
-0
lines changed
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
:doctitle: Olympia Load Store Unit (LSU) Design Document
2+
3+
:toc:
4+
5+
[[Document_Information]]
6+
== Document Information
7+
8+
=== Revision History
9+
10+
[width="100%",cols="11%,11%,16%,62%",options="header",]
11+
|===
12+
|*Revision* |*Date* |*Author* |*Summary of Changes*
13+
|0.1 | 2024.12.13 | Team | Initial LSU design document with multi-pipeline and data forwarding
14+
|===
15+
16+
=== Conventions and Terminology
17+
18+
[width="100%",cols="17%,83%",options="header",]
19+
|===
20+
|Label |Description
21+
|LSU |Load Store Unit - Handles all memory operations
22+
|MMU |Memory Management Unit - Handles virtual to physical address translation
23+
|ROB |ReOrder Buffer - Ensures in-order commitment of instructions
24+
|TLB |Translation Lookaside Buffer - Cache for virtual to physical address translations
25+
|RAW |Read After Write hazard - Load depends on earlier store
26+
|WAW |Write After Write hazard - Store depends on earlier store
27+
|CSB |Committed Store Buffer - Holds retired stores waiting to write to memory
28+
|===
29+
30+
=== Related Documents
31+
32+
[width="100%",cols="25%,75%",options="header",]
33+
|===
34+
|*Title* |*Description*
35+
|The RISC-V Instruction Set Manual Volume I |Unprivileged Architecture Version 2024041
36+
|Olympia Core Architecture |Core architecture specification
37+
|Core Memory Model |Memory subsystem specification
38+
|===
39+
40+
=== Notes/Open Issues
41+
42+
* Optimization of store buffer search for data forwarding
43+
* Handling of cache bank conflicts with multiple pipelines
44+
* Fine-tuning of pipeline stage lengths for optimal performance
45+
46+
== OVERVIEW
47+
48+
The Load Store Unit (LSU) implements the memory interface for the Olympia processor, managing all load and store operations. It features multiple parallel pipelines, data forwarding capabilities, and ensures memory consistency while maintaining high performance through careful hazard management and efficient queueing structures.
49+
50+
=== Overview Block Diagram
51+
52+
image::./media/LSU.png[LSU Block Diagram]
53+
54+
Figure 1 - LSU Block Diagram
55+
56+
== Functional Description
57+
58+
=== Unit Block Description
59+
60+
The LSU consists of several key functional blocks:
61+
62+
1. *Instruction Queues*
63+
- Load/Store Instruction Queue (ldst_inst_queue_)
64+
- Store Buffer (store_buffer_)
65+
- Ready Queue (ready_queue_)
66+
67+
2. *Pipeline Units*
68+
- Multiple parallel Load/Store pipelines
69+
- Address Generation Units
70+
- Data Forwarding Logic
71+
72+
3. *Interface Controllers*
73+
- MMU Interface
74+
- Cache Interface
75+
- ROB Interface
76+
77+
=== Key Components Detail
78+
79+
==== Load/Store Instruction Queue (ldst_inst_queue_)
80+
* Size: Configurable through ldst_inst_queue_size_ parameter
81+
* Purpose: Holds instructions from dispatch until ready for execution
82+
* Implementation: sparta::Buffer template with LoadStoreInstInfoPtr
83+
* Key Methods:
84+
[source,cpp]
85+
----
86+
void allocateInstToIssueQueue_(const InstPtr & inst_ptr)
87+
void popIssueQueue_(const LoadStoreInstInfoPtr & inst_ptr)
88+
----
89+
90+
==== Store Buffer
91+
* Size: Matches ldst_inst_queue_size_
92+
* Purpose:
93+
- Maintains program order for stores
94+
- Enables store-to-load forwarding
95+
- Tracks uncommitted stores
96+
* Implementation:
97+
[source,cpp]
98+
----
99+
sparta::Buffer<LoadStoreInstInfoPtr> store_buffer_;
100+
LoadStoreInstInfoPtr findYoungestMatchingStore_(const uint64_t addr) const;
101+
----
102+
103+
==== Pipeline Stages
104+
105+
[width="100%",cols="20%,15%,65%",options="header",]
106+
|===
107+
|Stage |Cycles |Function
108+
|Address Calculation |1 |Virtual address generation
109+
|MMU Lookup |1-N |Address translation
110+
|Cache Lookup |1-N |Cache access initiation
111+
|Cache Read |1 |Data retrieval
112+
|Complete |1 |Instruction completion
113+
|===
114+
115+
=== Operation Flow
116+
117+
1. *Instruction Receipt*
118+
- Receives instructions from dispatch
119+
- Allocates queue entries
120+
- Begins tracking dependencies
121+
122+
2. *Issue Stage*
123+
- Checks operand readiness
124+
- Verifies no hazards exist
125+
- Selects ready instructions for execution
126+
127+
3. *Execution*
128+
- Address calculation
129+
- MMU interaction
130+
- Cache access
131+
- Data forwarding when applicable
132+
133+
4. *Completion*
134+
- Updates architectural state
135+
- Handles exceptions
136+
- Signals ROB for retirement
137+
138+
=== Data Forwarding Implementation
139+
140+
The data forwarding logic is implemented through the store buffer and involves:
141+
142+
1. *Store Buffer Search*
143+
[source,cpp]
144+
----
145+
LoadStoreInstInfoPtr findYoungestMatchingStore_(const uint64_t addr) const {
146+
auto it = std::find_if(store_buffer_.rbegin(), store_buffer_.rend(),
147+
[addr](const auto& store) {
148+
return store->getInstPtr()->getTargetVAddr() == addr;
149+
});
150+
return (it != store_buffer_.rend()) ? *it : nullptr;
151+
}
152+
----
153+
154+
2. *Forward Detection*
155+
[source,cpp]
156+
----
157+
void handleCacheLookupReq_() {
158+
// ...
159+
if (!inst_ptr->isStoreInst() && allow_data_forwarding_) {
160+
const uint64_t load_addr = inst_ptr->getTargetVAddr();
161+
auto forwarding_store = findYoungestMatchingStore_(load_addr);
162+
if (forwarding_store) {
163+
mem_access_info_ptr->setDataReady(true);
164+
mem_access_info_ptr->setCacheState(MemoryAccessInfo::CacheState::HIT);
165+
return;
166+
}
167+
}
168+
// ...
169+
}
170+
----
171+
172+
=== Multi-Pipeline Design
173+
174+
The LSU implements multiple parallel pipelines through:
175+
176+
1. *Pipeline Configuration*
177+
[source,cpp]
178+
----
179+
PARAMETER(uint32_t, num_pipelines, 2, "Number of load/store pipelines")
180+
std::vector<LoadStorePipeline> ldst_pipelines_;
181+
----
182+
183+
2. *Pipeline Management*
184+
- Round-robin allocation
185+
- Independent progress tracking
186+
- Shared resource arbitration
187+
188+
== Test Bench Description
189+
190+
=== Basic Functionality Tests
191+
* Load/Store instruction handling
192+
* Address translation
193+
* Data forwarding correctness
194+
* Pipeline utilization
195+
196+
=== Corner Cases
197+
* Pipeline stalls
198+
* Exception handling
199+
* Flush scenarios
200+
* Resource conflicts
201+
202+
== Future Work
203+
204+
1. Enhanced store buffer search algorithms
205+
2. Advanced pipeline scheduling
206+
3. Improved hazard detection
207+
4. Extended performance counters
208+
209+
== References
210+
211+
[1] RISC-V Specification
212+
[2] Olympia Core Architecture Document
213+
[3] Memory Consistency Model Specification
133 KB
Loading

0 commit comments

Comments
 (0)