diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/firrtl/Compiler.scala | 4 | ||||
| -rw-r--r-- | src/main/scala/firrtl/LoweringCompilers.scala | 4 | ||||
| -rw-r--r-- | src/main/scala/firrtl/transforms/IdentityTransform.scala | 17 |
3 files changed, 24 insertions, 1 deletions
diff --git a/src/main/scala/firrtl/Compiler.scala b/src/main/scala/firrtl/Compiler.scala index 80ba42c4..87662800 100644 --- a/src/main/scala/firrtl/Compiler.scala +++ b/src/main/scala/firrtl/Compiler.scala @@ -373,6 +373,10 @@ trait Compiler extends LazyLogging { */ def transforms: Seq[Transform] + require(transforms.size >= 1, + s"Compiler transforms for '${this.getClass.getName}' must have at least ONE Transform! " + + "Use IdentityTransform if you need an identity/no-op transform.") + // Similar to (input|output)Form on [[Transform]] but derived from this Compiler's transforms def inputForm: CircuitForm = transforms.head.inputForm def outputForm: CircuitForm = transforms.last.outputForm diff --git a/src/main/scala/firrtl/LoweringCompilers.scala b/src/main/scala/firrtl/LoweringCompilers.scala index 350fd433..eab928c2 100644 --- a/src/main/scala/firrtl/LoweringCompilers.scala +++ b/src/main/scala/firrtl/LoweringCompilers.scala @@ -2,6 +2,8 @@ package firrtl +import firrtl.transforms.IdentityTransform + sealed abstract class CoreTransform extends SeqTransform /** This transforms "CHIRRTL", the chisel3 IR, to "Firrtl". Note the resulting @@ -132,7 +134,7 @@ import firrtl.transforms.BlackBoxSourceHelper */ class NoneCompiler extends Compiler { def emitter = new ChirrtlEmitter - def transforms: Seq[Transform] = Seq.empty + def transforms: Seq[Transform] = Seq(new IdentityTransform(ChirrtlForm)) } /** Emits input circuit diff --git a/src/main/scala/firrtl/transforms/IdentityTransform.scala b/src/main/scala/firrtl/transforms/IdentityTransform.scala new file mode 100644 index 00000000..a39ca4b7 --- /dev/null +++ b/src/main/scala/firrtl/transforms/IdentityTransform.scala @@ -0,0 +1,17 @@ +// See LICENSE for license details. + +package firrtl.transforms + +import firrtl.{CircuitForm, CircuitState, Transform} + +/** Transform that applies an identity function. This returns an unmodified [[CircuitState]]. + * @param form the input and output [[CircuitForm]] + */ +class IdentityTransform(form: CircuitForm) extends Transform { + + final override def inputForm: CircuitForm = form + final override def outputForm: CircuitForm = form + + final def execute(state: CircuitState): CircuitState = state + +} |
