diff options
| author | Jack Koenig | 2017-08-15 14:44:59 -0700 |
|---|---|---|
| committer | Jack Koenig | 2017-08-15 18:59:25 -0700 |
| commit | 90e775b1228765ce7f345716fa215f72b97816a9 (patch) | |
| tree | 73be4079fb5820cbae7ae7b788f43e1e2537f2c4 /src/main | |
| parent | c87145bc61a729bb035428d527c5787c174c5256 (diff) | |
Make .dir give correct direction for Module io in compatibility
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/scala/chisel3/compatibility.scala | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/src/main/scala/chisel3/compatibility.scala b/src/main/scala/chisel3/compatibility.scala index 33e8e75c..e169fb8f 100644 --- a/src/main/scala/chisel3/compatibility.scala +++ b/src/main/scala/chisel3/compatibility.scala @@ -29,26 +29,17 @@ package object Chisel { // scalastyle:ignore package.object.name } implicit class AddDirMethodToData[T<:Data](val target: T) extends AnyVal { - import chisel3.core.{DataMirror, ActualDirection, SpecifiedDirection} + import chisel3.core.{DataMirror, ActualDirection, requireIsHardware} def dir: Direction = { - DataMirror.isSynthesizable(target) match { - case true => target match { - case e: Element => DataMirror.directionOf(e) match { - case ActualDirection.Unspecified => NODIR - case ActualDirection.Output => OUTPUT - case ActualDirection.Input => INPUT - case dir => throw new RuntimeException(s"Unexpected element direction '$dir'") - } + requireIsHardware(target) // This has the side effect of calling _autoWrapPorts + target match { + case e: Element => DataMirror.directionOf(e) match { + case ActualDirection.Output => OUTPUT + case ActualDirection.Input => INPUT case _ => NODIR } - case false => DataMirror.specifiedDirectionOf(target) match { // returns local direction only - case SpecifiedDirection.Unspecified => NODIR - case SpecifiedDirection.Input => INPUT - case SpecifiedDirection.Output => OUTPUT - case dir => throw new RuntimeException(s"Unexpected element direction '$dir'") - } + case _ => NODIR } - } } |
