diff options
| author | Adam Izraelevitz | 2015-10-06 14:36:51 -0700 |
|---|---|---|
| committer | Adam Izraelevitz | 2015-10-06 14:36:51 -0700 |
| commit | eb79a51cadcee109c4bcf727762027ba85aba36a (patch) | |
| tree | a2d52d8697b87b1d07615dc9153d3a4da1b6c95f /src/main/stanza/errors.stanza | |
| parent | 2485d20374166b27c06c475a4aef365761a818f7 (diff) | |
| parent | aa8cfe06fd76d47e3b3721aae6ccf6b39dda34b8 (diff) | |
Merge pull request #45 from ucb-bar/change-mem-type
Changed DefMemory to be a non-vector type with a size member
Diffstat (limited to 'src/main/stanza/errors.stanza')
| -rw-r--r-- | src/main/stanza/errors.stanza | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/main/stanza/errors.stanza b/src/main/stanza/errors.stanza index 8b8c86fb..ad289ea0 100644 --- a/src/main/stanza/errors.stanza +++ b/src/main/stanza/errors.stanza @@ -101,6 +101,10 @@ defn NegVecSize (info:FileInfo) : PassException $ string-join $ [info ": [module " mname "] Vector type size cannot be negative."] +defn NegMemSize (info:FileInfo) : + PassException $ string-join $ + [info ": [module " mname "] Memory size cannot be negative or zero."] + defn IllegalUnknownWidth (info:FileInfo) : PassException $ string-join $ [info ": [module " mname "] Widths must be defined for memories and poison nodes."] @@ -312,6 +316,7 @@ public defn check-high-form (c:Circuit) -> Circuit : check-name(info(s),name(s)) names[name(s)] = true if has-flip?(type(s)) : add(errors, MemWithFlip(info(s), name(s))) + if size(s) <= 0 : add(errors,NegMemSize(info(s))) check-high-form-t(info(s),type(s),false) check-high-form-e(info(s),clock(s),names) (s:DefInstance) : @@ -394,11 +399,20 @@ defn OnResetNotReg (info:FileInfo, name:Symbol) : PassException $ string-join $ [info ": [module " mname "] Illegal on-reset to non-reg reference " name "."] +defn AccessVecOrMem (info:FileInfo) : + PassException $ string-join $ + [info ": [module " mname "] Accessors can only access vector-typed components or memories."] + ;----------------- Check Kinds Pass --------------------- ; I may have been overeager in looking for places where mems can't be, as mems are guaranteed to have a vector ; type, and this will get caught in the type check pass public defn check-kinds (c:Circuit) -> Circuit : val errors = Vector<PassException>() + defn get-kind (e:Expression) -> Kind : + match(e) : + (e:WRef) : kind(e) + (e:WSubfield) : get-kind(exp(e)) + (e:WIndex) : get-kind(exp(e)) defn check-not-mem (info:FileInfo,e:Expression) -> False : do(check-not-mem{info,_},e) match(e) : @@ -424,7 +438,12 @@ public defn check-kinds (c:Circuit) -> Circuit : defn check-kinds-s (s:Stmt) -> False : match(s) : (s:DefNode) : check-not-mem(info(s),value(s)) - (s:DefAccessor) : check-not-mem(info(s),index(s)) + (s:DefAccessor) : + check-not-mem(info(s),index(s)) + if (get-kind(source(s)) != MemKind()) and (not type(source(s)) typeof VectorType) : + println(get-kind(source(s))) + println(type(source(s))) + add(errors,AccessVecOrMem(info(s))) (s:Conditionally) : check-not-mem(info(s),pred(s)) (s:Connect) : check-not-mem(info(s),loc(s)) @@ -519,7 +538,6 @@ defn OnResetIllegalFlips (info:FileInfo) : PassException $ string-join $ [info ": [module " mname "] The register in onreset cannot be a bundle type with flips."] - ;---------------- Helper Functions -------------- defmethod equal? (t1:Type,t2:Type) -> True|False : match(t1,t2) : @@ -1030,7 +1048,7 @@ public defn check-low-form (c:Circuit) -> Circuit : (s:DefPoison) : check-low-form-t(info(s),type(s),name(s)) (s:DefMemory) : - check-low-form-t(info(s),type(type(s)),name(s)) + check-low-form-t(info(s),type(s),name(s)) add(mems,name(s)) (s:DefInstance) : for f in fields(type(module(s)) as BundleType) do : |
