Skip to content

Commit

Permalink
fix bug in core Agent
Browse files Browse the repository at this point in the history
  • Loading branch information
BigWhiteDog committed Jan 13, 2021
1 parent caa5d44 commit b086c6d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions debug/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ unit-test:
tlc-test:
cd .. && mill XiangShan.test.testOnly -o -s cache.TLCTest.TLCCacheTest

l1-test:
cd .. && mill XiangShan.test.testOnly -o -s cache.L1DTest.L1DCacheTest

unit-test-all:
cd .. && mill XiangShan.test.test -P$(P)

Expand Down
17 changes: 12 additions & 5 deletions src/test/scala/cache/L1DTest/CoreAgent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@ class CoreAgent(ID: Int, name: String, addrStateMap: mutable.Map[BigInt, AddrSta
override def step(): Unit = {
for (i <- 0 until portNum) {
s2_loadTrans(i) = s1_loadTrans(i)
s1_loadTrans(i) = s0_loadTrans(i)
s0_loadTrans(i) = None
if (loadPortsReqMessage(i).isEmpty) { //if fired
s1_loadTrans(i) = s0_loadTrans(i)
s0_loadTrans(i) = None
}
else {
s1_loadTrans(i) = None
}
}
clock += 1
}
Expand All @@ -149,18 +154,20 @@ class CoreAgent(ID: Int, name: String, addrStateMap: mutable.Map[BigInt, AddrSta
val rsize = 1 << lgSize
// addr must be aligned to size
val offset = (rand.nextInt(8) >> lgSize) << lgSize
val laddr = addr + wordCnt*8 + offset
val laddr = addr + wordCnt * 8 + offset
// generate mask from raddr and rsize
val mask = (BigInt(1) << rsize) - 1
val wmask = mask << offset
loadT.prepareLoad(laddr,wmask)
loadT.prepareLoad(laddr, wmask)
outerLoad.append(loadT)
}

def addStore(addr: BigInt): Unit = {
//addr is aligned to block
val storeT = new DCacheStoreCallerTrans()
val blockMask = (BigInt(rand.nextInt().toLong) << 32) | BigInt(rand.nextInt().toLong)
val blockMask = (0 until 4).foldLeft(BigInt(0))(
(d, _) => (d << 16) | BigInt(rand.nextInt(0xffff))
)
storeT.prepareStore(addr, randomBlockData(), blockMask)
outerStore.append(storeT)
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/cache/TLCTest/TLCAgent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class TLCAgent(ID: Int, name: String = "", addrStateMap: mutable.Map[BigInt, Add

val rand = new Random(0xdad)

var clock = 100
var clock = 0

def step(): Unit = {
clock += 1
Expand Down

0 comments on commit b086c6d

Please sign in to comment.