summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests/AnnotationNoDedup.scala
diff options
context:
space:
mode:
authorJack Koenig2018-02-28 17:40:53 -0800
committerGitHub2018-02-28 17:40:53 -0800
commit46553432aaf65cff131e59081d57dabe16c2ab55 (patch)
tree2a64125046b36808a5a89c18f98204394c27ccd8 /src/test/scala/chiselTests/AnnotationNoDedup.scala
parent97871178cb511063965f971b768f91c289c4776f (diff)
Refactor Annotations (#767)
* Generalize ChiselAnnotation This allows us to delay creation of Annotations till elaboration is complete. Also update all annotation-related code. * Add RunFirrtlTransform Use a Chisel-specific RunFirrtlTransform API to preserve behavior of old ChiselAnnotation (now called ChiselLegacyAnnotation) * Use unique test directories in ChiselRunners.compile
Diffstat (limited to 'src/test/scala/chiselTests/AnnotationNoDedup.scala')
-rw-r--r--src/test/scala/chiselTests/AnnotationNoDedup.scala18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/test/scala/chiselTests/AnnotationNoDedup.scala b/src/test/scala/chiselTests/AnnotationNoDedup.scala
index 93167f69..d93da31f 100644
--- a/src/test/scala/chiselTests/AnnotationNoDedup.scala
+++ b/src/test/scala/chiselTests/AnnotationNoDedup.scala
@@ -3,16 +3,14 @@
package chiselTests
import chisel3._
-import chisel3.experimental.ChiselAnnotation
+import chisel3.experimental.{annotate, ChiselAnnotation}
import firrtl.FirrtlExecutionSuccess
-import firrtl.transforms.DedupModules
+import firrtl.transforms.NoDedupAnnotation
import org.scalatest.{FreeSpec, Matchers}
-trait NoDedupAnnotator {
- self: Module =>
-
- def doNotDedup(module: Module): Unit = {
- annotate(ChiselAnnotation(module, classOf[DedupModules], "nodedup!"))
+object doNotDedup {
+ def apply(module: Module): Unit = {
+ annotate(new ChiselAnnotation { def toFirrtl = NoDedupAnnotation(module.toNamed) })
}
}
@@ -24,7 +22,7 @@ class MuchUsedModule extends Module {
io.out := io.in +% 1.U
}
-class UsesMuchUsedModule(addAnnos: Boolean) extends Module with NoDedupAnnotator{
+class UsesMuchUsedModule(addAnnos: Boolean) extends Module {
val io = IO(new Bundle {
val in = Input(UInt(16.W))
val out = Output(UInt(16.W))
@@ -49,7 +47,7 @@ class UsesMuchUsedModule(addAnnos: Boolean) extends Module with NoDedupAnnotator
class AnnotationNoDedup extends FreeSpec with Matchers {
"Firrtl provides transform that reduces identical modules to a single instance" - {
- "Annotations can be added which will defeat this deduplication for specific modules instances" in {
+ "Annotations can be added which will prevent this deduplication for specific modules instances" in {
Driver.execute(Array("-X", "low", "--target-dir", "test_run_dir"), () => new UsesMuchUsedModule(addAnnos = true)) match {
case ChiselExecutionSuccess(_, _, Some(firrtlResult: FirrtlExecutionSuccess)) =>
val lowFirrtl = firrtlResult.emitted
@@ -62,7 +60,7 @@ class AnnotationNoDedup extends FreeSpec with Matchers {
case _ =>
}
}
- "Turning off these nnotations dedup all the occurrences" in {
+ "Turning off these annotations dedups all the occurrences" in {
Driver.execute(Array("-X", "low", "--target-dir", "test_run_dir"), () => new UsesMuchUsedModule(addAnnos = false)) match {
case ChiselExecutionSuccess(_, _, Some(firrtlResult: FirrtlExecutionSuccess)) =>
val lowFirrtl = firrtlResult.emitted