aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorSchuyler Eldridge2018-12-21 11:47:33 -0500
committerGitHub2018-12-21 11:47:33 -0500
commit93e1f334de0579f513c3ffa03cb5f06c622b4fa8 (patch)
treed6da0dfea409d43c2c271fd1de729a88a04da554 /src/main
parent3655ae091249a72bd424073cfb4a382a5ab170c6 (diff)
parentc727961ca6461d90858c4c66d8b01897293fc0ab (diff)
Merge pull request #976 from seldridge/none-compiler-form
Fix NoneCompiler outputForm
Diffstat (limited to 'src/main')
-rw-r--r--src/main/scala/firrtl/Compiler.scala4
-rw-r--r--src/main/scala/firrtl/LoweringCompilers.scala4
-rw-r--r--src/main/scala/firrtl/transforms/IdentityTransform.scala17
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
+
+}