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

Fix := of Reset and AsyncReset to DontCare #1336

Merged
merged 1 commit into from
Feb 12, 2020
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
4 changes: 2 additions & 2 deletions chiselFrontend/src/main/scala/chisel3/Bits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ final class ResetType(private[chisel3] val width: Width = Width(1)) extends Elem
this.getClass == that.getClass

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

Expand Down Expand Up @@ -1036,7 +1036,7 @@ sealed class AsyncReset(private[chisel3] val width: Width = Width(1)) extends El
this.getClass == that.getClass

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

Expand Down
22 changes: 22 additions & 0 deletions src/test/scala/chiselTests/AsyncResetSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,32 @@ class AsyncResetQueueTester extends BasicTester {
}
}

class AsyncResetDontCareModule extends RawModule {
import chisel3.util.Valid
val monoPort = IO(Output(AsyncReset()))
monoPort := DontCare
val monoWire = Wire(AsyncReset())
monoWire := DontCare
val monoAggPort = IO(Output(Valid(AsyncReset())))
monoAggPort := DontCare
val monoAggWire = Wire(Valid(AsyncReset()))
monoAggWire := DontCare

// Can't bulk connect to Wire so only ports here
val bulkPort = IO(Output(AsyncReset()))
bulkPort <> DontCare
val bulkAggPort = IO(Output(Valid(AsyncReset())))
bulkAggPort <> DontCare
}

class AsyncResetSpec extends ChiselFlatSpec {

behavior of "AsyncReset"

it should "be able to be connected to DontCare" in {
elaborate(new AsyncResetDontCareModule)
}

it should "be allowed with literal reset values" in {
elaborate(new BasicTester {
withReset(reset.asAsyncReset)(RegInit(123.U))
Expand Down
22 changes: 22 additions & 0 deletions src/test/scala/chiselTests/ResetSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,33 @@ class ResetAgnosticModule extends RawModule {
out := reg
}

class AbstractResetDontCareModule extends RawModule {
import chisel3.util.Valid
val monoPort = IO(Output(Reset()))
monoPort := DontCare
val monoWire = Wire(Reset())
monoWire := DontCare
val monoAggPort = IO(Output(Valid(Reset())))
monoAggPort := DontCare
val monoAggWire = Wire(Valid(Reset()))
monoAggWire := DontCare

// Can't bulk connect to Wire so only ports here
val bulkPort = IO(Output(Reset()))
bulkPort <> DontCare
val bulkAggPort = IO(Output(Valid(Reset())))
bulkAggPort <> DontCare
}


class ResetSpec extends ChiselFlatSpec {

behavior of "Reset"

it should "be able to be connected to DontCare" in {
elaborate(new AbstractResetDontCareModule)
}

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