diff options
| author | Jack | 2016-05-18 12:08:08 -0700 |
|---|---|---|
| committer | jackkoenig | 2016-09-12 21:30:39 -0700 |
| commit | 5e62c6ba87e398509c1bc7a3d987c7c2e0f7abc4 (patch) | |
| tree | faff0cf3eb073134ef68f5750127c0af01b4c1d3 /src | |
| parent | 654f1130b604d74c0a194b2598d70111583b442e (diff) | |
Add legalization of pad operation on literals.
Performing a pad on SInt literals results in linting warnings in Verilator.
This commit replaces pad operations on literal values with a literal of the
correct width.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/firrtl/passes/Passes.scala | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main/scala/firrtl/passes/Passes.scala b/src/main/scala/firrtl/passes/Passes.scala index 66437556..d5d9a3b6 100644 --- a/src/main/scala/firrtl/passes/Passes.scala +++ b/src/main/scala/firrtl/passes/Passes.scala @@ -238,6 +238,13 @@ object Legalize extends Pass { case _ => expr } } + private def legalizePad(expr: DoPrim): Expression = expr.args.head match { + case UIntLiteral(value, IntWidth(width)) if (width < expr.consts.head) => + UIntLiteral(value, IntWidth(expr.consts.head)) + case SIntLiteral(value, IntWidth(width)) if (width < expr.consts.head) => + SIntLiteral(value, IntWidth(expr.consts.head)) + case _ => expr + } private def legalizeConnect(c: Connect): Statement = { val t = c.loc.tpe val w = bitWidth(t) @@ -256,6 +263,7 @@ object Legalize extends Pass { def legalizeE(expr: Expression): Expression = expr map legalizeE match { case prim: DoPrim => prim.op match { case Shr => legalizeShiftRight(prim) + case Pad => legalizePad(prim) case Bits => legalizeBits(prim) case _ => prim } |
