Commit fd73bca
committed
feat: RV32A atomics, FENCE.I, per-FU pipeline, and cache coherence fixes
## New instructions
- **RV32A**: LR.W, SC.W, and all AMO variants (AMOSWAP, AMOADD, AMOXOR,
AMOAND, AMOOR, AMOMAX, AMOMIN, AMOMAXU, AMOMINU) now route through the
cache layer via `lr_w` / `sc_w` / `amo_w` on the `Bus` trait.
LR/SC reservations are tracked per-hart inside `CacheController`
(and per-hart in the CPU registers as a fallback for bypass mode).
Any store to a reserved word cancels the reservation.
- **FENCE**: forwards to `Bus::fence()` (was a no-op).
- **FENCE.I**: implemented as `Bus::fence_i()`, invalidates the I-cache
so self-modifying code picks up freshly written instructions.
- Instruction panel type badges extended: `[A]` (atomic) and `[F]` (float).
## Cache coherence bug fixes (multi-level hierarchy)
Four bugs that caused silent data corruption when L1 D-cache + L2 are both
enabled (program crash at PC=0x00000000 with rust-to-raven.elf):
1. **Blanket L2 invalidation after write-back stores removed.**
`dcache_store_bytes` was invalidating L2 after every store. On a
write-allocate miss this sequence ran: fetch L2 → evict dirty D-cache
line → writeback dirty data to L2 → then invalidate that same L2 line.
Data ended up in neither cache level nor RAM (silent loss, corrupted
stack return addresses → PC=0).
2. **Write-through stores now correctly invalidate L2.**
Write-through keeps D-cache lines clean, so evictions never writeback
to L2. After a write-through store, the L2 copy is stale and must be
dropped so future misses re-read the updated value from RAM.
3. **`sync_to_ram` writeback order fixed.**
Was: D-cache first, then L2. Now: L2 (reversed outer levels) first,
then D-cache. D-cache is always authoritative; writing L2 last would
overwrite correct D-cache data with stale L2 data in RAM.
4. **`flush_all` writeback order fixed** (same root cause as #3).
Called when the user toggles the cache off; same reversal applied.
## Pipeline improvements
- Per-FU (ALU, MUL, DIV, FPU, LSU, SYS) stall counters and configurable
functional-unit counts.
- Branch predictor extended: not-taken (default), always-taken, BTFNT,
and 2-bit dynamic.
- Per-hazard stall tag breakdown in the pipeline footer.
- `.pcfg` config format updated: per-bypass-path flags replace single
`forwarding` boolean; `fu.*` counts added.
- Speculative Gantt: in-flight speculative instructions shown with distinct
styling; flushed instructions marked.
## rust-to-raven
- `raven_api` restructured: `hart.rs` moved to `hardware_thread/`,
`atomic/` module added with `Arc`, `AtomicBool`, `AtomicU32`, etc.
backed by LR.W/SC.W so they actually work on the simulator.
- `main.rs` updated to use `HartTask` with a closure-based API.1 parent 792b43c commit fd73bca
79 files changed
Lines changed: 8549 additions & 2085 deletions
File tree
- docs
- en
- pt-BR
- rust-to-raven
- .cargo
- .vscode
- src
- raven_api
- atomic
- hardware_thread
- src
- cli
- falcon
- asm
- cache
- decoder
- encoder
- ui
- app
- input
- keyboard
- pipeline
- tutorial/steps
- view
- cache
- docs
- content
- pipeline
- run
- tests
- support
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
83 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
84 | 93 | | |
85 | 94 | | |
86 | 95 | | |
| |||
181 | 190 | | |
182 | 191 | | |
183 | 192 | | |
184 | | - | |
| 193 | + | |
185 | 194 | | |
186 | 195 | | |
187 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
| 156 | + | |
155 | 157 | | |
156 | 158 | | |
157 | 159 | | |
| |||
401 | 403 | | |
402 | 404 | | |
403 | 405 | | |
404 | | - | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
405 | 410 | | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
406 | 417 | | |
407 | 418 | | |
408 | 419 | | |
| |||
411 | 422 | | |
412 | 423 | | |
413 | 424 | | |
414 | | - | |
415 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
416 | 431 | | |
417 | | - | |
| 432 | + | |
418 | 433 | | |
419 | 434 | | |
420 | 435 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
167 | 174 | | |
168 | 175 | | |
169 | 176 | | |
| |||
175 | 182 | | |
176 | 183 | | |
177 | 184 | | |
178 | | - | |
| 185 | + | |
179 | 186 | | |
180 | 187 | | |
181 | 188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
| 150 | + | |
150 | 151 | | |
151 | 152 | | |
152 | | - | |
153 | | - | |
| 153 | + | |
| 154 | + | |
154 | 155 | | |
| 156 | + | |
155 | 157 | | |
156 | 158 | | |
157 | 159 | | |
| |||
396 | 398 | | |
397 | 399 | | |
398 | 400 | | |
399 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
400 | 405 | | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
401 | 412 | | |
402 | 413 | | |
403 | 414 | | |
| |||
406 | 417 | | |
407 | 418 | | |
408 | 419 | | |
409 | | - | |
410 | | - | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
411 | 426 | | |
412 | | - | |
| 427 | + | |
413 | 428 | | |
414 | 429 | | |
415 | 430 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
0 commit comments