diff options
| author | Jack Koenig | 2017-11-09 19:01:25 -0800 |
|---|---|---|
| committer | Jack Koenig | 2017-12-12 15:20:27 -0800 |
| commit | 2ad8cded49d5a963a84ca22808b271607f1b0ba3 (patch) | |
| tree | 54fe9ad18ed5247d34f683a79a4abed39161ade7 /src | |
| parent | 0fd0c66adcf1226ee5947cdaa5629bf59c4123f1 (diff) | |
Make object ConstantPropagation utils
Move pad to object ConstantPropagation so other transforms can use it
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/firrtl/transforms/ConstantPropagation.scala | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/main/scala/firrtl/transforms/ConstantPropagation.scala b/src/main/scala/firrtl/transforms/ConstantPropagation.scala index 84b63e3d..ca48cbb5 100644 --- a/src/main/scala/firrtl/transforms/ConstantPropagation.scala +++ b/src/main/scala/firrtl/transforms/ConstantPropagation.scala @@ -16,15 +16,20 @@ import firrtl.analyses.InstanceGraph import annotation.tailrec import collection.mutable -class ConstantPropagation extends Transform { - def inputForm = LowForm - def outputForm = LowForm - - private def pad(e: Expression, t: Type) = (bitWidth(e.tpe), bitWidth(t)) match { +object ConstantPropagation { + /** Pads e to the width of t */ + def pad(e: Expression, t: Type) = (bitWidth(e.tpe), bitWidth(t)) match { case (we, wt) if we < wt => DoPrim(Pad, Seq(e), Seq(wt), t) case (we, wt) if we == wt => e } +} + +class ConstantPropagation extends Transform { + import ConstantPropagation._ + def inputForm = LowForm + def outputForm = LowForm + private def asUInt(e: Expression, t: Type) = DoPrim(AsUInt, Seq(e), Seq(), t) trait FoldLogicalOp { |
