Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it legal for concrete resets to drive abstract reset #2018

Merged
merged 2 commits into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions core/src/main/scala/chisel3/Bits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -961,11 +961,6 @@ final class ResetType(private[chisel3] val width: Width = Width(1)) extends Elem
private[chisel3] def typeEquivalent(that: Data): Boolean =
this.getClass == that.getClass

override def connect(that: Data)(implicit sourceInfo: SourceInfo, connectCompileOptions: CompileOptions): Unit = that match {
case _: Reset | DontCare => super.connect(that)(sourceInfo, connectCompileOptions)
case _ => super.badConnect(that)(sourceInfo)
}

override def litOption = None

/** Not really supported */
Expand Down Expand Up @@ -1008,11 +1003,6 @@ sealed class AsyncReset(private[chisel3] val width: Width = Width(1)) extends El
private[chisel3] def typeEquivalent(that: Data): Boolean =
this.getClass == that.getClass

override def connect(that: Data)(implicit sourceInfo: SourceInfo, connectCompileOptions: CompileOptions): Unit = that match {
case _: AsyncReset | DontCare => super.connect(that)(sourceInfo, connectCompileOptions)
case _ => super.badConnect(that)(sourceInfo)
}

override def litOption = None

/** Not really supported */
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/chisel3/internal/MonoConnect.scala
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ private[chisel3] object MonoConnect {
elemConnect(sourceInfo, connectCompileOptions, sink_e, source_e, context_mod)
case (sink_e: ResetType, source_e: Reset) =>
elemConnect(sourceInfo, connectCompileOptions, sink_e, source_e, context_mod)
case (sink_e: Reset, source_e: ResetType) =>
elemConnect(sourceInfo, connectCompileOptions, sink_e, source_e, context_mod)
case (sink_e: EnumType, source_e: UnsafeEnum) =>
elemConnect(sourceInfo, connectCompileOptions, sink_e, source_e, context_mod)
case (sink_e: EnumType, source_e: EnumType) if sink_e.typeEquivalent(source_e) =>
Expand Down
20 changes: 20 additions & 0 deletions src/test/scala/chiselTests/ResetSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ class ResetSpec extends ChiselFlatSpec with Utils {
ChiselStage.elaborate(new AbstractResetDontCareModule)
}

it should "be able to drive Bool" in {
ChiselStage.emitVerilog(new RawModule {
val in = IO(Input(Bool()))
val out = IO(Output(Bool()))
val w = Wire(Reset())
w := in
out := w
})
}

it should "be able to drive AsyncReset" in {
ChiselStage.emitVerilog(new RawModule {
val in = IO(Input(AsyncReset()))
val out = IO(Output(AsyncReset()))
val w = Wire(Reset())
w := in
out := w
})
}

it should "allow writing modules that are reset agnostic" in {
val sync = compile(new Module {
val io = IO(new Bundle {
Expand Down