fix(dcache): 修复replace时写回逻辑问题
This commit is contained in:
parent
a99cf13f87
commit
1ce49a39b3
|
@ -177,6 +177,7 @@ class DCache(cacheConfig: CacheConfig)(implicit cpuConfig: CpuConfig) extends Mo
|
||||||
// 是否使用exe的地址进行提前访存
|
// 是否使用exe的地址进行提前访存
|
||||||
val use_next_addr = (state === s_idle) || (state === s_wait)
|
val use_next_addr = (state === s_idle) || (state === s_wait)
|
||||||
val do_replace = RegInit(false.B)
|
val do_replace = RegInit(false.B)
|
||||||
|
val readbank = RegInit(false.B)
|
||||||
// replace index 表示行的索引
|
// replace index 表示行的索引
|
||||||
val replace_index = Wire(UInt(indexWidth.W))
|
val replace_index = Wire(UInt(indexWidth.W))
|
||||||
replace_index := io.cpu.addr(indexWidth + offsetWidth - 1, offsetWidth)
|
replace_index := io.cpu.addr(indexWidth + offsetWidth - 1, offsetWidth)
|
||||||
|
@ -504,35 +505,38 @@ class DCache(cacheConfig: CacheConfig)(implicit cpuConfig: CpuConfig) extends Mo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.otherwise {
|
}.otherwise {
|
||||||
// 这里相当于增加了一拍,用于发射读写控制信号
|
// 增加了一拍,用于sram读取数据
|
||||||
do_replace := true.B
|
readbank := true.B
|
||||||
|
when(readbank) {
|
||||||
ar.len := cached_len.U
|
readbank := false.B
|
||||||
ar.size := cached_size.U // 8 字节
|
do_replace := true.B
|
||||||
arvalid := true.B
|
ar.len := cached_len.U
|
||||||
rready := true.B
|
ar.size := cached_size.U // 8 字节
|
||||||
burst.wstrb(replace_way) := 1.U // 先写入第一块bank
|
arvalid := true.B
|
||||||
tag_wstrb(replace_way) := true.B
|
rready := true.B
|
||||||
when(!ptw_working) {
|
burst.wstrb(replace_way) := 1.U // 先写入第一块bank
|
||||||
// dcache的普通模式
|
tag_wstrb(replace_way) := true.B
|
||||||
// for ar axi
|
when(!ptw_working) {
|
||||||
ar.addr := Cat(io.cpu.tlb.paddr(PADDR_WID - 1, offsetWidth), 0.U(offsetWidth.W))
|
// dcache的普通模式
|
||||||
tag_wdata := io.cpu.tlb.ptag
|
// for ar axi
|
||||||
}.otherwise {
|
ar.addr := Cat(io.cpu.tlb.paddr(PADDR_WID - 1, offsetWidth), 0.U(offsetWidth.W))
|
||||||
// ptw复用的模式
|
tag_wdata := io.cpu.tlb.ptag
|
||||||
ar.addr := Cat(ptw_scratch.paddr.tag, ptw_scratch.paddr.index, 0.U(offsetWidth.W))
|
}.otherwise {
|
||||||
tag_wdata := ptw_scratch.paddr.tag
|
// ptw复用的模式
|
||||||
}
|
ar.addr := Cat(ptw_scratch.paddr.tag, ptw_scratch.paddr.index, 0.U(offsetWidth.W))
|
||||||
when(replace_dirty) {
|
tag_wdata := ptw_scratch.paddr.tag
|
||||||
aw.addr := Cat(tag(replace_way), replace_index, 0.U(offsetWidth.W))
|
}
|
||||||
aw.len := cached_len.U
|
when(replace_dirty) {
|
||||||
aw.size := cached_size.U
|
aw.addr := Cat(tag(replace_way), replace_index, 0.U(offsetWidth.W))
|
||||||
awvalid := true.B
|
aw.len := cached_len.U
|
||||||
w.data := data(0)(replace_way)
|
aw.size := cached_size.U
|
||||||
w.strb := ~0.U(AXI_STRB_WID.W)
|
awvalid := true.B
|
||||||
w.last := false.B
|
w.data := bank_replication(0)
|
||||||
wvalid := true.B
|
w.strb := ~0.U(AXI_STRB_WID.W)
|
||||||
bank_windex := 0.U
|
w.last := false.B
|
||||||
|
wvalid := true.B
|
||||||
|
bank_windex := 0.U
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -755,7 +759,7 @@ class DCache(cacheConfig: CacheConfig)(implicit cpuConfig: CpuConfig) extends Mo
|
||||||
raisePageFault()
|
raisePageFault()
|
||||||
}.elsewhen(!pte.flag.a || access_type === AccessType.store && !pte.flag.d) {
|
}.elsewhen(!pte.flag.a || access_type === AccessType.store && !pte.flag.d) {
|
||||||
raisePageFault() // 使用软件的方式设置脏位以及访问位
|
raisePageFault() // 使用软件的方式设置脏位以及访问位
|
||||||
}.otherwise {
|
}.otherwise {
|
||||||
// 翻译成功
|
// 翻译成功
|
||||||
val rmask = WireInit(~0.U(maskLen.W))
|
val rmask = WireInit(~0.U(maskLen.W))
|
||||||
io.cpu.tlb.ptw.pte.valid := true.B
|
io.cpu.tlb.ptw.pte.valid := true.B
|
||||||
|
|
Loading…
Reference in New Issue