summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core/UserModule.scala
diff options
context:
space:
mode:
authorRichard Lin2017-06-26 18:35:46 -0700
committerGitHub2017-06-26 18:35:46 -0700
commitaaee58d374dc3f3a088856da13a6a59ecffb2cac (patch)
tree790828de9a9fbb1dfd26635eebaf27668a4cc8df /chiselFrontend/src/main/scala/chisel3/core/UserModule.scala
parent91850ec917a432e9e3db588e7711c8a82801eb49 (diff)
Directions internals mega-refactor (#617)
Part 1 of mega-change in #578 Major notes: - Input(...) and Output(...) now (effectively) recursively override their elements' directions - Nodes given userDirection (Input, Output, Flip - what the user assigned to _that_ node) and actualDirection (Input, Output, None, but also Bidirectional and BidirectionalFlip for mostly Aggregates), because of the above (since a higher-level Input(...) can override the locally specified user direction). - DataMirror (node reflection APIs) added to chisel3.experimental. This provides ways to query the user given direction of a node as well as the actual direction. - checkSynthesizable replaced with requireIsHardware and requireIsChiselType and made available in chisel3.experimental. Internal changes notes: - toType moved into Emitter, this makes the implementation cleaner especially considering that Vec types can't be flipped in FIRRTL. This also more clearly separates Chisel frontend from FIRRTL emission. - Direction separated from Bindings, both are now fields in Data, and all nodes are given hierarchical directions (Aggregates may be Bidirectional). The actualDirection at the Element (leaf) level should be the same as binding directions previously. - Bindings are hierarchical, children (of a, for example, Bundle) have a ChildBinding that points to their parent. This is different than the previous scheme where Bindings only applied at the Element (leaf) level. - Lots of small misc clean up. Future PRs will address other parts of #578, including stricter direction checks that aren't a side-effect of this internal refactor, stricter checks and splitting of binding operations (Wire vs. WireInit), and node operations not introduced here (getType and deprecation of chiselCloneType). Since those shouldn't mess with internals, those should be much smaller.
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/UserModule.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/UserModule.scala18
1 files changed, 7 insertions, 11 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/UserModule.scala b/chiselFrontend/src/main/scala/chisel3/core/UserModule.scala
index 666be4d0..5207ef04 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/UserModule.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/UserModule.scala
@@ -64,21 +64,17 @@ abstract class UserModule(implicit moduleCompileOptions: CompileOptions)
id._onModuleClose
}
- val firrtlPorts = for (port <- getModulePorts) yield {
- // Port definitions need to know input or output at top-level. 'flipped' means Input.
- val direction = if(Data.isFirrtlFlipped(port)) Direction.Input else Direction.Output
- firrtl.Port(port, direction)
- }
+ val firrtlPorts = getModulePorts map {port => Port(port, port.userDirection)}
_firrtlPorts = Some(firrtlPorts)
// Generate IO invalidation commands to initialize outputs as unused
val invalidateCommands = getModulePorts map {port => DefInvalid(UnlocatableSourceInfo, port.ref)}
-
+
val component = DefModule(this, name, firrtlPorts, invalidateCommands ++ getCommands)
_component = Some(component)
component
}
-
+
// There is no initialization to be done by default.
private[core] def initializeInParent() {}
}
@@ -100,7 +96,7 @@ abstract class ImplicitModule(implicit moduleCompileOptions: CompileOptions)
private[core] override def initializeInParent() {
implicit val sourceInfo = UnlocatableSourceInfo
-
+
for (port <- getModulePorts) {
pushCommand(DefInvalid(sourceInfo, port.ref))
}
@@ -122,7 +118,7 @@ abstract class LegacyModule(implicit moduleCompileOptions: CompileOptions)
// These are to be phased out
protected var override_clock: Option[Clock] = None
protected var override_reset: Option[Bool] = None
-
+
// _clock and _reset can be clock and reset in these 2ary constructors
// once chisel2 compatibility issues are resolved
@deprecated("Module constructor with override_clock and override_reset deprecated, use withClockAndReset", "chisel3")
@@ -132,7 +128,7 @@ abstract class LegacyModule(implicit moduleCompileOptions: CompileOptions)
this.override_clock = override_clock
this.override_reset = override_reset
}
-
+
@deprecated("Module constructor with override _clock deprecated, use withClock", "chisel3")
def this(_clock: Clock)(implicit moduleCompileOptions: CompileOptions) = this(Option(_clock), None)(moduleCompileOptions)
@deprecated("Module constructor with override _reset deprecated, use withReset", "chisel3")
@@ -174,7 +170,7 @@ abstract class LegacyModule(implicit moduleCompileOptions: CompileOptions)
// Don't generate source info referencing parents inside a module, since this interferes with
// module de-duplication in FIRRTL emission.
implicit val sourceInfo = UnlocatableSourceInfo
-
+
pushCommand(DefInvalid(sourceInfo, io.ref))
override_clock match {