Skip to content

Commit efac7ee

Browse files
committed
area(CDP): zip pfDepth index and use 2 sat bank for less area
1 parent a168471 commit efac7ee

5 files changed

Lines changed: 21 additions & 15 deletions

File tree

src/main/scala/coupledL2/Common.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class TaskBundle(implicit p: Parameters) extends L2Bundle
9090
val fromL2pft = prefetchOpt.map(_ => Bool()) // Is the prefetch req from L2(BOP) or from L1 prefetch?
9191
// If true, MSHR should send an ack to L2 prefetcher.
9292
val needHint = prefetchOpt.map(_ => Bool())
93-
val pftDepth = prefetchOpt.map(_ => UInt(4.W))
93+
val pftDepth = prefetchOpt.map(_ => UInt(pfDepthBits.W))
9494

9595
val dirty = Bool()
9696

src/main/scala/coupledL2/CoupledL2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ trait HasCoupledL2Parameters {
113113
def hasNLPrefetcher = prefetchers.exists(_.isInstanceOf[NLParameters])
114114
def hasPrefetchBit = prefetchers.exists(_.hasPrefetchBit) // !! TODO.test this
115115
def hasPrefetchSrc = prefetchers.exists(_.hasPrefetchSrc)
116+
def pfDepthMax = 3
117+
def pfDepthBits = log2Ceil(pfDepthMax + 1)
116118
def chiOpt = Some(true)
117119
def topDownOpt = if(cacheParams.elaboratedTopDown) Some(true) else None
118120

src/main/scala/coupledL2/Directory.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class MetaEntry(implicit p: Parameters) extends L2Bundle {
4141
val dataErr = Bool()
4242

4343
// for CDP
44-
val pfDepth = UInt(4.W)
44+
val pfDepth = UInt(pfDepthBits.W)
4545

4646
def =/=(entry: MetaEntry): Bool = {
4747
this.asUInt =/= entry.asUInt

src/main/scala/coupledL2/prefetch/CDP.scala

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ trait HasCDPParams extends HasPrefetcherHelper with HasCoupledL2Parameters {
6565

6666
val hot_threshold = cdpParams.HotThreshold
6767
val depth_threshold = cdpParams.DepthThreshold
68+
require(depth_threshold <= pfDepthMax, s"depth_threshold(${depth_threshold}) should be less than pfDepthMax(${pfDepthMax})")
6869

6970
// helper function
7071
def get_folded_hash(origin_val: UInt, resultBitWidth: Int): UInt = { // fold $origin_val length value into $resultBitWidth
@@ -210,14 +211,14 @@ abstract class CDPModule(implicit val p: Parameters) extends Module with HasCDPP
210211

211212
class CDPDetectTrigger(implicit p: Parameters) extends CDPBundle {
212213
val cacheblock = UInt(blockBits.W)
213-
val pfDepth = UInt(4.W)
214+
val pfDepth = UInt(pfDepthBits.W)
214215
val pfSource = UInt(PfSource.pfSourceBits.W)
215216
val is_hit = Bool()
216217
}
217218

218219
class CDPDetectEntry(implicit p: Parameters) extends CDPBundle {
219220
val half_cacheblock = UInt((blockBits / 2).W)
220-
val pfDepth = UInt(4.W)
221+
val pfDepth = UInt(pfDepthBits.W)
221222
val pfSource = UInt(PfSource.pfSourceBits.W)
222223

223224
val is_hit = Bool()
@@ -443,9 +444,9 @@ class FilterTable(implicit p: Parameters) extends CDPModule {
443444
val (query_req, query_rsp) = (io.query_req, io.query_rsp)
444445
val train_req = io.train_req
445446

446-
require(FilterEntryBlks % 4 == 0, "FilterEntryBlks must be divisible by 4")
447-
val SatBankNum = 4
447+
val SatBankNum = 2
448448
val SatBankBlks = FilterEntryBlks / SatBankNum
449+
require(FilterEntryBlks % SatBankNum == 0, "FilterEntryBlks must be divisible by SatBankNum")
449450

450451
def ftMetaEntry() = new Bundle {
451452
val valid = Bool()
@@ -521,15 +522,15 @@ class FilterTable(implicit p: Parameters) extends CDPModule {
521522

522523
class CDPDetectReq(implicit p: Parameters) extends CDPBundle {
523524
val vaddr = UInt(fullAddressBits.W)
524-
val pfDepth = UInt(4.W)
525+
val pfDepth = UInt(pfDepthBits.W)
525526
val pfSource = UInt(PfSource.pfSourceBits.W)
526527

527528
val is_hit = Bool()
528529
}
529530

530531
class CDPPrefetchReq(implicit p: Parameters) extends CDPBundle {
531532
val pfAddr = UInt(fullAddressBits.W)
532-
val pfDepth = UInt(4.W)
533+
val pfDepth = UInt(pfDepthBits.W)
533534

534535
// Only for monitor
535536
val pfSource = UInt(PfSource.pfSourceBits.W)
@@ -888,7 +889,7 @@ class DetectPipeline(name:String)(implicit p: Parameters) extends CDPModule {
888889
val s3_depth = RegNext(Mux(
889890
s2_is_hit,
890891
1.U, // hit a CDP prefetched block, reinforce
891-
Mux(s2_depth === 0.U, 4.U, s2_depth + 1.U)
892+
Mux(s2_depth === 0.U, pfDepthMax.U, s2_depth + 1.U)
892893
))
893894

894895
val s3_addr = s3_req.bits.vaddr
@@ -907,7 +908,7 @@ class DetectPipeline(name:String)(implicit p: Parameters) extends CDPModule {
907908
// ----------- ChiselDB -----------
908909
class detectTriggerEntry extends CDPBundle {
909910
val vaddr = UInt(fullAddressBits.W)
910-
val pfDepth = UInt(4.W)
911+
val pfDepth = UInt(pfDepthBits.W)
911912
val pfSource = UInt(PfSource.pfSourceBits.W)
912913
val main_idx = UInt(mainEntryBits.W)
913914
val sub_idx = UInt(subEntryBits.W)
@@ -936,7 +937,7 @@ class PrefetchFilterEntry(implicit p: Parameters) extends CDPBundle {
936937
val paddr_valid = Bool()
937938
val pTag = UInt(ReqFilterTagBits.W)
938939
val vTag = UInt(ReqFilterTagBits.W)
939-
val pfDepth = UInt(4.W)
940+
val pfDepth = UInt(pfDepthBits.W)
940941

941942
// for TLB retry
942943
val retry_en = Bool()
@@ -1295,7 +1296,7 @@ class CDPPrefetcher(implicit p: Parameters) extends CDPModule {
12951296
/**
12961297
* Check : Detection Condition
12971298
* Hit Trigger:
1298-
a) Hit a CDP prefetched block, pfDepth == 2 or 4
1299+
a) Hit a CDP prefetched block, pfDepth == 1 or pfDepthMax
12991300
b) Hit a SMS/BOP prefetched block
13001301
13011302
* Refill Trigger:
@@ -1314,10 +1315,13 @@ class CDPPrefetcher(implicit p: Parameters) extends CDPModule {
13141315
val hit_trigger = detect_trig.bits.is_hit &&
13151316
(
13161317
if (UseFilteredDetect) {
1317-
detect_trig_fromCDP && (detect_trig.bits.pfDepth === 1.U || detect_trig.bits.pfDepth === 4.U) || detect_trig_fromSMS || detect_trig_fromBOP
1318+
detect_trig_fromCDP &&
1319+
(detect_trig.bits.pfDepth === 1.U || detect_trig.bits.pfDepth === pfDepthMax.U) ||
1320+
detect_trig_fromSMS || detect_trig_fromBOP
13181321
}
13191322
else {
1320-
detect_trig_fromCDP && (detect_trig.bits.pfDepth === 1.U || detect_trig.bits.pfDepth === 4.U)
1323+
detect_trig_fromCDP &&
1324+
(detect_trig.bits.pfDepth === 1.U || detect_trig.bits.pfDepth === pfDepthMax.U)
13211325
}
13221326
)
13231327
val refill_trigger = !detect_trig.bits.is_hit && detect_trig.bits.pfDepth < depth_threshold.U &&

src/main/scala/coupledL2/prefetch/Prefetcher.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class PrefetchReq(implicit p: Parameters) extends PrefetchBundle {
120120
val pfSource = UInt(MemReqSource.reqSourceBits.W)
121121

122122
// CDP
123-
val pfDepth = UInt(4.W)
123+
val pfDepth = UInt(pfDepthBits.W)
124124

125125
def addr: UInt = Cat(tag, set, 0.U(offsetBits.W))
126126
def setaddr: UInt = Cat(tag, set)

0 commit comments

Comments
 (0)