diff options
| author | azidar | 2016-01-31 12:59:31 -0800 |
|---|---|---|
| committer | azidar | 2016-02-09 18:57:06 -0800 |
| commit | e985d47312458459e9ebe42fe99b5a063c08e637 (patch) | |
| tree | d726c711e86d6e948a220a568dcae0a997629d18 /src | |
| parent | 2bd423fa061fb3e0973fa83e98f2877fd4616746 (diff) | |
Changed stanza output of UInt/SInt to include widths. Made tests match accordingly
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/firrtl/Visitor.scala | 10 | ||||
| -rw-r--r-- | src/main/stanza/ir-utils.stanza | 5 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/main/scala/firrtl/Visitor.scala b/src/main/scala/firrtl/Visitor.scala index e9bc633c..56d3bbe7 100644 --- a/src/main/scala/firrtl/Visitor.scala +++ b/src/main/scala/firrtl/Visitor.scala @@ -164,14 +164,20 @@ class Visitor(val fullFilename: String) extends FIRRTLBaseVisitor[AST] val (width, value) = if (ctx.getChildCount > 4) (IntWidth(string2BigInt(ctx.IntLit(0).getText)), string2BigInt(ctx.IntLit(1).getText)) - else (UnknownWidth(), string2BigInt(ctx.IntLit(0).getText)) + else { + val bigint = string2BigInt(ctx.IntLit(0).getText) + (IntWidth(BigInt(bigint.bitLength)),bigint) + } UIntValue(value, width) } case "SInt" => { val (width, value) = if (ctx.getChildCount > 4) (IntWidth(string2BigInt(ctx.IntLit(0).getText)), string2BigInt(ctx.IntLit(1).getText)) - else (UnknownWidth(), string2BigInt(ctx.IntLit(0).getText)) + else { + val bigint = string2BigInt(ctx.IntLit(0).getText) + (IntWidth(BigInt(bigint.bitLength + 1)),bigint) + } SIntValue(value, width) } case "validif(" => ValidIf(visitExp(ctx.exp(0)), visitExp(ctx.exp(1)), UnknownType()) diff --git a/src/main/stanza/ir-utils.stanza b/src/main/stanza/ir-utils.stanza index 24149649..3fc8b155 100644 --- a/src/main/stanza/ir-utils.stanza +++ b/src/main/stanza/ir-utils.stanza @@ -395,8 +395,9 @@ defmethod print (o:OutputStream, e:Expression) : (e:SubField) : print-all(o, [exp(e) "." name(e)]) (e:SubIndex) : print-all(o, [exp(e) "[" value(e) "]"]) (e:SubAccess) : print-all(o, [exp(e) "[" index(e) "]"]) - (e:UIntValue) : print-all(o, ["UInt(" value(e) ")"]) - (e:SIntValue) : print-all(o, ["SInt(" value(e) ")"]) + (e:UIntValue) : + print-all(o, ["UInt<" width(e) ">(" value(e) ")"]) + (e:SIntValue) : print-all(o, ["SInt<" width(e) ">(" value(e) ")"]) (e:DoPrim) : print-all(o, [op(e) "("]) print-all(o, join(concat(args(e), consts(e)), ", ")) |
