Refactor with zip
This commit is contained in:
@@ -29,20 +29,19 @@ class CoalescingLogic(numThreads: Int = 1)(implicit p: Parameters)
|
|||||||
fifoId = Some(0)
|
fifoId = Some(0)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val vec_node_entry = Seq.tabulate(numThreads) { _ =>
|
val entryNodes = Seq.tabulate(numThreads) { _ =>
|
||||||
TLManagerNode(Seq(TLSlavePortParameters.v1(seqparam, beatBytes)))
|
TLManagerNode(Seq(TLSlavePortParameters.v1(seqparam, beatBytes)))
|
||||||
}
|
}
|
||||||
// Assign each vec_node to the identity node
|
entryNodes.foreach { n => n := node }
|
||||||
vec_node_entry.foreach { n => n := node }
|
|
||||||
|
|
||||||
lazy val module = new Impl
|
lazy val module = new Impl
|
||||||
class Impl extends LazyModuleImp(this) {
|
class Impl extends LazyModuleImp(this) {
|
||||||
// Example 1: accessing the entire A channel data for Thread 0
|
// Example 1: accessing the entire A channel data for Thread 0
|
||||||
val (tl_in_0, edge0) = vec_node_entry(0).in(0)
|
val (tl_in_0, edge0) = entryNodes(0).in(0)
|
||||||
dontTouch(tl_in_0.a)
|
dontTouch(tl_in_0.a)
|
||||||
|
|
||||||
// Example 2: accssing the entire A channel data for Thread 1
|
// Example 2: accssing the entire A channel data for Thread 1
|
||||||
val (tl_in_1, edge1) = vec_node_entry(1).in(0)
|
val (tl_in_1, edge1) = entryNodes(1).in(0)
|
||||||
dontTouch(tl_in_1.a)
|
dontTouch(tl_in_1.a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +74,7 @@ class MemTraceDriver(numThreads: Int = 1)(implicit p: Parameters)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Combine N outgoing client node into 1 idenity node for diplomatic
|
// Combine N outgoing client node into 1 idenity node for diplomatic
|
||||||
// connection
|
// connection.
|
||||||
val node = TLIdentityNode()
|
val node = TLIdentityNode()
|
||||||
thread_nodes.foreach { thread_node =>
|
thread_nodes.foreach { thread_node =>
|
||||||
node := thread_node
|
node := thread_node
|
||||||
@@ -94,23 +93,25 @@ class MemTraceDriverImp(
|
|||||||
numThreads: Int
|
numThreads: Int
|
||||||
) extends LazyModuleImp(outer)
|
) extends LazyModuleImp(outer)
|
||||||
with UnitTestModule {
|
with UnitTestModule {
|
||||||
val sim = Module(new SimMemTrace(filename = "vecadd.core1.thread4.trace", 4))
|
val sim = Module(
|
||||||
|
new SimMemTrace(filename = "vecadd.core1.thread4.trace", numThreads)
|
||||||
|
)
|
||||||
sim.io.clock := clock
|
sim.io.clock := clock
|
||||||
sim.io.reset := reset.asBool
|
sim.io.reset := reset.asBool
|
||||||
sim.io.trace_read.ready := true.B
|
sim.io.trace_read.ready := true.B
|
||||||
|
|
||||||
// Split sim.io.trace_read.address, which is flattened across all lanes,
|
// Split output of SimMemTrace, which is flattened across all lanes,
|
||||||
// back to each lane's value.
|
// back to each thread's.
|
||||||
val reqs = Wire(Vec(numThreads, new TraceReq))
|
val thread_reqs = Wire(Vec(numThreads, new TraceReq))
|
||||||
(0 to numThreads - 1).map { i =>
|
thread_reqs.zipWithIndex.foreach { case (req, i) =>
|
||||||
reqs(i).valid := (sim.io.trace_read.valid >> i)
|
req.valid := (sim.io.trace_read.valid >> i)
|
||||||
reqs(i).address := (sim.io.trace_read.address >> (64 * i))
|
req.address := (sim.io.trace_read.address >> (64 * i))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect each sim module to its respective TL connection
|
// Connect each sim module to its respective TL connection
|
||||||
(0 to numThreads - 1).map { i =>
|
(outer.thread_nodes zip thread_reqs).foreach { case (node, req) =>
|
||||||
val (tl_out, edge) = outer.thread_nodes(i).out(0)
|
val (tl_out, edge) = node.out(0)
|
||||||
tl_out.a.valid := reqs(i).valid
|
tl_out.a.valid := req.valid
|
||||||
// TODO: placeholders, use actual value from trace
|
// TODO: placeholders, use actual value from trace
|
||||||
tl_out.a.bits := edge
|
tl_out.a.bits := edge
|
||||||
.Put(
|
.Put(
|
||||||
@@ -119,7 +120,7 @@ class MemTraceDriverImp(
|
|||||||
// 64 bits = 8 bytes = 2**(3) bytes
|
// 64 bits = 8 bytes = 2**(3) bytes
|
||||||
lgSize = 3.U,
|
lgSize = 3.U,
|
||||||
// data = (i + 100).U
|
// data = (i + 100).U
|
||||||
data = reqs(i).address
|
data = req.address
|
||||||
)
|
)
|
||||||
._2
|
._2
|
||||||
// tl_out.a.bits.mask := 0xf.U
|
// tl_out.a.bits.mask := 0xf.U
|
||||||
@@ -156,6 +157,7 @@ class SimMemTrace(val filename: String, numThreads: Int)
|
|||||||
|
|
||||||
class CoalConnectTrace(implicit p: Parameters) extends LazyModule {
|
class CoalConnectTrace(implicit p: Parameters) extends LazyModule {
|
||||||
val coal_entry = LazyModule(new CoalescingEntry)
|
val coal_entry = LazyModule(new CoalescingEntry)
|
||||||
|
// TODO: use parameters for numThreads
|
||||||
val coal_logic = LazyModule(new CoalescingLogic(numThreads = 4))
|
val coal_logic = LazyModule(new CoalescingLogic(numThreads = 4))
|
||||||
val driver = LazyModule(new MemTraceDriver(numThreads = 4))
|
val driver = LazyModule(new MemTraceDriver(numThreads = 4))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user