@@ -82,7 +82,7 @@ class MMUInterface(parameter: MMUParameter) extends Bundle {
8282 // [tlb fu]
8383 val in = Flipped (
8484 Decoupled (
85- Valid (new AluIn (parameter.width, parameter.pRegNum, parameter.robSize, parameter.brSize))
85+ Valid (new MduIn (parameter.width, parameter.pRegNum, parameter.robSize, parameter.brSize))
8686 )
8787 )
8888 val out = Decoupled (
@@ -101,6 +101,8 @@ class MMUInterface(parameter: MMUParameter) extends Bundle {
101101 parameter.robSize,
102102 parameter.enableDifftest))
103103 )
104+ val branchInfo =
105+ Valid (new BranchInfo (parameter.robSize, parameter.brSize, parameter.width))
104106
105107 // csr
106108 val asidR = Input (UInt (10 .W ))
@@ -136,6 +138,7 @@ class MMU(val parameter: MMUParameter) extends Module with SerializableModule[MM
136138 io.out.bits.bits.tlbIndex.get := DontCare
137139 io.out.bits.bits.csrEstate.get := DontCare
138140 }
141+ io.branchInfo.valid := false .B
139142
140143 val tlbMem =
141144 BetterSRAM (parameter.tlbEntryNum, new TLBEntry , clock, parameter.tlbEntryNum, 1 , 0 )
@@ -330,6 +333,7 @@ class MMU(val parameter: MMUParameter) extends Module with SerializableModule[MM
330333 }
331334 when(
332335 io.in.bits.bits.func === TlbOp .Write .asUInt && io.in.bits.bits.exception.ecodes === ECodes .NONE ) {
336+ io.branchInfo.valid := true .B
333337 // [文档]执行 TLBWR 时,页表项写入 TLB 的位置是由 CSR.TLBIDX 的 Index 域的值指定的。
334338 tlbMem.writePorts(0 ).address := io.tlbidxIndexR
335339 if (parameter.enableDifftest) {
@@ -361,6 +365,7 @@ class MMU(val parameter: MMUParameter) extends Module with SerializableModule[MM
361365 }
362366 when(
363367 io.in.bits.bits.func === TlbOp .Fill .asUInt && io.in.bits.bits.exception.ecodes === ECodes .NONE ) {
368+ io.branchInfo.valid := true .B
364369 // [文档]执行 TLBFILL 时,页表项被填入到 TLB 的哪一项,是由硬件随机选择的。
365370 tlbMem.writePorts(0 ).address := random
366371 if (parameter.enableDifftest) {
@@ -392,11 +397,13 @@ class MMU(val parameter: MMUParameter) extends Module with SerializableModule[MM
392397 }
393398 when(
394399 io.in.bits.bits.func === TlbOp .InvAll .asUInt && io.in.bits.bits.exception.ecodes === ECodes .NONE ) {
400+ io.branchInfo.valid := true .B
395401 // [文档]清除所有页表项
396402 tlbExist.foreach(_ := false .B )
397403 }
398404 when(
399405 io.in.bits.bits.func === TlbOp .InvG1 .asUInt && io.in.bits.bits.exception.ecodes === ECodes .NONE ) {
406+ io.branchInfo.valid := true .B
400407 // [文档]清除所有 G=1 的页表项。
401408 tlbExist.zipWithIndex.foreach { case (exist, i) =>
402409 when(tlbWire(i).g) {
@@ -406,6 +413,7 @@ class MMU(val parameter: MMUParameter) extends Module with SerializableModule[MM
406413 }
407414 when(
408415 io.in.bits.bits.func === TlbOp .InvG0 .asUInt && io.in.bits.bits.exception.ecodes === ECodes .NONE ) {
416+ io.branchInfo.valid := true .B
409417 // [文档]清除所有 G=0 的页表项。
410418 tlbExist.zipWithIndex.foreach { case (exist, i) =>
411419 when(! tlbWire(i).g) {
@@ -415,6 +423,7 @@ class MMU(val parameter: MMUParameter) extends Module with SerializableModule[MM
415423 }
416424 when(
417425 io.in.bits.bits.func === TlbOp .InvG0AndAsid .asUInt && io.in.bits.bits.exception.ecodes === ECodes .NONE ) {
426+ io.branchInfo.valid := true .B
418427 // [文档]清除所有 G=0,且 ASID 等于寄存器指定 ASID 的页表项。
419428 tlbExist.zipWithIndex.foreach { case (exist, i) =>
420429 when(! tlbWire(i).g && tlbWire(i).asid === io.in.bits.bits.src1(9 , 0 )) {
@@ -424,6 +433,7 @@ class MMU(val parameter: MMUParameter) extends Module with SerializableModule[MM
424433 }
425434 when(
426435 io.in.bits.bits.func === TlbOp .InvG0AndAsidAndVa .asUInt && io.in.bits.bits.exception.ecodes === ECodes .NONE ) {
436+ io.branchInfo.valid := true .B
427437 // [文档]清除 G=0,且 ASID 等于寄存器指定 ASID,且 VA 等于寄存器指定 VA 的页表项。
428438 tlbExist.zipWithIndex.foreach { case (exist, i) =>
429439 when(
@@ -438,6 +448,7 @@ class MMU(val parameter: MMUParameter) extends Module with SerializableModule[MM
438448 }
439449 when(
440450 io.in.bits.bits.func === TlbOp .InvG1OrAsidAndVa .asUInt && io.in.bits.bits.exception.ecodes === ECodes .NONE ) {
451+ io.branchInfo.valid := true .B
441452 // [文档]清除所有 G=1 或 ASID 等于寄存器指定 ASID,且 VA 等于寄存器指定 VA 的页表项。
442453 tlbExist.zipWithIndex.foreach { case (exist, i) =>
443454 when(
@@ -451,5 +462,12 @@ class MMU(val parameter: MMUParameter) extends Module with SerializableModule[MM
451462 }
452463 }
453464 }
465+ io.branchInfo.bits.brIdx := io.in.bits.bits.brIdx
466+ io.branchInfo.bits.robIdx := io.in.bits.bits.robIdx
467+ io.branchInfo.bits.pc := io.in.bits.bits.src3
468+ io.branchInfo.bits.brTpe := BruOp .Excp
469+ io.branchInfo.bits.isTaken := true .B
470+ io.branchInfo.bits.isRet := false .B
471+ io.branchInfo.bits.correctPC := io.in.bits.bits.src3 + 4 .U
454472
455473}
0 commit comments