diff options
| author | Adam Izraelevitz | 2020-03-02 10:51:51 -0800 |
|---|---|---|
| committer | GitHub | 2020-03-02 18:51:51 +0000 |
| commit | 1a4e0dd65ba3e64268beca8f592bd58d98c434a4 (patch) | |
| tree | a1ba3415731e88065c00dc6e874d65e113a337ef /src/test/scala | |
| parent | 016939265e15936dc3ba9310d1a79ec1f60176f6 (diff) | |
Cleanup aspects (#1359)
* Clean up aspects
* Refactored InjectingAspect with InjectorAspect
* Made AspectLibrary work with objects
* Cleaned up code
* Apply suggestions from code review
* Added tests, removed deprecated newInstance call
* Backed out removal of newInstance as exceptions were different
* Removed trailing commas
Diffstat (limited to 'src/test/scala')
| -rw-r--r-- | src/test/scala/chiselTests/aop/SelectSpec.scala | 2 | ||||
| -rw-r--r-- | src/test/scala/chiselTests/stage/ChiselMainSpec.scala | 31 |
2 files changed, 29 insertions, 4 deletions
diff --git a/src/test/scala/chiselTests/aop/SelectSpec.scala b/src/test/scala/chiselTests/aop/SelectSpec.scala index 80ab518f..49341ed5 100644 --- a/src/test/scala/chiselTests/aop/SelectSpec.scala +++ b/src/test/scala/chiselTests/aop/SelectSpec.scala @@ -33,7 +33,7 @@ class SelectTester(results: Seq[Int]) extends BasicTester { } } -case class SelectAspect[T <: RawModule, X](selector: T => Seq[X], desired: T => Seq[X])(implicit tTag: TypeTag[T]) extends Aspect[T] { +case class SelectAspect[T <: RawModule, X](selector: T => Seq[X], desired: T => Seq[X]) extends Aspect[T] { override def toAnnotation(top: T): AnnotationSeq = { val results = selector(top) val desiredSeq = desired(top) diff --git a/src/test/scala/chiselTests/stage/ChiselMainSpec.scala b/src/test/scala/chiselTests/stage/ChiselMainSpec.scala index 7862acd6..2b3b9c2c 100644 --- a/src/test/scala/chiselTests/stage/ChiselMainSpec.scala +++ b/src/test/scala/chiselTests/stage/ChiselMainSpec.scala @@ -4,22 +4,37 @@ package chiselTests.stage import chisel3._ import chisel3.stage.ChiselMain - import java.io.File +import chisel3.aop.inspecting.{InspectingAspect, InspectorAspect} import org.scalatest.{FeatureSpec, GivenWhenThen, Matchers} object ChiselMainSpec { /** A module that connects two different types together resulting in an elaboration error */ class DifferentTypesModule extends RawModule { - val in = IO(UInt(1.W)) - val out = IO(SInt(1.W)) + val in = IO(Input(UInt(1.W))) + val out = IO(Output(SInt(1.W))) + out := in + } + + /** A module that connects two of the same types together */ + class SameTypesModule extends MultiIOModule { + val in = IO(Input(UInt(1.W))) + val out = IO(Output(UInt(1.W))) out := in } } +case class TestClassAspect() extends InspectorAspect[RawModule] ({ + _: RawModule => println("Ran inspectingAspect") +}) + +case object TestObjectAspect extends InspectorAspect[RawModule] ({ + _: RawModule => println("Ran inspectingAspect") +}) + class ChiselMainSpec extends FeatureSpec with GivenWhenThen with Matchers with chiselTests.Utils { import ChiselMainSpec._ @@ -113,5 +128,15 @@ class ChiselMainSpec extends FeatureSpec with GivenWhenThen with Matchers with c result = 1) ).foreach(runStageExpectFiles) } + feature("Aspect library") { + Seq( + ChiselMainTest(args = Array( "-X", "high", "--with-aspect", "chiselTests.stage.TestClassAspect" ), + generator = Some(classOf[SameTypesModule]), + stdout = Some("Ran inspectingAspect")), + ChiselMainTest(args = Array( "-X", "high", "--with-aspect", "chiselTests.stage.TestObjectAspect" ), + generator = Some(classOf[SameTypesModule]), + stdout = Some("Ran inspectingAspect")) + ).foreach(runStageExpectFiles) + } } |
