Skip to content

Commit ae05023

Browse files
feat: try to correct the logic of eyeriss top
1 parent 8bd17a1 commit ae05023

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

dla/src/diplomatic/EyerissTop.scala

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ class EyerissTop(val param: EyerissTopParam) extends Module with ClusterConfig w
5454
cGroupIO.ctrlPath.cscSwitcherCtrlPath <> decoderIO.cscSwitcherCtrlIO
5555
/** cGroupIO data path*/
5656
cGroupIO.dataPath.pSumIO.foreach(x => x.inIOs <> DontCare)
57-
private def sourceInputDataMux(offChip: DecoupledIO[SimpleTLDIO], onChip: Seq[DecoupledIO[UInt]]) : Unit = {
57+
private def sourceInputDataMux(offChip: DecoupledIO[SimpleTLDIO], onChip: Seq[DecoupledIO[UInt]], enable: Bool) : Unit = {
5858
onChip.zipWithIndex.foreach({ case (value, i) =>
5959
value.bits := offChip.bits.data
60-
value.valid := offChip.bits.source === i.U && offChip.valid
60+
value.valid := offChip.bits.source === i.U && offChip.valid && enable
6161
})
6262
offChip.ready := MuxLookup(offChip.bits.source, false.B, onChip.zipWithIndex.map({ case (value, i) =>
6363
i.U -> value.ready
@@ -81,11 +81,20 @@ class EyerissTop(val param: EyerissTopParam) extends Module with ClusterConfig w
8181
memCtrlIO.pSumIO.sourceAlloc.valid && decoderIO.pSumIO.pSumLoadEn)
8282
}
8383
protected val inActInIOs: IndexedSeq[DecoupledIO[UInt]] = cGroupIO.dataPath.inActIO.map(x => x.data)
84-
sourceInputDataMux(offChip = io.ctrlPath.bundles.memInActBundles.d, onChip = inActInIOs)
84+
sourceInputDataMux(offChip = io.ctrlPath.bundles.memInActBundles.d, onChip = inActInIOs, enable = cgCtrlPath.glbInActLoadEn)
8585
protected val weightInIOs: IndexedSeq[DecoupledIO[UInt]] = cGroupIO.dataPath.weightIO.map(x => x.data)
86-
sourceInputDataMux(offChip = io.ctrlPath.bundles.memWeightBundles.d, onChip = weightInIOs)
86+
sourceInputDataMux(offChip = io.ctrlPath.bundles.memWeightBundles.d, onChip = weightInIOs, enable = cgCtrlPath.peWeightLoadEn)
8787
protected val pSumOutIOs: IndexedSeq[DecoupledIO[UInt]] = cGroupIO.dataPath.pSumIO.map(x => x.outIOs)
8888
pSumBundleMux(offChip = io.ctrlPath.bundles.memPSumBundles.a, onChip = pSumOutIOs)
89+
protected val inActReqFirstReg: Bool = RegInit(false.B)
90+
inActReqFirstReg := Mux(memCtrlIO.inActIO.sourceAlloc.fire(), false.B,
91+
Mux(io.ctrlPath.bundles.memInActBundles.reqFirst, true.B, inActReqFirstReg))
92+
protected val weightReqFirstReg: Bool = RegInit(false.B)
93+
weightReqFirstReg := Mux(memCtrlIO.weightIO.sourceAlloc.fire(), false.B,
94+
Mux(io.ctrlPath.bundles.memWeightBundles.reqFirst, true.B, weightReqFirstReg))
95+
protected val pSumReqFirstReg: Bool = RegInit(false.B)
96+
pSumReqFirstReg := Mux(memCtrlIO.pSumIO.sourceAlloc.fire(), false.B,
97+
Mux(io.ctrlPath.bundles.memPSumBundles.reqFirst, true.B, pSumReqFirstReg))
8998
/** memory module address and size */
9099
memCtrlIO.inActIO.startAdr := decoderIO.inActIO.starAdr
91100
memCtrlIO.inActIO.reqSize := decoderIO.inActIO.reqSize
@@ -95,21 +104,21 @@ class EyerissTop(val param: EyerissTopParam) extends Module with ClusterConfig w
95104
memCtrlIO.pSumIO.reqSize := decoderIO.pSumIO.reqSize
96105
/** only glbLoadEn, then generate source id*/
97106
memCtrlIO.inActIO.sourceAlloc.ready := io.ctrlPath.bundles.memInActBundles.legal &&
98-
io.ctrlPath.bundles.memInActBundles.reqFirst &&
107+
(io.ctrlPath.bundles.memInActBundles.reqFirst || inActReqFirstReg) &&
99108
io.ctrlPath.bundles.memInActBundles.a.ready && cgCtrlPath.glbInActLoadEn
100109
memCtrlIO.inActIO.sourceFree.valid := io.ctrlPath.bundles.memInActBundles.respFirst &&
101110
io.ctrlPath.bundles.memInActBundles.d.fire()
102111
memCtrlIO.inActIO.sourceFree.bits := io.ctrlPath.bundles.memInActBundles.d.bits.source
103112
/** only peLoadEn and haven't finish read (sourceAlloc.valid), then generate source id*/
104113
memCtrlIO.weightIO.sourceAlloc.ready := io.ctrlPath.bundles.memWeightBundles.legal &&
105-
io.ctrlPath.bundles.memWeightBundles.reqFirst &&
114+
(io.ctrlPath.bundles.memWeightBundles.reqFirst || weightReqFirstReg) &&
106115
io.ctrlPath.bundles.memWeightBundles.a.ready && cgCtrlPath.peWeightLoadEn
107116
memCtrlIO.weightIO.sourceFree.valid := io.ctrlPath.bundles.memWeightBundles.respFirst &&
108117
io.ctrlPath.bundles.memWeightBundles.d.fire()
109118
memCtrlIO.weightIO.sourceFree.bits := io.ctrlPath.bundles.memWeightBundles.d.bits.source
110119
/** only pSumLoadEn, then generate source id*/
111120
memCtrlIO.pSumIO.sourceAlloc.ready := io.ctrlPath.bundles.memPSumBundles.legal &&
112-
io.ctrlPath.bundles.memPSumBundles.reqFirst &&
121+
(io.ctrlPath.bundles.memPSumBundles.reqFirst || pSumReqFirstReg) &&
113122
io.ctrlPath.bundles.memPSumBundles.a.ready && decoderIO.pSumIO.pSumLoadEn
114123
memCtrlIO.pSumIO.sourceFree.valid := io.ctrlPath.bundles.memPSumBundles.respFirst &&
115124
io.ctrlPath.bundles.memPSumBundles.d.fire()
@@ -121,15 +130,15 @@ class EyerissTop(val param: EyerissTopParam) extends Module with ClusterConfig w
121130
io.ctrlPath.interrupts := decoderIO.valid
122131
/** only glbLoadEn then a.valid is true then can Get data */
123132
io.ctrlPath.bundles.memInActBundles.a.valid := io.ctrlPath.bundles.memInActBundles.legal &&
124-
(!io.ctrlPath.bundles.memInActBundles.reqFirst || memCtrlIO.inActIO.sourceAlloc.valid && cgCtrlPath.glbInActLoadEn)
133+
(!io.ctrlPath.bundles.memInActBundles.reqFirst || memCtrlIO.inActIO.sourceAlloc.valid) && cgCtrlPath.glbInActLoadEn
125134
io.ctrlPath.bundles.memInActBundles.a.bits.source := memCtrlIO.inActIO.sourceAlloc.bits
126135
/** Don't care memInActBundles.a.bits.data as memInActBundle.a.bits.data will be assigned in LazyImp*/
127136
io.ctrlPath.bundles.memInActBundles.a.bits.data := DontCare
128137
io.ctrlPath.bundles.memInActBundles.address := memCtrlIO.inActIO.address
129138
io.ctrlPath.bundles.memInActBundles.reqSize := decoderIO.inActIO.reqSize
130139
/** weight */
131140
io.ctrlPath.bundles.memWeightBundles.a.valid := io.ctrlPath.bundles.memWeightBundles.legal &&
132-
(!io.ctrlPath.bundles.memWeightBundles.reqFirst || (memCtrlIO.weightIO.sourceAlloc.valid && cgCtrlPath.peWeightLoadEn))
141+
(!io.ctrlPath.bundles.memWeightBundles.reqFirst || memCtrlIO.weightIO.sourceAlloc.valid) && cgCtrlPath.peWeightLoadEn
133142
io.ctrlPath.bundles.memWeightBundles.a.bits.source := memCtrlIO.weightIO.sourceAlloc.bits
134143
/** Don't care memWeightBundles.a.bits.data as memWeightBundle.a.bits.data will be assigned in LazyImp*/
135144
io.ctrlPath.bundles.memWeightBundles.a.bits.data := DontCare

dla/tests/src/diplomatictest/EyerissTopSpecTest.scala

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dla.tests.diplomatictest
22

33
import chisel3._
44
import chisel3.tester._
5-
import chiseltest.internal.WriteVcdAnnotation
5+
import chiseltest.internal.{VerilatorBackendAnnotation, WriteVcdAnnotation}
66
import chisel3.tester.experimental.TestOptionBuilder._
77
import dla.cluster.{ClusterConfig, GNMFCS1Config, GNMFCS2Config}
88
import dla.diplomatic.{EyerissMemCtrlBundle, EyerissTop, EyerissTopParam}
@@ -40,6 +40,7 @@ object EyerissTLBundleDriver {
4040
peekIO.a.ready.poke(false.B)
4141
}
4242
}.fork.withName("manage response").withRegion(Monitor) {
43+
theClock.step((new Random).nextInt(30) + 1) // transferring time
4344
while (respSourceId.length < sourceIdNum) {
4445
peekIO.d.valid.poke(true.B)
4546
while (!peekIO.d.ready.peek().litToBoolean) {
@@ -89,7 +90,7 @@ class EyerissTopSpecTest extends FlatSpec with ChiselScalatestTester with Matche
8990
private val dataDriver = EyerissTLBundleDriver
9091
behavior of "test the spec of EyerissTop"
9192
it should "work well on cal" in {
92-
test(new EyerissTop(param = param)).withAnnotations(Seq(WriteVcdAnnotation)) { eyeriss =>
93+
test(new EyerissTop(param = param)).withAnnotations(Seq(WriteVcdAnnotation, VerilatorBackendAnnotation)) { eyeriss =>
9394
val theTopIO = eyeriss.io
9495
implicit val theClock: Clock = eyeriss.clock
9596
eyeriss.reset.poke(true.B)
@@ -114,10 +115,12 @@ class EyerissTopSpecTest extends FlatSpec with ChiselScalatestTester with Matche
114115
starAdr = decoderSequencer.inActAdr.hex)
115116
println("[INFO] inAct later Finish")
116117
/** load weight */
117-
dataDriver.readReqAndResp(theTopIO.ctrlPath.bundles.memWeightBundles,
118-
dataSequencer.weightStreamGLBOrder.flatten.map(x => x.flatten.toList), sourceIdNum = weightRouterNum,
119-
starAdr = decoderSequencer.weightAdr.hex)
120-
println("[INFO] one weight Finish")
118+
for (i <- 0 until 10) {
119+
dataDriver.readReqAndResp(theTopIO.ctrlPath.bundles.memWeightBundles,
120+
dataSequencer.weightStreamGLBOrder.flatten.map(x => x.flatten), sourceIdNum = weightRouterNum,
121+
starAdr = decoderSequencer.weightAdr.hex)
122+
println(s"[INFO] $i-th weight Finish")
123+
}
121124
}
122125
}
123126
}

0 commit comments

Comments
 (0)