Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jack Koenig <jack.koenig3@gmail.com>
  • Loading branch information
adkian-sifive and jackkoenig authored Jun 9, 2022
1 parent 67a80ae commit 7a0c541
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions core/src/main/scala/chisel3/RawModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ abstract class RawModule(implicit moduleCompileOptions: CompileOptions) extends

private[chisel3] def checkPorts(): Unit = {
for (port <- getModulePorts) {
port._computeName(None, None).orElse(None) match {
case Some(name) =>
case None =>
Builder.error(
s"Unable to name port $port in $this, " +
"try making it a public field of the Module"
)
if (port._computeName(None, None).isEmpty) {
Builder.error(
s"Unable to name port $port in $this, " +
"try making it a public field of the Module"
)
}
}
}
Expand All @@ -63,7 +61,7 @@ abstract class RawModule(implicit moduleCompileOptions: CompileOptions) extends
// Ports get first naming priority, since they are part of a Module's IO spec
checkPorts()

// All suggestions are in, force names to every node.
// Now that elaboration is complete for this Module, we can finalize names
for (id <- getIds) {
id match {
case id: ModuleClone[_] => id.setRefAndPortsRef(_namespace) // special handling
Expand All @@ -83,7 +81,7 @@ abstract class RawModule(implicit moduleCompileOptions: CompileOptions) extends
case MemoryPortBinding(_, _) =>
id.forceName(None, default = "MPORT", _namespace)
case PortBinding(_) =>
id.forceName(None, default = "PORT", _namespace, true, { x: String => ModuleIO(this, x) })
id.forceName(None, default = "PORT", _namespace, true, x => ModuleIO(this, x))
case RegBinding(_, _) =>
id.forceName(None, default = "REG", _namespace)
case WireBinding(_, _) =>
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/chisel3/internal/Builder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private[chisel3] trait HasId extends InstanceId {
default: => String,
namespace: Namespace,
errorIfDup: Boolean = false,
refBuilder: String => Arg = (x: String) => (Ref(x))
refBuilder: String => Arg = Ref(_)
): Unit =
if (_ref.isEmpty) {
val candidate_name = _computeName(prefix, Some(default).filterNot(_ => errorIfDup)).get
Expand Down

0 comments on commit 7a0c541

Please sign in to comment.