Skip to content

Commit

Permalink
VLSU: fix the problem caused by the 'segmentUnit' not connecting with…
Browse files Browse the repository at this point in the history
… 'sbufferVecDifftestInfo'.
  • Loading branch information
Anzooooo authored and Tang-Haojin committed Jul 4, 2024
1 parent be867eb commit 6edb148
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
37 changes: 24 additions & 13 deletions src/main/scala/xiangshan/backend/MemBlock.scala
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,16 @@ class MemBlockImp(outer: MemBlock) extends LazyModuleImp(outer)
for (j <- 0 until TriggerNum)
PrintTriggerInfo(tEnable(j), tdata(j))

// The segment instruction is executed atomically.
// After the segment instruction directive starts executing, no other instructions should be executed.
val vSegmentFlag = RegInit(false.B)

when(vSegmentUnit.io.in.fire){
vSegmentFlag := true.B
}.elsewhen(vSegmentUnit.io.uopwriteback.valid){
vSegmentFlag := false.B
}

// LoadUnit
val correctMissTrain = Constantin.createRecord(s"CorrectMissTrain$hartId", initValue = false)

Expand Down Expand Up @@ -728,16 +738,6 @@ class MemBlockImp(outer: MemBlock) extends LazyModuleImp(outer)
vSegmentUnit.io.rdcache.req.ready := dcache.io.lsu.load(i).req.ready
}


// The segment instruction is executed atomically.
// After the segment instruction directive starts executing, no other instructions should be executed.
val vSegmentFlag = RegInit(false.B)

when(vSegmentUnit.io.in.fire){
vSegmentFlag := true.B
}.elsewhen(vSegmentUnit.io.uopwriteback.valid){
vSegmentFlag := false.B
}
// Dcache requests must also be preempted by the segment.
when(vSegmentFlag){
loadUnits(i).io.dcache.req.ready := false.B // Dcache is preempted.
Expand Down Expand Up @@ -1334,10 +1334,21 @@ class MemBlockImp(outer: MemBlock) extends LazyModuleImp(outer)
dcache.io.force_write := lsq.io.force_write

// Initialize when unenabled difftest.
sbuffer.io.vecDifftestInfo := DontCare
lsq.io.sbufferVecDifftestInfo := DontCare
sbuffer.io.vecDifftestInfo := DontCare
lsq.io.sbufferVecDifftestInfo := DontCare
vSegmentUnit.io.vecDifftestInfo := DontCare
if (env.EnableDifftest) {
lsq.io.sbufferVecDifftestInfo <> sbuffer.io.vecDifftestInfo
sbuffer.io.vecDifftestInfo .zipWithIndex.map{ case (sbufferPort, index) =>
if( index == 0) {
sbufferPort.valid := Mux(vSegmentFlag, vSegmentUnit.io.vecDifftestInfo.valid, lsq.io.sbufferVecDifftestInfo(0).valid)
sbufferPort.bits := Mux(vSegmentFlag, vSegmentUnit.io.vecDifftestInfo.bits, lsq.io.sbufferVecDifftestInfo(0).bits)

vSegmentUnit.io.vecDifftestInfo.ready := sbufferPort.ready
lsq.io.sbufferVecDifftestInfo(0).ready := sbufferPort.ready
}else{
sbufferPort <> lsq.io.sbufferVecDifftestInfo(index)
}
}
}

// lsq.io.vecStoreRetire <> vsFlowQueue.io.sqRelease
Expand Down
3 changes: 3 additions & 0 deletions src/main/scala/xiangshan/mem/vector/VSegmentUnit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@ class VSegmentUnit (implicit p: Parameters) extends VLSUModule
io.sbuffer.bits.id := DontCare
io.sbuffer.bits.addr := instMicroOp.paddr

io.vecDifftestInfo.valid := state === s_send_data && segmentActive
io.vecDifftestInfo.bits := uopq(deqPtr.value).uop

/**
* update ptr
* */
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/xiangshan/mem/vector/VecBundle.scala
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class VSegmentUnitIO(implicit p: Parameters) extends VLSUBundle{
val uopwriteback = DecoupledIO(new MemExuOutput(isVector = true)) // writeback data
val rdcache = new DCacheLoadIO // read dcache port
val sbuffer = Decoupled(new DCacheWordReqWithVaddrAndPfFlag)
val vecDifftestInfo = Decoupled(new DynInst) // to sbuffer
val dtlb = new TlbRequestIO(2)
val pmpResp = Flipped(new PMPRespBundle())
val flush_sbuffer = new SbufferFlushBundle
Expand Down

0 comments on commit 6edb148

Please sign in to comment.