Skip to content

Commit

Permalink
fix: chisel3 pr chipsalliance#2758
Browse files Browse the repository at this point in the history
+ remove EnhancedChisel3Assign;
+ using .waiveAll and .squeezeAll;
  • Loading branch information
SingularityKChen committed Feb 17, 2023
1 parent 8204bfa commit 8d7bfd4
Show file tree
Hide file tree
Showing 26 changed files with 107 additions and 181 deletions.
5 changes: 2 additions & 3 deletions src/main/scala/amba/ahb/AHBLite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package freechips.rocketchip.amba.ahb
import chisel3._
import freechips.rocketchip.config.Parameters
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.util.EnhancedChisel3Assign

class AHBLite()(implicit p: Parameters) extends LazyModule {
val node = AHBMasterAdapterNode(
Expand All @@ -29,8 +28,8 @@ class AHBLite()(implicit p: Parameters) extends LazyModule {
out.hprot := in.hprot
out.haddr := in.haddr
out.hwdata := in.hwdata
out.hauser :<> in.hauser
in.hduser :<> out.hduser
out.hauser :<>= in.hauser
in.hduser :<>= out.hduser
in.hrdata := out.hrdata
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/amba/ahb/Xbar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import chisel3.util._
import freechips.rocketchip.config.Parameters
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.util._
import freechips.rocketchip.util.EnhancedChisel3Assign

class AHBFanout()(implicit p: Parameters) extends LazyModule {
val node = new AHBFanoutNode(
Expand Down Expand Up @@ -47,7 +46,7 @@ class AHBFanout()(implicit p: Parameters) extends LazyModule {

when (in.hready) { d_sel := a_sel }
(a_sel zip io_out) foreach { case (sel, out) =>
out :<> in
out :<>= in
out.hsel := in.hsel && sel
out.hmaster.map { _ := 0.U }
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/amba/apb/Xbar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import chisel3.util._
import freechips.rocketchip.config.Parameters
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.util._
import freechips.rocketchip.util.EnhancedChisel3Assign

class APBFanout()(implicit p: Parameters) extends LazyModule {
val node = new APBNexusNode(
Expand Down Expand Up @@ -44,7 +43,7 @@ class APBFanout()(implicit p: Parameters) extends LazyModule {

val sel = VecInit(route_addrs.map(seq => seq.map(_.contains(in.paddr)).reduce(_ || _)))
(sel zip io_out) foreach { case (sel, out) =>
out :<> in
out :<>= in
out.psel := sel && in.psel
out.penable := sel && in.penable
}
Expand Down
31 changes: 15 additions & 16 deletions src/main/scala/amba/axi4/Credited.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import freechips.rocketchip.diplomacy._
import freechips.rocketchip.tilelink._
import freechips.rocketchip.subsystem.CrossingWrapper
import freechips.rocketchip.util._
import freechips.rocketchip.util.EnhancedChisel3Assign

class AXI4CreditedBuffer(delay: AXI4CreditedDelay)(implicit p: Parameters) extends LazyModule
{
Expand All @@ -19,11 +18,11 @@ class AXI4CreditedBuffer(delay: AXI4CreditedDelay)(implicit p: Parameters) exten
lazy val module = new Impl
class Impl extends LazyModuleImp(this) {
(node.in zip node.out) foreach { case ((in, edgeIn), (out, edgeOut)) =>
out.aw :<> in.aw.pipeline(delay.aw)
out.w :<> in.w.pipeline(delay.w)
in.b :<> out.b.pipeline(delay.b)
out.ar :<> in.ar.pipeline(delay.ar)
in.r :<> out.r.pipeline(delay.r)
out.aw :<>= in.aw.pipeline(delay.aw)
out.w :<>= in.w.pipeline(delay.w)
in.b :<>= out.b.pipeline(delay.b)
out.ar :<>= in.ar.pipeline(delay.ar)
in.r :<>= out.r.pipeline(delay.r)
}
}
}
Expand All @@ -44,11 +43,11 @@ class AXI4CreditedSource(delay: AXI4CreditedDelay)(implicit p: Parameters) exten
class Impl extends LazyModuleImp(this) {
(node.in zip node.out) foreach { case ((in, edgeIn), (out, edgeOut)) =>
val tld = edgeOut.delay
out.aw :<> CreditedIO.fromSender(in.aw, tld.aw.total).pipeline(delay.aw)
out.w :<> CreditedIO.fromSender(in.w, tld.w.total).pipeline(delay.w)
in.b :<> out.b.pipeline(delay.b).toReceiver(tld.b.total)
out.ar :<> CreditedIO.fromSender(in.ar, tld.ar.total).pipeline(delay.ar)
in.r :<> out.r.pipeline(delay.r).toReceiver(tld.r.total)
out.aw :<>= CreditedIO.fromSender(in.aw, tld.aw.total).pipeline(delay.aw)
out.w :<>= CreditedIO.fromSender(in.w, tld.w.total).pipeline(delay.w)
in.b :<>= out.b.pipeline(delay.b).toReceiver(tld.b.total)
out.ar :<>= CreditedIO.fromSender(in.ar, tld.ar.total).pipeline(delay.ar)
in.r :<>= out.r.pipeline(delay.r).toReceiver(tld.r.total)
}
}
}
Expand All @@ -69,11 +68,11 @@ class AXI4CreditedSink(delay: AXI4CreditedDelay)(implicit p: Parameters) extends
class Impl extends LazyModuleImp(this) {
(node.in zip node.out) foreach { case ((in, edgeIn), (out, edgeOut)) =>
val tld = edgeIn.delay
out.aw :<> in.aw.pipeline(delay.aw).toReceiver(tld.aw.total)
out.w :<> in.w.pipeline(delay.w).toReceiver(tld.w.total)
in.b :<> CreditedIO.fromSender(out.b, tld.b.total).pipeline(delay.b)
out.ar :<> in.ar.pipeline(delay.ar).toReceiver(tld.ar.total)
in.r :<> CreditedIO.fromSender(out.r, tld.r.total).pipeline(delay.r)
out.aw :<>= in.aw.pipeline(delay.aw).toReceiver(tld.aw.total)
out.w :<>= in.w.pipeline(delay.w).toReceiver(tld.w.total)
in.b :<>= CreditedIO.fromSender(out.b, tld.b.total).pipeline(delay.b)
out.ar :<>= in.ar.pipeline(delay.ar).toReceiver(tld.ar.total)
in.r :<>= CreditedIO.fromSender(out.r, tld.r.total).pipeline(delay.r)
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/main/scala/amba/axi4/Deinterleaver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import chisel3.util.{Cat, isPow2, log2Ceil, ReadyValidIO,
import freechips.rocketchip.config.Parameters
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.util.leftOR
import freechips.rocketchip.util.EnhancedChisel3Assign

/** This adapter deinterleaves read responses on the R channel.
*
Expand Down Expand Up @@ -48,14 +47,14 @@ class AXI4Deinterleaver(maxReadBytes: Int, buffer: BufferParams = BufferParams.d
val beats = maxBeats(edgeOut.slave)

// This adapter passes through the AR/AW control + W/B write data channels
out.ar :<> in.ar
out.aw :<> in.aw
out.w :<> in.w
in.b :<> out.b
out.ar :<>= in.ar
out.aw :<>= in.aw
out.w :<>= in.w
in.b :<>= out.b

// Only the R channel has the possibility of being changed
if (nothingToDeinterleave(edgeOut.slave)) {
in.r.asInstanceOf[ReadyValidIO[AXI4BundleR]] :<> buffer.irrevocable(out.r)
in.r.asInstanceOf[ReadyValidIO[AXI4BundleR]] :<>= buffer.irrevocable(out.r)
} else {
// We only care to deinterleave ids that are actually in use
val maxFlightPerId = Seq.tabulate(endId) { i =>
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/amba/axi4/Filter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package freechips.rocketchip.amba.axi4

import freechips.rocketchip.config._
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.util.EnhancedChisel3Assign

class AXI4Filter(
Sfilter: AXI4SlaveParameters => Option[AXI4SlaveParameters] = AXI4Filter.Sidentity,
Expand Down Expand Up @@ -33,7 +32,7 @@ class AXI4Filter(
lazy val module = new Impl
class Impl extends LazyModuleImp(this) {
(node.in zip node.out) foreach { case ((in, edgeIn), (out, edgeOut)) =>
out :<> in
out :<>= in
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/main/scala/amba/axi4/Fragmenter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import chisel3.util._
import freechips.rocketchip.config.Parameters
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.util._
import freechips.rocketchip.util.EnhancedChisel3Assign

case object AXI4FragLast extends ControlKey[Bool]("real_last")
case class AXI4FragLastField() extends SimpleBundleField(AXI4FragLast)(Output(Bool()), false.B)
Expand Down Expand Up @@ -148,7 +147,7 @@ class AXI4Fragmenter()(implicit p: Parameters) extends LazyModule
val in_w = Queue.irrevocable(in.w, 1, flow=true)

// AR flow control; super easy
out.ar :<>: in_ar
(out.ar: Data).waiveAll :<>= (in_ar: Data).waiveAll
out.ar.bits.echo(AXI4FragLast) := ar_last

// When does W channel start counting a new transfer
Expand All @@ -162,7 +161,7 @@ class AXI4Fragmenter()(implicit p: Parameters) extends LazyModule
out.aw.valid := in_aw.valid && (wbeats_ready || wbeats_latched)
in_aw.ready := out.aw.ready && (wbeats_ready || wbeats_latched)
wbeats_valid := in_aw.valid && !wbeats_latched
out.aw.bits :<>: in_aw.bits
(out.aw.bits: Data).waiveAll :<>= (in_aw.bits: Data).waiveAll
out.aw.bits.echo(AXI4FragLast) := aw_last

// We need to inject 'last' into the W channel fragments, count!
Expand All @@ -184,12 +183,12 @@ class AXI4Fragmenter()(implicit p: Parameters) extends LazyModule

// R flow control
val r_last = out.r.bits.echo(AXI4FragLast)
in.r :<> out.r
(in.r: Data).waiveAll :<>= (out.r: Data).waiveAll
in.r.bits.last := out.r.bits.last && r_last

// B flow control
val b_last = out.b.bits.echo(AXI4FragLast)
in.b :<> out.b
(in.b: Data).waiveAll :<>= (out.b: Data).waiveAll
in.b.valid := out.b.valid && b_last
out.b.ready := in.b.ready || !b_last

Expand Down
11 changes: 5 additions & 6 deletions src/main/scala/amba/axi4/IdIndexer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import freechips.rocketchip.config.Parameters
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.util._
import chisel3.util.{log2Ceil, Cat}
import freechips.rocketchip.util.EnhancedChisel3Assign

case object AXI4ExtraId extends ControlKey[UInt]("extra_id")
case class AXI4ExtraIdField(width: Int) extends SimpleBundleField(AXI4ExtraId)(Output(UInt(width.W)), 0.U)
Expand Down Expand Up @@ -61,11 +60,11 @@ class AXI4IdIndexer(idBits: Int)(implicit p: Parameters) extends LazyModule
(node.in zip node.out) foreach { case ((in, edgeIn), (out, edgeOut)) =>

// Leave everything mostly untouched
out.ar :<> in.ar
out.aw :<> in.aw
out.w :<> in.w
in.b :<> out.b
in.r :<> out.r
(out.ar: Data).waiveAll :<>= (in.ar: Data).waiveAll.squeezeAll
(out.aw: Data).waiveAll :<>= (in.aw: Data).waiveAll.squeezeAll
out.w :<>= in.w
(in.b: Data).waiveAll :<>= (out.b: Data).waiveAll.squeezeAll
(in.r: Data).waiveAll :<>= (out.r: Data).waiveAll.squeezeAll

val bits = log2Ceil(edgeIn.master.endId) - idBits
if (bits > 0) {
Expand Down
7 changes: 3 additions & 4 deletions src/main/scala/amba/axi4/ToTL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import freechips.rocketchip.config.Parameters
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.tilelink._
import freechips.rocketchip.util._
import freechips.rocketchip.util.EnhancedChisel3Assign

case class AXI4ToTLIdMapEntry(tlId: IdRange, axi4Id: IdRange, name: String)
extends IdMapEntry
Expand Down Expand Up @@ -111,7 +110,7 @@ class AXI4ToTL(wcorrupt: Boolean)(implicit p: Parameters) extends LazyModule
r_out.valid := in.ar.valid
r_out.bits :<= edgeOut.Get(r_id, r_addr, r_size)._2

r_out.bits.user :<= in.ar.bits.user
(r_out.bits.user: Data).waiveAll :<= (in.ar.bits.user: Data).waiveAll
r_out.bits.user.lift(AMBAProt).foreach { rprot =>
rprot.privileged := in.ar.bits.prot(0)
rprot.secure := !in.ar.bits.prot(1)
Expand Down Expand Up @@ -147,7 +146,7 @@ class AXI4ToTL(wcorrupt: Boolean)(implicit p: Parameters) extends LazyModule
w_out.bits :<= edgeOut.Put(w_id, w_addr, w_size, in.w.bits.data, in.w.bits.strb)._2
in.w.bits.user.lift(AMBACorrupt).foreach { w_out.bits.corrupt := _ }

w_out.bits.user :<= in.aw.bits.user
(w_out.bits.user: Data).waiveAll :<= (in.aw.bits.user: Data).waiveAll
w_out.bits.user.lift(AMBAProt).foreach { wprot =>
wprot.privileged := in.aw.bits.prot(0)
wprot.secure := !in.aw.bits.prot(1)
Expand Down Expand Up @@ -183,7 +182,7 @@ class AXI4ToTL(wcorrupt: Boolean)(implicit p: Parameters) extends LazyModule
ok_r.bits.user :<= out.d.bits.user

// AXI4 needs irrevocable behaviour
in.r :<> Queue.irrevocable(ok_r, 1, flow=true)
in.r :<>= Queue.irrevocable(ok_r, 1, flow=true)

ok_b.bits.id := out.d.bits.source >> addedBits
ok_b.bits.resp := d_resp
Expand Down
11 changes: 5 additions & 6 deletions src/main/scala/amba/axi4/UserYanker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import freechips.rocketchip.util.CompileOptions.NotStrictInferReset
import freechips.rocketchip.config.Parameters
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.util._
import freechips.rocketchip.util.EnhancedChisel3Assign

/** This adapter prunes all user bit fields of the echo type from request messages,
* storing them in queues and echoing them back when matching response messages are received.
Expand Down Expand Up @@ -57,13 +56,13 @@ class AXI4UserYanker(capMaxFlight: Option[Int] = None)(implicit p: Parameters) e
val ar_ready = Vec(rqueues.map(_.enq.ready))(arid)
in .ar.ready := out.ar.ready && ar_ready
out.ar.valid := in .ar.valid && ar_ready
out.ar.bits :<= in .ar.bits
(out.ar.bits: Data).waiveAll :<= (in .ar.bits: Data).waiveAll

val rid = out.r.bits.id
val r_valid = Vec(rqueues.map(_.deq.valid))(rid)
val r_bits = Vec(rqueues.map(_.deq.bits))(rid)
assert (!out.r.valid || r_valid) // Q must be ready faster than the response
in.r :<> out.r
(in.r: Data).waiveAll :<>= (out.r: Data).waiveAll
in.r.bits.echo :<= r_bits

val arsel = UIntToOH(arid, edgeIn.master.endId).asBools
Expand All @@ -78,13 +77,13 @@ class AXI4UserYanker(capMaxFlight: Option[Int] = None)(implicit p: Parameters) e
val aw_ready = Vec(wqueues.map(_.enq.ready))(awid)
in .aw.ready := out.aw.ready && aw_ready
out.aw.valid := in .aw.valid && aw_ready
out.aw.bits :<= in .aw.bits
(out.aw.bits: Data).waiveAll :<= (in .aw.bits: Data).waiveAll

val bid = out.b.bits.id
val b_valid = Vec(wqueues.map(_.deq.valid))(bid)
val b_bits = Vec(wqueues.map(_.deq.bits))(bid)
assert (!out.b.valid || b_valid) // Q must be ready faster than the response
in.b :<> out.b
(in.b: Data).waiveAll :<>= (out.b: Data).waiveAll
in.b.bits.echo :<= b_bits

val awsel = UIntToOH(awid, edgeIn.master.endId).asBools
Expand All @@ -95,7 +94,7 @@ class AXI4UserYanker(capMaxFlight: Option[Int] = None)(implicit p: Parameters) e
q.enq.bits :<= in.aw.bits.echo
}

out.w :<> in.w
out.w :<>= in.w
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/scala/amba/axi4/Xbar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import freechips.rocketchip.diplomacy._
import freechips.rocketchip.util._
import freechips.rocketchip.unittest._
import freechips.rocketchip.tilelink._
import freechips.rocketchip.util.EnhancedChisel3Assign

/**
* AXI4 Crossbar. It connects multiple AXI4 masters to slaves.
Expand Down Expand Up @@ -86,7 +85,7 @@ class AXI4Xbar(
// Transform input bundles
val in = Wire(Vec(io_in.size, new AXI4Bundle(wide_bundle)))
for (i <- 0 until in.size) {
in(i) :<> io_in(i)
in(i) :<>= io_in(i)

// Handle size = 1 gracefully (Chisel3 empty range is broken)
def trim(id: UInt, size: Int) = if (size <= 1) 0.U else id(log2Ceil(size)-1, 0)
Expand Down Expand Up @@ -169,7 +168,7 @@ class AXI4Xbar(
// Transform output bundles
val out = Wire(Vec(io_out.size, new AXI4Bundle(wide_bundle)))
for (i <- 0 until out.size) {
io_out(i) :<> out(i)
io_out(i) :<>= out(i)

if (io_in.size > 1) {
// Block AW if we cannot record the W source
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/amba/axis/Buffer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

package freechips.rocketchip.amba.axis

import chisel3._
import freechips.rocketchip.config._
import freechips.rocketchip.util._
import freechips.rocketchip.diplomacy._
Expand All @@ -12,7 +13,7 @@ class AXISBuffer(val params: BufferParams)(implicit p: Parameters) extends LazyM
lazy val module = new Impl
class Impl extends LazyModuleImp(this) {
(node.in zip node.out) foreach { case ((in, edgeIn), (out, edgeOut)) =>
out :<>: params.irrevocable(in)
(out: Data).waiveAll :<>= (params.irrevocable(in): Data).waiveAll
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/main/scala/amba/axis/Xbar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import freechips.rocketchip.config._
import freechips.rocketchip.util._
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.tilelink._
import freechips.rocketchip.util.EnhancedChisel3Assign

class AXISXbar(beatBytes: Int, policy: TLArbiter.Policy = TLArbiter.roundRobin)(implicit p: Parameters) extends LazyModule
{
Expand Down Expand Up @@ -43,14 +42,14 @@ class AXISXbar(beatBytes: Int, policy: TLArbiter.Policy = TLArbiter.roundRobin)(
// Transform input bundle sources (dest uses global namespace on both sides)
val in = Wire(Vec(io_in.size, AXISBundle(wide_bundle)))
for (i <- 0 until in.size) {
in(i) :<> io_in(i)
in(i) :<>= io_in(i)
in(i).bits.lift(AXISId) foreach { _ := io_in(i).bits.id | inputIdRanges(i).start.U }
}

// Transform output bundle sinks (id use global namespace on both sides)
val out = Wire(Vec(io_out.size, AXISBundle(wide_bundle)))
for (o <- 0 until out.size) {
io_out(o) :<> out(o)
io_out(o) :<>= out(o)
io_out(o).bits.lift(AXISDest) foreach { _ := trim(out(o).bits.dest, outputIdRanges(o).size) }
}

Expand Down Expand Up @@ -78,7 +77,7 @@ object AXISXbar
if (sources.isEmpty) {
sink.valid := false.B
} else if (sources.size == 1) {
sink :<> sources.head
sink :<>= sources.head
} else {
// The number of beats which remain to be sent
val idle = RegInit(true.B)
Expand Down
1 change: 0 additions & 1 deletion src/main/scala/regmapper/RegisterRouter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import chisel3._
import chisel3.util.{isPow2}
import freechips.rocketchip.config.Parameters
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.util.EnhancedChisel3Assign

/** Parameters which apply to any RegisterRouter. */
case class RegisterRouterParams(
Expand Down
1 change: 0 additions & 1 deletion src/main/scala/tilelink/AddressAdjuster.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import chisel3._
import chisel3.util._
import freechips.rocketchip.config._
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.util.EnhancedChisel3Assign

class AddressAdjuster(
val params: ReplicatedRegion, // only devices in this region get adjusted
Expand Down
Loading

0 comments on commit 8d7bfd4

Please sign in to comment.