@@ -177,9 +177,9 @@ class SpikeTile(
177177
178178 override lazy val module = new SpikeTileModuleImp (this )
179179 // TODO: Modularize Accel instantiation with configs
180- // Add line below with instantiation of desired accelerator
181- val accel_module : AdderExample = LazyModule ( new AdderExample ( OpcodeSet .all))
182- // val accel_module: AccumulatorExample = LazyModule(new AccumulatorExample(OpcodeSet.all));
180+ val accel_sequence = p( BuildRoCC ).map(_(p)) // .getOrElse(new NoAccelerator)
181+ val has_accel = accel_sequence.nonEmpty
182+ val accel_module = if (has_accel) accel_sequence.head else null
183183}
184184
185185class SpikeBlackBox (
@@ -197,8 +197,8 @@ class SpikeBlackBox(
197197 executable_regions : String ,
198198 tcm_base : BigInt ,
199199 tcm_size : BigInt ,
200- /* has_accel : Boolean,*/
201- use_dtm : Boolean ) extends BlackBox (Map (
200+ use_dtm : Boolean ,
201+ ) extends BlackBox (Map (
202202 " HARTID" -> IntParam (hartId),
203203 " ISA" -> StringParam (isa),
204204 " PMPREGIONS" -> IntParam (pmpregions),
@@ -213,8 +213,7 @@ class SpikeBlackBox(
213213 " CACHEABLE" -> StringParam (cacheable_regions),
214214 " EXECUTABLE" -> StringParam (executable_regions),
215215 " TCM_BASE" -> IntParam (tcm_base),
216- " TCM_SIZE" -> IntParam (tcm_size),
217- /* "HAS_ACCEL" -> IntParam(has_accel)*/
216+ " TCM_SIZE" -> IntParam (tcm_size)
218217 )) with HasBlackBoxResource {
219218
220219 val io = IO (new Bundle {
@@ -224,6 +223,7 @@ class SpikeBlackBox(
224223 val ipc = Input (UInt (64 .W ))
225224 val cycle = Input (UInt (64 .W ))
226225 val insns_retired = Output (UInt (64 .W ))
226+ val has_accel = Input (Bool ())
227227
228228 val debug = Input (Bool ())
229229 val mtip = Input (Bool ())
@@ -368,6 +368,7 @@ class SpikeTileModuleImp(outer: SpikeTile) extends BaseTileModuleImp(outer) {
368368 outer.spikeTileParams.tcmParams.map(_.size).getOrElse(0 ),
369369 useDTM
370370 ))
371+ spike.io.has_accel := outer.has_accel.asBool
371372 spike.io.clock := clock.asBool
372373 val cycle = RegInit (0 .U (64 .W ))
373374 cycle := cycle + 1 .U
@@ -489,7 +490,9 @@ class SpikeTileModuleImp(outer: SpikeTile) extends BaseTileModuleImp(outer) {
489490 }
490491
491492 /* Begin Accel Section */
492- val to_accel_enq_bits = IO (new Bundle {
493+
494+ if (outer.has_accel) {
495+ val to_accel_enq_bits = IO (new Bundle {
493496 val rs2 = UInt (64 .W )
494497 val rs1 = UInt (64 .W )
495498 val insn = UInt (64 .W )
@@ -498,18 +501,10 @@ class SpikeTileModuleImp(outer: SpikeTile) extends BaseTileModuleImp(outer) {
498501 val to_accel_q = Module (new Queue (UInt (192 .W ), 1 , flow= true , pipe= true ))
499502 spike.io.accel.a.ready := to_accel_q.io.enq.ready && to_accel_q.io.count === 0 .U
500503 to_accel_q.io.enq.valid := spike.io.accel.a.valid
501- // printf(cf"Accel valid? ${spike.io.accel.a.valid}\n")
502504 to_accel_enq_bits.insn := spike.io.accel.a.insn
503505 to_accel_enq_bits.rs1 := spike.io.accel.a.rs1
504506 to_accel_enq_bits.rs2 := spike.io.accel.a.rs2
505507 to_accel_q.io.enq.bits := to_accel_enq_bits.asUInt
506- // printf(cf"Enq bits: ${to_accel_enq_bits.insn(63, 0)}\n")
507- // printf(cf"RS1 bits: ${to_accel_enq_bits.rs1(63, 0)}\n")
508- // printf(cf"RS2 bits: ${to_accel_enq_bits.rs2(63, 0)}\n")
509- // printf(cf"Enq valid? ${to_accel_q.io.enq.valid}\n")
510- // printf(cf"Enq ready? ${to_accel_q.io.enq.ready}\n")
511- // printf(cf"Deq valid? ${to_accel_q.io.deq.valid}\n")
512- // printf(cf"Deq ready? ${to_accel_q.io.deq.ready}\n")
513508
514509 outer.accel_module.module.io.cmd.valid := to_accel_q.io.deq.valid
515510 to_accel_q.io.deq.ready := outer.accel_module.module.io.cmd.ready
@@ -532,10 +527,6 @@ class SpikeTileModuleImp(outer: SpikeTile) extends BaseTileModuleImp(outer) {
532527 outer.accel_module.module.io.cmd.bits := cmd
533528 dontTouch(outer.accel_module.module.io)
534529
535- // printf(cf"inst bits: ${inst}\n")
536- // printf(cf"rs1 bits: ${cmd.rs1}\n")
537- // printf(cf"rs2 bits: ${cmd.rs2}\n")
538-
539530 // Instantiate unused signals, will probably be used as interface develops further.
540531 outer.accel_module.module.io.mem.req.ready := false .B
541532 outer.accel_module.module.io.mem.s2_nack := false .B
@@ -579,37 +570,27 @@ class SpikeTileModuleImp(outer: SpikeTile) extends BaseTileModuleImp(outer) {
579570 })
580571
581572 val from_accel_q = Module (new Queue (UInt (128 .W ), 1 , flow= true , pipe= true )) // rd and result stitched together
582- // printf(cf"From Accel:\n")
583- // printf(cf"Enq valid? ${from_accel_q.io.enq.valid}\n")
584- // printf(cf"Enq ready? ${from_accel_q.io.enq.ready}\n")
585- // printf(cf"Deq valid? ${from_accel_q.io.deq.valid}\n")
586- // printf(cf"Deq ready? ${from_accel_q.io.deq.ready}\n")
587573 outer.accel_module.module.io.resp.ready := from_accel_q.io.enq.ready && from_accel_q.io.count === 0 .U
588574 from_accel_q.io.enq.valid := outer.accel_module.module.io.resp.valid
589575
590576 from_accel_enq_bits.rd := outer.accel_module.module.io.resp.bits.rd
591577 from_accel_enq_bits.resp := outer.accel_module.module.io.resp.bits.data
592578 from_accel_q.io.enq.bits := from_accel_enq_bits.asUInt
593- // spike.io.accel.d.valid := from_accel_q.io.deq.valid
594579 spike.io.accel.d.valid := false .B
595580 from_accel_q.io.deq.ready := true .B
596581 spike.io.accel.d.rd := from_accel_q.io.deq.bits(127 ,64 )
597582 spike.io.accel.d.result := 0 .U
598- // spike.io.accel.d.result := outer.accel_module.module.io.resp.bits.data
599- // printf(cf"Accel pre-queue result? ${outer.accel_module.module.io.resp.bits.data}\n")
600- // printf(cf"Accel dequeue result: ${from_accel_q.io.deq.bits(68,5)}\n")
601- // printf(cf"From Accel queue ready? ${from_accel_q.io.enq.ready}\n")
602- // printf(cf"From Accel queue valid? ${from_accel_q.io.enq.valid}\n")
603- // when (to_accel_q.io.deq.fire) {
604- // printf(cf"Got accel instruction: ${to_accel_q.io.deq.bits(63, 0)}\n")
605- // }
606583
607584 when (from_accel_q.io.deq.fire) {
608585 spike.io.accel.d.valid := true .B
609586 spike.io.accel.d.result := from_accel_q.io.deq.bits(63 ,0 )
610- // printf(cf"Got result: ${spike.io.accel.d.result}\n")
611587 }
612- printf(" Accel result: %d\n " , spike.io.accel.d.result)
588+ } else {
589+ spike.io.accel.a.ready := false .B
590+ spike.io.accel.d.valid := false .B
591+ spike.io.accel.d.result := 0 .U
592+ spike.io.accel.d.rd := 0 .U
593+ }
613594 /* End Accel Section */
614595}
615596
@@ -642,3 +623,15 @@ class WithSpikeTCM extends Config((site, here, up) => {
642623 case ExtMem => None
643624 case SubsystemBankedCoherenceKey => up(SubsystemBankedCoherenceKey ).copy(nBanks = 0 )
644625})
626+
627+ /**
628+ * Config fragment to enable different RoCCs, work in progress
629+ */
630+ class WithAccumRoCC extends Config ((site, here, up) => {
631+ case BuildRoCC => List (
632+ (p : Parameters ) => {
633+ val accumulator = LazyModule (new AccumulatorExample (OpcodeSet .custom0, n = 4 )(p))
634+ accumulator
635+ }
636+ )
637+ })
0 commit comments