Skip to content

Commit

Permalink
refactor: replace cloneType with chiselTypeOf
Browse files Browse the repository at this point in the history
  • Loading branch information
zhutmost committed Aug 4, 2024
1 parent 14b050c commit 663d620
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions chipmunk/src/stream/StreamArbiter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import chisel3.util._

object StreamArbiter {
def roundRobin[T <: Data](ins: Seq[StreamIO[T]]): StreamIO[T] = {
val uArb = Module(new RRArbiter(ins.head.bits.cloneType, ins.length))
val uArb = Module(new RRArbiter(chiselTypeOf(ins.head.bits), ins.length))
(uArb.io.in zip ins).foreach { x =>
x._1.valid := x._2.valid
x._1.bits := x._2.bits
Expand All @@ -16,7 +16,7 @@ object StreamArbiter {
}

def lowerFirst[T <: Data](ins: Seq[StreamIO[T]]): StreamIO[T] = {
val uArb = Module(new Arbiter(ins.head.bits.cloneType, ins.length))
val uArb = Module(new Arbiter(chiselTypeOf(ins.head.bits), ins.length))
(uArb.io.in zip ins).foreach { x =>
x._1.valid := x._2.valid
x._1.bits := x._2.bits
Expand Down
6 changes: 3 additions & 3 deletions chipmunk/src/stream/StreamDelay.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object StreamDelay {
if (cycles == 0) {
in
} else {
val uStreamDelay = Module(new StreamDelay(in.bits.cloneType, delayWidth = log2Ceil(cycles + 1)))
val uStreamDelay = Module(new StreamDelay(chiselTypeOf(in.bits), delayWidth = log2Ceil(cycles + 1)))
uStreamDelay.io.in << in
uStreamDelay.io.targetDelay := cycles.U
uStreamDelay.io.out
Expand All @@ -23,7 +23,7 @@ object StreamDelay {
if (maxCycles == minCycles) {
fixed(in, maxCycles)
} else {
val uStreamDelay = Module(new StreamDelay(in.bits.cloneType, log2Ceil(maxCycles + 1)))
val uStreamDelay = Module(new StreamDelay(chiselTypeOf(in.bits), log2Ceil(maxCycles + 1)))

val randomDelayRange: Int = maxCycles - minCycles - 1
val randomDelayWidth: Int = log2Ceil(randomDelayRange)
Expand Down Expand Up @@ -88,7 +88,7 @@ class StreamDelay[T <: Data](gen: T, delayWidth: Int) extends Module {
}
}
}
import fsm.{sIdle, sCount, sPend}
import fsm.{sCount, sIdle, sPend}

val counterInc: Bool = fsm.isActive(sCount)
val counterReset: Bool = fsm.isActive(sIdle) || fsm.isEntering(sPend)
Expand Down
4 changes: 2 additions & 2 deletions chipmunk/src/stream/StreamDemux.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import chisel3.util._
/** Demultiplex one stream into multiple output streams, always selecting only one at a time. */
object StreamDemux {
def apply[T <: Data](in: StreamIO[T], select: UInt, num: Int): Vec[StreamIO[T]] = {
val c = Module(new StreamDemux(in.bits.cloneType, num))
val c = Module(new StreamDemux(chiselTypeOf(in.bits), num))
c.io.in << in
c.io.select := select
c.io.outs
}

def apply[T <: Data](in: StreamIO[T], select: StreamIO[UInt], num: Int): Vec[StreamIO[T]] = {
val c = Module(new StreamDemux(in.bits.cloneType, num))
val c = Module(new StreamDemux(chiselTypeOf(in.bits), num))
c.io.in << in
select >> c.io.createSelectStream()
c.io.outs
Expand Down
4 changes: 2 additions & 2 deletions chipmunk/src/stream/StreamMux.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import chisel3.util._
/** Multiplex multiple streams into a single one, always only processing one at a time. */
object StreamMux {
def apply[T <: Data](select: UInt, ins: Vec[StreamIO[T]]): StreamIO[T] = {
val uMux = Module(new StreamMux(ins(0).bits.cloneType, ins.length))
val uMux = Module(new StreamMux(chiselTypeOf(ins(0).bits), ins.length))
(uMux.io.ins zip ins).foreach(x => x._1 << x._2)
uMux.io.select := select
uMux.io.out
}

def apply[T <: Data](select: StreamIO[UInt], ins: Vec[StreamIO[T]]): StreamIO[T] = {
val uMux = Module(new StreamMux(ins(0).bits.cloneType, ins.length))
val uMux = Module(new StreamMux(chiselTypeOf(ins(0).bits), ins.length))
(uMux.io.ins zip ins).foreach(x => x._1 << x._2)
select >> uMux.io.createSelectStream()
uMux.io.out
Expand Down

0 comments on commit 663d620

Please sign in to comment.