diff options
| author | Jack Koenig | 2021-01-20 13:46:48 -0800 |
|---|---|---|
| committer | Jack Koenig | 2021-01-21 15:36:55 -0800 |
| commit | 5ece5aa8ac2716d66a6ed91e38a978049d8bf250 (patch) | |
| tree | f83353530e836491bb9b770712f1b8ff3dac3942 /core/src | |
| parent | 616256c35cb7de8fcd97df56af1986b747abe54d (diff) | |
Rename MultiIOModule to Module
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/main/scala/chisel3/Annotation.scala | 4 | ||||
| -rw-r--r-- | core/src/main/scala/chisel3/Module.scala | 44 | ||||
| -rw-r--r-- | core/src/main/scala/chisel3/RawModule.scala | 57 | ||||
| -rw-r--r-- | core/src/main/scala/chisel3/core/package.scala | 4 | ||||
| -rw-r--r-- | core/src/main/scala/chisel3/package.scala | 3 |
5 files changed, 49 insertions, 63 deletions
diff --git a/core/src/main/scala/chisel3/Annotation.scala b/core/src/main/scala/chisel3/Annotation.scala index c8ac462d..545ea480 100644 --- a/core/src/main/scala/chisel3/Annotation.scala +++ b/core/src/main/scala/chisel3/Annotation.scala @@ -4,7 +4,7 @@ package chisel3.experimental import scala.language.existentials import chisel3.internal.{Builder, InstanceId, LegacyModule} -import chisel3.{CompileOptions, Data} +import chisel3.{CompileOptions, Data, RawModule} import firrtl.Transform import firrtl.annotations._ import firrtl.options.Unserializable @@ -78,7 +78,7 @@ object doNotDedup { * @param module The module to be marked * @return Unmodified signal `module` */ - def apply[T <: LegacyModule](module: T)(implicit compileOptions: CompileOptions): Unit = { + def apply[T <: RawModule](module: T)(implicit compileOptions: CompileOptions): Unit = { annotate(new ChiselAnnotation { def toFirrtl = NoDedupAnnotation(module.toNamed) }) } } diff --git a/core/src/main/scala/chisel3/Module.scala b/core/src/main/scala/chisel3/Module.scala index 236f528e..27b38d0c 100644 --- a/core/src/main/scala/chisel3/Module.scala +++ b/core/src/main/scala/chisel3/Module.scala @@ -6,15 +6,14 @@ import scala.collection.immutable.ListMap import scala.collection.mutable.{ArrayBuffer, HashMap} import scala.collection.JavaConversions._ import scala.language.experimental.macros - import java.util.IdentityHashMap import chisel3.internal._ import chisel3.internal.Builder._ import chisel3.internal.firrtl._ -import chisel3.internal.sourceinfo.{InstTransform, SourceInfo} +import chisel3.internal.sourceinfo.{InstTransform, SourceInfo, UnlocatableSourceInfo} import chisel3.experimental.BaseModule -import _root_.firrtl.annotations.{ModuleName, ModuleTarget, IsModule} +import _root_.firrtl.annotations.{IsModule, ModuleName, ModuleTarget} object Module extends SourceInfoDoc { /** A wrapper method that all Module instantiations must be wrapped in @@ -87,6 +86,43 @@ object Module extends SourceInfoDoc { def currentModule: Option[BaseModule] = Builder.currentModule } +/** Abstract base class for Modules, which behave much like Verilog modules. + * These may contain both logic and state which are written in the Module + * body (constructor). + * This abstract base class includes an implicit clock and reset. + * + * @note Module instantiations must be wrapped in a Module() call. + */ +abstract class Module(implicit moduleCompileOptions: CompileOptions) extends RawModule { + // Implicit clock and reset pins + final val clock: Clock = IO(Input(Clock())).suggestName("clock") + final val reset: Reset = IO(Input(mkReset)).suggestName("reset") + + // These are to be phased out + protected var override_clock: Option[Clock] = None + protected var override_reset: Option[Bool] = None + + private[chisel3] def mkReset: Reset = { + // Top module and compatibility mode use Bool for reset + val inferReset = _parent.isDefined && moduleCompileOptions.inferModuleReset + if (inferReset) Reset() else Bool() + } + + // Setup ClockAndReset + Builder.currentClock = Some(clock) + Builder.currentReset = Some(reset) + Builder.clearPrefix() + + private[chisel3] override def initializeInParent(parentCompileOptions: CompileOptions): Unit = { + implicit val sourceInfo = UnlocatableSourceInfo + + super.initializeInParent(parentCompileOptions) + clock := override_clock.getOrElse(Builder.forcedClock) + reset := override_reset.getOrElse(Builder.forcedReset) + } +} + + package experimental { object IO { @@ -145,7 +181,7 @@ package internal { if (!compileOptions.explicitInvalidate) { pushCommand(DefInvalid(sourceInfo, clonePorts.ref)) } - if (proto.isInstanceOf[MultiIOModule]) { + if (proto.isInstanceOf[Module]) { clonePorts("clock") := Module.clock clonePorts("reset") := Module.reset } diff --git a/core/src/main/scala/chisel3/RawModule.scala b/core/src/main/scala/chisel3/RawModule.scala index 9f0a24d6..bb84c444 100644 --- a/core/src/main/scala/chisel3/RawModule.scala +++ b/core/src/main/scala/chisel3/RawModule.scala @@ -142,47 +142,14 @@ abstract class RawModule(implicit moduleCompileOptions: CompileOptions) } } -trait RequireAsyncReset extends MultiIOModule { +trait RequireAsyncReset extends Module { override private[chisel3] def mkReset: AsyncReset = AsyncReset() } -trait RequireSyncReset extends MultiIOModule { +trait RequireSyncReset extends Module { override private[chisel3] def mkReset: Bool = Bool() } -/** Abstract base class for Modules, which behave much like Verilog modules. - * These may contain both logic and state which are written in the Module - * body (constructor). - * This abstract base class includes an implicit clock and reset. - * - * @note Module instantiations must be wrapped in a Module() call. - */ -abstract class MultiIOModule(implicit moduleCompileOptions: CompileOptions) - extends RawModule { - // Implicit clock and reset pins - final val clock: Clock = IO(Input(Clock())).autoSeed("clock") - final val reset: Reset = IO(Input(mkReset)).autoSeed("reset") - - private[chisel3] def mkReset: Reset = { - // Top module and compatibility mode use Bool for reset - val inferReset = _parent.isDefined && moduleCompileOptions.inferModuleReset - if (inferReset) Reset() else Bool() - } - - // Setup ClockAndReset - Builder.currentClock = Some(clock) - Builder.currentReset = Some(reset) - Builder.clearPrefix() - - private[chisel3] override def initializeInParent(parentCompileOptions: CompileOptions): Unit = { - implicit val sourceInfo = UnlocatableSourceInfo - - super.initializeInParent(parentCompileOptions) - clock := Builder.forcedClock - reset := Builder.forcedReset - } -} - package internal { /** Legacy Module class that restricts IOs to just io, clock, and reset, and provides a constructor @@ -192,12 +159,7 @@ package internal { * IO), the clock and reset constructors will be phased out. Recommendation is to wrap the module * in a withClock/withReset/withClockAndReset block, or directly hook up clock or reset IO pins. */ - abstract class LegacyModule(implicit moduleCompileOptions: CompileOptions) - extends MultiIOModule { - // These are to be phased out - protected var override_clock: Option[Clock] = None - protected var override_reset: Option[Bool] = None - + abstract class LegacyModule(implicit moduleCompileOptions: CompileOptions) extends Module { // IO for this Module. At the Scala level (pre-FIRRTL transformations), // connections in and out of a Module may only go through `io` elements. @deprecated("Removed for causing issues in Scala 2.12+. You remain free to define io Bundles " + @@ -233,18 +195,5 @@ package internal { super.generateComponent() } - - private[chisel3] override def initializeInParent(parentCompileOptions: CompileOptions): Unit = { - // Don't generate source info referencing parents inside a module, since this interferes with - // module de-duplication in FIRRTL emission. - implicit val sourceInfo = UnlocatableSourceInfo - - if (!parentCompileOptions.explicitInvalidate) { - pushCommand(DefInvalid(sourceInfo, _io.ref)) - } - - clock := override_clock.getOrElse(Builder.forcedClock) - reset := override_reset.getOrElse(Builder.forcedReset) - } } } diff --git a/core/src/main/scala/chisel3/core/package.scala b/core/src/main/scala/chisel3/core/package.scala index 1da4ba97..fa29f244 100644 --- a/core/src/main/scala/chisel3/core/package.scala +++ b/core/src/main/scala/chisel3/core/package.scala @@ -66,13 +66,13 @@ package object core { type RawModule = chisel3.RawModule @deprecated("Avoid importing from chisel3.core, these are not public APIs and may change at any time. " + "Use chisel3.MultiIOModule instead. This alias will be removed in 3.4.", "since the beginning of time") - type MultiIOModule = chisel3.MultiIOModule + type MultiIOModule = chisel3.Module @deprecated("Avoid importing from chisel3.core, these are not public APIs and may change at any time. " + " Use chisel3.RawModule instead. This alias will be removed in 3.4.", "since the beginning of time") type UserModule = chisel3.RawModule @deprecated("Avoid importing from chisel3.core, these are not public APIs and may change at any time. " + "Use chisel3.MultiIOModule instead. This alias will be removed in 3.4.", "since the beginning of time") - type ImplicitModule = chisel3.MultiIOModule + type ImplicitModule = chisel3.Module @deprecated("Use the version in chisel3._", "3.2") val Bits = chisel3.Bits diff --git a/core/src/main/scala/chisel3/package.scala b/core/src/main/scala/chisel3/package.scala index fb83c9d9..d5a4bfae 100644 --- a/core/src/main/scala/chisel3/package.scala +++ b/core/src/main/scala/chisel3/package.scala @@ -167,7 +167,8 @@ package object chisel3 { type InstanceId = internal.InstanceId - type Module = chisel3.internal.LegacyModule + @deprecated("MultiIOModule is now just Module", "Chisel 3.5") + type MultiIOModule = chisel3.Module /** Implicit for custom Printable string interpolator */ implicit class PrintableHelper(val sc: StringContext) extends AnyVal { |
