Skip to content

Commit

Permalink
ICache: fix physical tag bug
Browse files Browse the repository at this point in the history
* Using get_phy_tag function instead of get_tag
* This bug happens when using VIPT ICache and setting lage set number
  • Loading branch information
jinyue110 committed Sep 17, 2021
1 parent efcb3cd commit 03c39bd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/scala/xiangshan/cache/L1Cache.scala
Expand Up @@ -81,6 +81,7 @@ trait HasL1CacheParameters extends HasXSParameter
def offsetlsb = wordOffBits

def get_tag(addr: UInt) = (addr >> untagBits).asUInt()
def get_phy_tag(paddr: UInt) = (paddr >> pgUntagBits).asUInt()
def get_idx(addr: UInt) = addr(untagBits-1, blockOffBits)
def get_block(addr: UInt) = addr >> blockOffBits
def get_block_addr(addr: UInt) = (addr >> blockOffBits) << blockOffBits
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/xiangshan/frontend/ICache.scala
Expand Up @@ -271,7 +271,7 @@ class ICacheMissEntry(edge: TLEdgeOut)(implicit p: Parameters) extends ICacheMis
//req register
val req = Reg(new ICacheMissReq)
val req_idx = req.vSetIdx //virtual index
val req_tag = get_tag(req.addr) //physical tag
val req_tag = get_phy_tag(req.addr) //physical tag
val req_waymask = req.waymask

val (_, _, refill_done, refill_address_inc) = edge.addr_inc(io.mem_grant)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/xiangshan/frontend/IFU.scala
Expand Up @@ -194,7 +194,7 @@ class NewIFU(implicit p: Parameters) extends XSModule with HasICacheParameters
tlbRespAllValid := tlbRespValid(0) && (tlbRespValid(1) || !f1_doubleLine)

val f1_pAddrs = tlbRespPAddr //TODO: Temporary assignment
val f1_pTags = VecInit(f1_pAddrs.map(get_tag(_)))
val f1_pTags = VecInit(f1_pAddrs.map(get_phy_tag(_)))
val (f1_tags, f1_cacheline_valid, f1_datas) = (meta_resp.tags, meta_resp.valid, data_resp.datas)
val bank0_hit_vec = VecInit(f1_tags(0).zipWithIndex.map{ case(way_tag,i) => f1_cacheline_valid(0)(i) && way_tag === f1_pTags(0) })
val bank1_hit_vec = VecInit(f1_tags(1).zipWithIndex.map{ case(way_tag,i) => f1_cacheline_valid(1)(i) && way_tag === f1_pTags(1) })
Expand Down

0 comments on commit 03c39bd

Please sign in to comment.