1
0

DebugModule: Be more paranoid about addressing corner cases.

This commit is contained in:
Megan Wachs 2016-10-26 18:03:07 -07:00 committed by Wesley W. Terpstra
parent b99662796d
commit 5090ff945b

View File

@ -480,6 +480,9 @@ trait DebugModule extends Module with HasDebugModuleParameters with HasRegMap {
val dbRamRdEn = Wire(Bool()) val dbRamRdEn = Wire(Bool())
val dbRamWrEnFinal = Wire(Bool()) val dbRamWrEnFinal = Wire(Bool())
val dbRamRdEnFinal = Wire(Bool()) val dbRamRdEnFinal = Wire(Bool())
require((cfg.nDebugRamBytes % ramDataBytes) == 0)
val dbRamDataOffset = log2Up(ramDataBytes)
// --- Debug Bus Accesses // --- Debug Bus Accesses
@ -606,10 +609,7 @@ trait DebugModule extends Module with HasDebugModuleParameters with HasRegMap {
// 0x40 - 0x6F Not Implemented // 0x40 - 0x6F Not Implemented
dbRamAddr := dbReq.addr( ramAddrWidth-1 , 0) dbRamAddr := dbReq.addr( ramAddrWidth-1 , 0)
dbRamWrData := dbReq.data dbRamWrData := dbReq.data
dbRamAddrValid := Bool(true) dbRamAddrValid := (dbReq.addr(3,0) <= UInt((cfg.nDebugRamBytes/ramDataBytes)))
if (ramAddrWidth < 4){
dbRamAddrValid := (dbReq.addr(3, ramAddrWidth) === UInt(0))
}
val dbRamRdDataFields = List.tabulate(cfg.nDebugRamBytes / ramDataBytes) { ii => val dbRamRdDataFields = List.tabulate(cfg.nDebugRamBytes / ramDataBytes) { ii =>
val slice = ramMem.slice(ii * ramDataBytes, (ii+1)*ramDataBytes) val slice = ramMem.slice(ii * ramDataBytes, (ii+1)*ramDataBytes)
@ -620,7 +620,7 @@ trait DebugModule extends Module with HasDebugModuleParameters with HasRegMap {
when (dbRamWrEnFinal) { when (dbRamWrEnFinal) {
for (ii <- 0 until ramDataBytes) { for (ii <- 0 until ramDataBytes) {
ramMem(dbRamAddr * UInt(ramDataBytes) + UInt(ii)) := dbRamWrData((8*(ii+1)-1), (8*ii)) ramMem((dbRamAddr << UInt(dbRamDataOffset)) + UInt(ii)) := dbRamWrData((8*(ii+1)-1), (8*ii))
} }
} }