Skip to content

Commit

Permalink
Enable Clock Invalidation (#2485)
Browse files Browse the repository at this point in the history
Loosen restrictions on clocks to enable them to be connected to
DontCare, i.e., be invalidated.

Co-authored-by: Jack Koenig <koenig@sifive.com>
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>

Co-authored-by: Jack Koenig <koenig@sifive.com>
(cherry picked from commit 5d8a0c8)

# Conflicts:
#	core/src/main/scala/chisel3/Clock.scala
  • Loading branch information
seldridge committed Apr 15, 2022
1 parent 5d394ab commit ff56625
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/scala/chisel3/Clock.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sealed class Clock(private[chisel3] val width: Width = Width(1)) extends Element
this.getClass == that.getClass

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

Expand Down
8 changes: 8 additions & 0 deletions src/test/scala/chiselTests/InvalidateAPISpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,12 @@ class InvalidateAPISpec extends ChiselPropSpec with Matchers with BackendCompila
val firrtlOutput = myGenerateFirrtl(new ModuleWithoutDontCare)
firrtlOutput should include("is invalid")
}

property("a clock should be able to be connected to a DontCare") {
class ClockConnectedToDontCare extends Module {
val io = IO(new Bundle { val foo = Output(Clock()) })
io.foo := DontCare
}
myGenerateFirrtl(new ClockConnectedToDontCare) should include("io.foo is invalid")
}
}

0 comments on commit ff56625

Please sign in to comment.