From 8aeed3484a660d8ed7fdd060bae52d8de8ca5d01 Mon Sep 17 00:00:00 2001 From: David Biancolin Date: Tue, 19 Nov 2019 22:58:21 -0800 Subject: [PATCH] [gg] Also check for clock ports in EnsureNoTargetIO.scala --- .../scala/midas/passes/EnsureNoTargetIO.scala | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sim/midas/src/main/scala/midas/passes/EnsureNoTargetIO.scala b/sim/midas/src/main/scala/midas/passes/EnsureNoTargetIO.scala index 20c35cb2..15d93c15 100644 --- a/sim/midas/src/main/scala/midas/passes/EnsureNoTargetIO.scala +++ b/sim/midas/src/main/scala/midas/passes/EnsureNoTargetIO.scala @@ -18,6 +18,8 @@ import java.io.{File, FileWriter, StringWriter} // Ensures that there are no dangling IO on the target. All I/O coming off the DUT must be bound // to an Bridge BlackBox +case class TargetMalformedException(message: String) extends RuntimeException(message) + private[passes] class EnsureNoTargetIO extends firrtl.Transform { def inputForm = HighForm def outputForm = HighForm @@ -27,14 +29,20 @@ private[passes] class EnsureNoTargetIO extends firrtl.Transform { val topName = state.circuit.main val topModule = state.circuit.modules.find(_.name == topName).get - val nonClockPorts = topModule.ports.filter(_.tpe != ClockType) + val (clockPorts, nonClockPorts) = topModule.ports.partition(_.tpe == ClockType) + + if (!clockPorts.isEmpty) { + val exceptionMessage = "Your target design has the following unexpected clock ports:\n" + + clockPorts.map(_.name).mkString("\n") + + "\nRemove these ports and generate clocks for your simulated system using a ClockBridge." + throw TargetMalformedException(exceptionMessage) + } if (!nonClockPorts.isEmpty) { - val exceptionMessage = """ -Your target design has dangling IO. -You must bind the following top-level ports to an Bridge BlackBox: -""" + nonClockPorts.map(_.name).mkString("\n") - throw new Exception(exceptionMessage) + val exceptionMessage = "Your target design has the following unexpecte IO ports:\n" + + nonClockPorts.map(_.name).mkString("\n") + + "\nRemove these ports and instead bind their sources/sinks to a target-to-host Bridge." + throw TargetMalformedException(exceptionMessage) } state }