From f7056f3529e34489b223993e975da0b2d66068a8 Mon Sep 17 00:00:00 2001 From: Angie Wang Date: Tue, 14 Mar 2017 23:59:57 -0700 Subject: [PATCH] Fft changes (#15) * modified CustomBundle to also apply on Int * programmatic bundle should take T <: Data instead of Data * turns out indexedElements doesn't synthesize * had to change a bunch of files to get clk/pads compiling again with recent firrtl mods --- .../transforms/clkgen/ClkSrcTransform.scala | 2 +- .../transforms/clkgen/CreateClkConstraints.scala | 2 +- .../transforms/pads/AddIOPadsTransform.scala | 11 +++++------ .../transforms/utils/ProgrammaticBundle.scala | 16 +++++++++------- .../scala/transforms/ResetInverterSpec.scala | 1 - 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tapeout/src/main/scala/transforms/clkgen/ClkSrcTransform.scala b/tapeout/src/main/scala/transforms/clkgen/ClkSrcTransform.scala index d5e887c6d9..4a447cb780 100644 --- a/tapeout/src/main/scala/transforms/clkgen/ClkSrcTransform.scala +++ b/tapeout/src/main/scala/transforms/clkgen/ClkSrcTransform.scala @@ -21,7 +21,7 @@ class ClkSrcTransform extends Transform with SimpleRun { InferTypes, new CreateClkConstraints(clkModAnnos, clkPortAnnos, targetDir) ) - state.copy(state = runPasses(state.circuit, passSeq), outputForm = outputForm) + state.copy(circuit = runPasses(state.circuit, passSeq)) } } } diff --git a/tapeout/src/main/scala/transforms/clkgen/CreateClkConstraints.scala b/tapeout/src/main/scala/transforms/clkgen/CreateClkConstraints.scala index 2e5021de5d..ea2ba22f37 100644 --- a/tapeout/src/main/scala/transforms/clkgen/CreateClkConstraints.scala +++ b/tapeout/src/main/scala/transforms/clkgen/CreateClkConstraints.scala @@ -89,7 +89,7 @@ class CreateClkConstraints( }).toSet val inlineTransform = new InlineInstances - val inlinedCircuit = inlineTransform.run(onlyClockCircuit, modulesToInline, Set()).circuit + val inlinedCircuit = inlineTransform.run(onlyClockCircuit, modulesToInline, Set(), None).circuit val topModule = inlinedCircuit.modules.find(_.name == top).getOrElse(throwInternalError) diff --git a/tapeout/src/main/scala/transforms/pads/AddIOPadsTransform.scala b/tapeout/src/main/scala/transforms/pads/AddIOPadsTransform.scala index 2531a6321c..df4536a538 100644 --- a/tapeout/src/main/scala/transforms/pads/AddIOPadsTransform.scala +++ b/tapeout/src/main/scala/transforms/pads/AddIOPadsTransform.scala @@ -16,7 +16,7 @@ class AddIOPadsTransform extends Transform with SimpleRun { val collectedAnnos = HasPadAnnotation(getMyAnnotations(state)) collectedAnnos match { // Transform not used - case None => CircuitState(state.circuit, LowForm) + case None => state case Some(x) => val techLoc = (new TechnologyLocation).get(state) // Get foundry pad templates from yaml @@ -45,11 +45,10 @@ class AddIOPadsTransform extends Transform with SimpleRun { ) // Expects BlackBox helper to be run after to inline pad Verilog! val prevAnnos = state.annotations.getOrElse(AnnotationMap(Seq.empty)).annotations - val cs = CircuitState( - runPasses(circuitWithBBs, passSeq), - LowForm, - Some(AnnotationMap(prevAnnos ++ bbAnnotations)) - ) + val cs = state.copy( + circuit = runPasses(circuitWithBBs, passSeq), + annotations = Some(AnnotationMap(prevAnnos ++ bbAnnotations))) + // TODO: *.f file is overwritten on subsequent executions, but it doesn't seem to be used anywhere? (new firrtl.transforms.BlackBoxSourceHelper).execute(cs) } diff --git a/tapeout/src/main/scala/transforms/utils/ProgrammaticBundle.scala b/tapeout/src/main/scala/transforms/utils/ProgrammaticBundle.scala index 7df199ba9a..17197c8055 100644 --- a/tapeout/src/main/scala/transforms/utils/ProgrammaticBundle.scala +++ b/tapeout/src/main/scala/transforms/utils/ProgrammaticBundle.scala @@ -3,22 +3,24 @@ package barstools.tapeout.transforms import chisel3._ import scala.collection.immutable.ListMap -final class CustomBundle(elts: (String, Data)*) extends Record { +final class CustomBundle[T <: Data](elts: (String, T)*) extends Record { val elements = ListMap(elts map { case (field, elt) => field -> elt.chiselCloneType }: _*) - def apply(elt: String): Data = elements(elt) + def apply(elt: String): T = elements(elt) + def apply(elt: Int): T = elements(elt.toString) override def cloneType = (new CustomBundle(elements.toList: _*)).asInstanceOf[this.type] } -final class CustomIndexedBundle(elts: (Int, Data)*) extends Record { +final class CustomIndexedBundle[T <: Data](elts: (Int, T)*) extends Record { // Must be String, Data val elements = ListMap(elts map { case (field, elt) => field.toString -> elt.chiselCloneType }: _*) - def indexedElements = ListMap(elts map { case (field, elt) => field -> elt.chiselCloneType }: _*) - def apply(elt: Int): Data = elements(elt.toString) + // TODO: Make an equivalent to the below work publicly + private def indexedElements = ListMap(elts map { case (field, elt) => field -> elt.chiselCloneType }: _*) + def apply(elt: Int): T = elements(elt.toString) override def cloneType = (new CustomIndexedBundle(indexedElements.toList: _*)).asInstanceOf[this.type] } object CustomIndexedBundle { - def apply(gen: Data, idxs: Seq[Int]) = new CustomIndexedBundle(idxs.map(_ -> gen): _*) + def apply[T <: Data](gen: T, idxs: Seq[Int]) = new CustomIndexedBundle(idxs.map(_ -> gen): _*) // Allows Vecs of elements of different types/widths - def apply(gen: Seq[Data]) = new CustomIndexedBundle(gen.zipWithIndex.map{ case (elt, field) => field -> elt }: _*) + def apply[T <: Data](gen: Seq[T]) = new CustomIndexedBundle(gen.zipWithIndex.map{ case (elt, field) => field -> elt }: _*) } \ No newline at end of file diff --git a/tapeout/src/test/scala/transforms/ResetInverterSpec.scala b/tapeout/src/test/scala/transforms/ResetInverterSpec.scala index fd49435ed5..0ae41dc1e4 100644 --- a/tapeout/src/test/scala/transforms/ResetInverterSpec.scala +++ b/tapeout/src/test/scala/transforms/ResetInverterSpec.scala @@ -3,7 +3,6 @@ package barstools.tapeout.transforms import chisel3._ -import chisel3.util.RegInit import firrtl._ import org.scalatest.{FreeSpec, Matchers}