Skip to content

Commit 5ece5aa

Browse files
committed
Rename MultiIOModule to Module
1 parent 616256c commit 5ece5aa

28 files changed

+134
-145
lines changed

core/src/main/scala/chisel3/Annotation.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package chisel3.experimental
44

55
import scala.language.existentials
66
import chisel3.internal.{Builder, InstanceId, LegacyModule}
7-
import chisel3.{CompileOptions, Data}
7+
import chisel3.{CompileOptions, Data, RawModule}
88
import firrtl.Transform
99
import firrtl.annotations._
1010
import firrtl.options.Unserializable
@@ -78,7 +78,7 @@ object doNotDedup {
7878
* @param module The module to be marked
7979
* @return Unmodified signal `module`
8080
*/
81-
def apply[T <: LegacyModule](module: T)(implicit compileOptions: CompileOptions): Unit = {
81+
def apply[T <: RawModule](module: T)(implicit compileOptions: CompileOptions): Unit = {
8282
annotate(new ChiselAnnotation { def toFirrtl = NoDedupAnnotation(module.toNamed) })
8383
}
8484
}

core/src/main/scala/chisel3/Module.scala

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ import scala.collection.immutable.ListMap
66
import scala.collection.mutable.{ArrayBuffer, HashMap}
77
import scala.collection.JavaConversions._
88
import scala.language.experimental.macros
9-
109
import java.util.IdentityHashMap
1110

1211
import chisel3.internal._
1312
import chisel3.internal.Builder._
1413
import chisel3.internal.firrtl._
15-
import chisel3.internal.sourceinfo.{InstTransform, SourceInfo}
14+
import chisel3.internal.sourceinfo.{InstTransform, SourceInfo, UnlocatableSourceInfo}
1615
import chisel3.experimental.BaseModule
17-
import _root_.firrtl.annotations.{ModuleName, ModuleTarget, IsModule}
16+
import _root_.firrtl.annotations.{IsModule, ModuleName, ModuleTarget}
1817

1918
object Module extends SourceInfoDoc {
2019
/** A wrapper method that all Module instantiations must be wrapped in
@@ -87,6 +86,43 @@ object Module extends SourceInfoDoc {
8786
def currentModule: Option[BaseModule] = Builder.currentModule
8887
}
8988

89+
/** Abstract base class for Modules, which behave much like Verilog modules.
90+
* These may contain both logic and state which are written in the Module
91+
* body (constructor).
92+
* This abstract base class includes an implicit clock and reset.
93+
*
94+
* @note Module instantiations must be wrapped in a Module() call.
95+
*/
96+
abstract class Module(implicit moduleCompileOptions: CompileOptions) extends RawModule {
97+
// Implicit clock and reset pins
98+
final val clock: Clock = IO(Input(Clock())).suggestName("clock")
99+
final val reset: Reset = IO(Input(mkReset)).suggestName("reset")
100+
101+
// These are to be phased out
102+
protected var override_clock: Option[Clock] = None
103+
protected var override_reset: Option[Bool] = None
104+
105+
private[chisel3] def mkReset: Reset = {
106+
// Top module and compatibility mode use Bool for reset
107+
val inferReset = _parent.isDefined && moduleCompileOptions.inferModuleReset
108+
if (inferReset) Reset() else Bool()
109+
}
110+
111+
// Setup ClockAndReset
112+
Builder.currentClock = Some(clock)
113+
Builder.currentReset = Some(reset)
114+
Builder.clearPrefix()
115+
116+
private[chisel3] override def initializeInParent(parentCompileOptions: CompileOptions): Unit = {
117+
implicit val sourceInfo = UnlocatableSourceInfo
118+
119+
super.initializeInParent(parentCompileOptions)
120+
clock := override_clock.getOrElse(Builder.forcedClock)
121+
reset := override_reset.getOrElse(Builder.forcedReset)
122+
}
123+
}
124+
125+
90126
package experimental {
91127

92128
object IO {
@@ -145,7 +181,7 @@ package internal {
145181
if (!compileOptions.explicitInvalidate) {
146182
pushCommand(DefInvalid(sourceInfo, clonePorts.ref))
147183
}
148-
if (proto.isInstanceOf[MultiIOModule]) {
184+
if (proto.isInstanceOf[Module]) {
149185
clonePorts("clock") := Module.clock
150186
clonePorts("reset") := Module.reset
151187
}

core/src/main/scala/chisel3/RawModule.scala

Lines changed: 3 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -142,47 +142,14 @@ abstract class RawModule(implicit moduleCompileOptions: CompileOptions)
142142
}
143143
}
144144

145-
trait RequireAsyncReset extends MultiIOModule {
145+
trait RequireAsyncReset extends Module {
146146
override private[chisel3] def mkReset: AsyncReset = AsyncReset()
147147
}
148148

149-
trait RequireSyncReset extends MultiIOModule {
149+
trait RequireSyncReset extends Module {
150150
override private[chisel3] def mkReset: Bool = Bool()
151151
}
152152

153-
/** Abstract base class for Modules, which behave much like Verilog modules.
154-
* These may contain both logic and state which are written in the Module
155-
* body (constructor).
156-
* This abstract base class includes an implicit clock and reset.
157-
*
158-
* @note Module instantiations must be wrapped in a Module() call.
159-
*/
160-
abstract class MultiIOModule(implicit moduleCompileOptions: CompileOptions)
161-
extends RawModule {
162-
// Implicit clock and reset pins
163-
final val clock: Clock = IO(Input(Clock())).autoSeed("clock")
164-
final val reset: Reset = IO(Input(mkReset)).autoSeed("reset")
165-
166-
private[chisel3] def mkReset: Reset = {
167-
// Top module and compatibility mode use Bool for reset
168-
val inferReset = _parent.isDefined && moduleCompileOptions.inferModuleReset
169-
if (inferReset) Reset() else Bool()
170-
}
171-
172-
// Setup ClockAndReset
173-
Builder.currentClock = Some(clock)
174-
Builder.currentReset = Some(reset)
175-
Builder.clearPrefix()
176-
177-
private[chisel3] override def initializeInParent(parentCompileOptions: CompileOptions): Unit = {
178-
implicit val sourceInfo = UnlocatableSourceInfo
179-
180-
super.initializeInParent(parentCompileOptions)
181-
clock := Builder.forcedClock
182-
reset := Builder.forcedReset
183-
}
184-
}
185-
186153
package internal {
187154

188155
/** Legacy Module class that restricts IOs to just io, clock, and reset, and provides a constructor
@@ -192,12 +159,7 @@ package internal {
192159
* IO), the clock and reset constructors will be phased out. Recommendation is to wrap the module
193160
* in a withClock/withReset/withClockAndReset block, or directly hook up clock or reset IO pins.
194161
*/
195-
abstract class LegacyModule(implicit moduleCompileOptions: CompileOptions)
196-
extends MultiIOModule {
197-
// These are to be phased out
198-
protected var override_clock: Option[Clock] = None
199-
protected var override_reset: Option[Bool] = None
200-
162+
abstract class LegacyModule(implicit moduleCompileOptions: CompileOptions) extends Module {
201163
// IO for this Module. At the Scala level (pre-FIRRTL transformations),
202164
// connections in and out of a Module may only go through `io` elements.
203165
@deprecated("Removed for causing issues in Scala 2.12+. You remain free to define io Bundles " +
@@ -233,18 +195,5 @@ package internal {
233195

234196
super.generateComponent()
235197
}
236-
237-
private[chisel3] override def initializeInParent(parentCompileOptions: CompileOptions): Unit = {
238-
// Don't generate source info referencing parents inside a module, since this interferes with
239-
// module de-duplication in FIRRTL emission.
240-
implicit val sourceInfo = UnlocatableSourceInfo
241-
242-
if (!parentCompileOptions.explicitInvalidate) {
243-
pushCommand(DefInvalid(sourceInfo, _io.ref))
244-
}
245-
246-
clock := override_clock.getOrElse(Builder.forcedClock)
247-
reset := override_reset.getOrElse(Builder.forcedReset)
248-
}
249198
}
250199
}

core/src/main/scala/chisel3/core/package.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ package object core {
6666
type RawModule = chisel3.RawModule
6767
@deprecated("Avoid importing from chisel3.core, these are not public APIs and may change at any time. " +
6868
"Use chisel3.MultiIOModule instead. This alias will be removed in 3.4.", "since the beginning of time")
69-
type MultiIOModule = chisel3.MultiIOModule
69+
type MultiIOModule = chisel3.Module
7070
@deprecated("Avoid importing from chisel3.core, these are not public APIs and may change at any time. " +
7171
" Use chisel3.RawModule instead. This alias will be removed in 3.4.", "since the beginning of time")
7272
type UserModule = chisel3.RawModule
7373
@deprecated("Avoid importing from chisel3.core, these are not public APIs and may change at any time. " +
7474
"Use chisel3.MultiIOModule instead. This alias will be removed in 3.4.", "since the beginning of time")
75-
type ImplicitModule = chisel3.MultiIOModule
75+
type ImplicitModule = chisel3.Module
7676

7777
@deprecated("Use the version in chisel3._", "3.2")
7878
val Bits = chisel3.Bits

core/src/main/scala/chisel3/package.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ package object chisel3 {
167167

168168
type InstanceId = internal.InstanceId
169169

170-
type Module = chisel3.internal.LegacyModule
170+
@deprecated("MultiIOModule is now just Module", "Chisel 3.5")
171+
type MultiIOModule = chisel3.Module
171172

172173
/** Implicit for custom Printable string interpolator */
173174
implicit class PrintableHelper(val sc: StringContext) extends AnyVal {

src/main/scala/chisel3/aop/injecting/InjectingAspect.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package chisel3.aop.injecting
44

5-
import chisel3.{Module, ModuleAspect, MultiIOModule, RawModule, experimental, withClockAndReset}
5+
import chisel3.{Module, ModuleAspect, RawModule, withClockAndReset}
66
import chisel3.aop._
77
import chisel3.internal.{Builder, DynamicContext}
88
import chisel3.internal.firrtl.DefModule
@@ -63,7 +63,7 @@ abstract class InjectorAspect[T <: RawModule, M <: RawModule](
6363
RunFirrtlTransformAnnotation(new InjectingTransform) +: modules.map { module =>
6464
val (chiselIR, _) = Builder.build(Module(new ModuleAspect(module) {
6565
module match {
66-
case x: MultiIOModule => withClockAndReset(x.clock, x.reset) { injection(module) }
66+
case x: Module => withClockAndReset(x.clock, x.reset) { injection(module) }
6767
case x: RawModule => injection(module)
6868
}
6969
}), dynamicContext)

src/main/scala/chisel3/util/Decoupled.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ abstract class ReadyValidIO[+T <: Data](gen: T) extends Bundle
2121
{
2222
// Compatibility hack for rocket-chip
2323
private val genType = (DataMirror.internal.isSynthesizable(gen), chisel3.internal.Builder.currentModule) match {
24-
case (true, Some(module: MultiIOModule))
24+
case (true, Some(module: Module))
2525
if !module.compileOptions.declaredTypeMustBeUnbound => chiselTypeOf(gen)
2626
case _ => gen
2727
}

src/test/scala/chiselTests/AnalogIntegrationSpec.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,19 @@ class AnalogBlackBox(index: Int) extends BlackBox(Map("index" -> index)) {
3131
val io = IO(new AnalogBlackBoxIO(1))
3232
}
3333

34+
trait AnalogBlackBoxModuleIntf extends Module {
35+
def io: AnalogBlackBoxIO
36+
}
37+
3438
// AnalogBlackBox wrapper, which extends Module to present the common io._ interface
35-
class AnalogBlackBoxModule(index: Int) extends Module {
39+
class AnalogBlackBoxModule(index: Int) extends AnalogBlackBoxModuleIntf {
3640
val io = IO(new AnalogBlackBoxIO(1))
3741
val impl = Module(new AnalogBlackBox(index))
3842
io <> impl.io
3943
}
4044

4145
// Wraps up n blackboxes, connecing their buses and simply forwarding their ports up
42-
class AnalogBlackBoxWrapper(n: Int, idxs: Seq[Int]) extends Module {
46+
class AnalogBlackBoxWrapper(n: Int, idxs: Seq[Int]) extends AnalogBlackBoxModuleIntf {
4347
require(n > 0)
4448
val io = IO(new AnalogBlackBoxIO(n))
4549
val bbs = idxs.map(i => Module(new AnalogBlackBoxModule(i)))

src/test/scala/chiselTests/AutoClonetypeSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class AutoClonetypeSpec extends ChiselFlatSpec with Utils {
198198
}
199199

200200
"Wrapped IO construction without parent reference" should "not fail for autoclonetype" in {
201-
class TestModule extends MultiIOModule {
201+
class TestModule extends Module {
202202
def thunk[T](f: => T): T = f
203203
val works = thunk(IO(new Bundle {
204204
val x = Output(UInt(3.W))
@@ -208,7 +208,7 @@ class AutoClonetypeSpec extends ChiselFlatSpec with Utils {
208208
}
209209

210210
"Wrapped IO construction with parent references" should "not fail for autoclonetype" in {
211-
class TestModule(blah: Int) extends MultiIOModule {
211+
class TestModule(blah: Int) extends Module {
212212
// Note that this currently fails only if f: =>T on Scala 2.11.12
213213
// This works successfully with 2.12.11
214214
def thunk[T](f: => T): T = f

src/test/scala/chiselTests/BoringUtilsSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class BoringUtilsSpec extends ChiselFlatSpec with ChiselRunners {
7171
out := x
7272
}
7373

74-
class Top(val width: Int) extends MultiIOModule {
74+
class Top(val width: Int) extends Module {
7575
/* From the perspective of deduplication, all sources are identical and all sinks are identical. */
7676
val sources = Seq.fill(3)(Module(new Source))
7777
val sinks = Seq.fill(6)(Module(new Sink))

0 commit comments

Comments
 (0)