diff options
| author | azidar | 2015-08-26 15:07:12 -0700 |
|---|---|---|
| committer | azidar | 2015-08-26 15:07:53 -0700 |
| commit | b6bf5ee9b29a117c1fcb3b7ec19ce1ce07132ffd (patch) | |
| tree | c65e8d722c77fbbaa42c4b3d98e3d0ba6cdb9fca /src/main/stanza/ir-parser.stanza | |
| parent | cf1fe102a99efee192288061849165072c699c2e (diff) | |
Fixed bug where firrtl was incorrectly judging the width of a bigint. #36 #37.
Diffstat (limited to 'src/main/stanza/ir-parser.stanza')
| -rw-r--r-- | src/main/stanza/ir-parser.stanza | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/main/stanza/ir-parser.stanza b/src/main/stanza/ir-parser.stanza index d3d9c379..f81777f5 100644 --- a/src/main/stanza/ir-parser.stanza +++ b/src/main/stanza/ir-parser.stanza @@ -277,9 +277,24 @@ defsyntax firrtl : ;Prefix Operators expterm = (?t:#inttype(?v:#string)) : + val b = BigIntLit(v as String) match(t) : - (t:UIntType) : UIntValue(BigIntLit(v as String), width(t)) - (t:SIntType) : SIntValue(BigIntLit(v as String), width(t)) + (t:UIntType) : + match(width(t)) : + (w:LongWidth) : + if to-long(max(1,(req-num-bits(b) - 1))) > width(w) : + FPE(form, "Width too small for UIntValue.") + UIntValue(b, w) + (w) : + UIntValue(b, w) + (t:SIntType) : + match(width(t)) : + (w:LongWidth) : + if to-long(req-num-bits(b)) > width(w) : + FPE(form, "Width too small for SIntValue.") + SIntValue(b, w) + (w) : + SIntValue(b, w) expterm = (?t:#inttype(?v:#int$)) : match(t) : @@ -288,7 +303,7 @@ defsyntax firrtl : FPE(form, "UIntValue cannot be negative.") match(width(t)) : (w:LongWidth) : - UIntValue(BigIntLit(v as Int,to-int(width(w))),w) + UIntValue(BigIntLit(v as Int,to-int(width(w)) + 1),w) (w) : val num-bits = req-num-bits(v as Int) UIntValue(BigIntLit(v as Int,num-bits), LongWidth(max(1,num-bits - 1))) |
