Half-working load.

This commit is contained in:
Sebastian Bugge 2024-09-27 07:51:25 +02:00
parent 961ae49523
commit f7c93b1292
Signed by: kaholaz
GPG key ID: 2EFFEDEE03519691
8 changed files with 112 additions and 36 deletions

View file

@ -18,6 +18,11 @@ class MemoryFetch() extends MultiIOModule {
val io = IO(
new Bundle {
val ALUResult = Input(UInt(32.W)) // We get ALUResult one cycle early
val writeData = Input(UInt(32.W))
val readMem = Input(Bool())
val writeMem = Input(Bool())
val dataOut = Output(UInt(32.W))
})
@ -35,7 +40,15 @@ class MemoryFetch() extends MultiIOModule {
/**
* Your code here.
*/
DMEM.io.dataIn := 0.U
DMEM.io.dataAddress := 0.U
DMEM.io.writeEnable := false.B
DMEM.io.dataIn := io.writeData
DMEM.io.dataAddress := io.ALUResult
DMEM.io.writeEnable := io.writeMem
// ALUResult is one cycle early!
val ALUResult = RegInit(UInt(32.W), 0.U)
ALUResult := io.ALUResult
when(io.readMem) {
io.dataOut := DMEM.io.dataOut
}.otherwise(io.dataOut := ALUResult)
}