summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/compatibility.scala
diff options
context:
space:
mode:
authorRichard Lin2017-04-13 22:59:00 -0700
committerGitHub2017-04-13 22:59:00 -0700
commite07248b8f6022fafdb84f5d1c0ebe3fc90a5475a (patch)
treef2bb938fd35651b4fc7b88cbcd20e163cc75dd2e /src/main/scala/chisel3/compatibility.scala
parent97902cdc53eec52aa0cd806b8cb49a0e3f2fb769 (diff)
Module Hierarchy Refactor (#469)
Diffstat (limited to 'src/main/scala/chisel3/compatibility.scala')
-rw-r--r--src/main/scala/chisel3/compatibility.scala33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/main/scala/chisel3/compatibility.scala b/src/main/scala/chisel3/compatibility.scala
index 40fbe9bf..778d2c13 100644
--- a/src/main/scala/chisel3/compatibility.scala
+++ b/src/main/scala/chisel3/compatibility.scala
@@ -152,16 +152,43 @@ package object Chisel { // scalastyle:ignore package.object.name
object Bool extends BoolFactory
val Mux = chisel3.core.Mux
- type BlackBox = chisel3.core.BlackBox
-
+ import chisel3.core.Param
+ abstract class BlackBox(params: Map[String, Param] = Map.empty[String, Param]) extends chisel3.core.BlackBox(params) {
+ // This class auto-wraps the BlackBox with IO(...), allowing legacy code (where IO(...) wasn't
+ // required) to build.
+ override def _autoWrapPorts() = {
+ if (!_ioPortBound()) {
+ IO(io)
+ }
+ }
+ }
val Mem = chisel3.core.Mem
type MemBase[T <: Data] = chisel3.core.MemBase[T]
type Mem[T <: Data] = chisel3.core.Mem[T]
val SeqMem = chisel3.core.SyncReadMem
type SeqMem[T <: Data] = chisel3.core.SyncReadMem[T]
+ import chisel3.core.CompileOptions
+ abstract class CompatibilityModule(
+ override_clock: Option[Clock]=None, override_reset: Option[Bool]=None)
+ (implicit moduleCompileOptions: CompileOptions)
+ extends chisel3.core.LegacyModule(override_clock, override_reset) {
+ // This class auto-wraps the Module IO with IO(...), allowing legacy code (where IO(...) wasn't
+ // required) to build.
+ // Also provides the clock / reset constructors, which were used before withClock happened.
+
+ def this(_clock: Clock)(implicit moduleCompileOptions: CompileOptions) = this(Option(_clock), None)(moduleCompileOptions)
+ def this(_reset: Bool)(implicit moduleCompileOptions: CompileOptions) = this(None, Option(_reset))(moduleCompileOptions)
+ def this(_clock: Clock, _reset: Bool)(implicit moduleCompileOptions: CompileOptions) = this(Option(_clock), Option(_reset))(moduleCompileOptions)
+
+ override def _autoWrapPorts() = {
+ if (!_ioPortBound()) {
+ IO(io)
+ }
+ }
+ }
val Module = chisel3.core.Module
- type Module = chisel3.core.Module
+ type Module = CompatibilityModule
val printf = chisel3.core.printf