diff options
| author | azidar | 2015-08-25 14:51:08 -0700 |
|---|---|---|
| committer | azidar | 2015-08-25 14:51:08 -0700 |
| commit | 9fd6d47c5ee82e4dac924e15b60f2a519d566b14 (patch) | |
| tree | 999ea3f223d228cef7f84ae7647ec95db7294e56 /src/main/stanza/errors.stanza | |
| parent | eb1ab67b6cc3fd4a549da563bf643bd519d7562e (diff) | |
Removed IntWidth, now only use LongWidth. Now do width inference for Constants in parser, and correctly subtract 1 (except when 0) when calculating width from num-bits of BigInt
Diffstat (limited to 'src/main/stanza/errors.stanza')
| -rw-r--r-- | src/main/stanza/errors.stanza | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/main/stanza/errors.stanza b/src/main/stanza/errors.stanza index 72535242..fd3dfc2a 100644 --- a/src/main/stanza/errors.stanza +++ b/src/main/stanza/errors.stanza @@ -252,8 +252,8 @@ public defn check-high-form (c:Circuit) -> Circuit : defn check-high-form-w (info:FileInfo,w:Width,unknown-ok?:True|False) -> Width : match(w) : - (w:IntWidth) : - if width(w) <= 0 : add(errors,NegWidth(info)) + (w:LongWidth) : + if width(w) <= to-long(0) : add(errors,NegWidth(info)) w (w:UnknownWidth) : if unknown-ok? == false : add(errors,IllegalUnknownWidth(info)) @@ -907,8 +907,6 @@ public defn check-width (c:Circuit) -> Circuit : defn check-width-m (m:Module) -> False : defn check-width-w (info:FileInfo,w:Width) -> Width : match(w) : - (w:IntWidth) : - if width(w) <= 0 : add(errors,NegWidth(info)) (w:LongWidth) : if width(w) <= to-long(0) : add(errors,NegWidth(info)) (w) : @@ -917,11 +915,15 @@ public defn check-width (c:Circuit) -> Circuit : defn check-width-e (info:FileInfo,e:Expression) -> Expression : match(map(check-width-e{info,_},e)) : - (e:UIntValue|SIntValue) : + (e:UIntValue) : match(width(e)) : - (w:IntWidth) : - if num-bits(value(e)) > width(w) : + (w:LongWidth) : + if max(to-long(1),to-long(num-bits(value(e)) - 1)) > width(w) : add(errors,WidthTooSmall(info,to-string(value(e)))) + (w) : add(errors,UninferredWidth(info)) + check-width-w(info,width(e)) + (e:SIntValue) : + match(width(e)) : (w:LongWidth) : if to-long(num-bits(value(e))) > width(w) : add(errors,WidthTooSmall(info,to-string(value(e)))) |
