aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorazidar2015-07-31 16:31:10 -0700
committerazidar2015-07-31 16:31:10 -0700
commitba55a55ee07805d28995b535beb5a19bd4a99c5c (patch)
treebc636b7f11efb34166a357678a1b4c2471f33552 /src
parent0fc3314eb15c6f2e42b21a175978a69217810879 (diff)
Added errors for bulk connects where field names match but types/flips don't
Diffstat (limited to 'src')
-rw-r--r--src/main/stanza/errors.stanza22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/main/stanza/errors.stanza b/src/main/stanza/errors.stanza
index 8727f762..f97b43b7 100644
--- a/src/main/stanza/errors.stanza
+++ b/src/main/stanza/errors.stanza
@@ -621,13 +621,31 @@ public defn check-types (c:Circuit) -> Circuit :
(e:DoPrim) : check-types-primop(e,errors,info)
(e:UIntValue|SIntValue) : false
e
+
+ defn bulk-equals? (t1:Type,t2:Type) -> True|False :
+ match(t1,t2) :
+ (t1:BundleType,t2:BundleType) :
+ var same? = true
+ for (f1 in fields(t1),f2 in fields(t2)) do :
+ if name(f1) == name(f2) :
+ if flip(f1) != flip(f2) : same? = false
+ if not bulk-equals?(type(f1),type(f2)) : same? = false
+ same?
+ (t1:ClockType,t2:ClockType) : true
+ (t1:UIntType,t2:UIntType) : true
+ (t1:SIntType,t2:SIntType) : true
+ (t1:VectorType,t2:VectorType) :
+ if bulk-equals?(type(t1),type(t2)) : true
+ else : false
+ (t1,t2) : false
+
defn check-types-s (s:Stmt) -> Stmt :
map{check-types-s,_} $ {
match(map(check-types-e{info(s),_},s)) :
(s:Connect) :
if type(loc(s)) != type(exp(s)) : add(errors,InvalidConnect(info(s)))
- (s:Connect) :
- if type(loc(s)) != type(exp(s)) : add(errors,InvalidConnect(info(s)))
+ (s:BulkConnect) :
+ if not bulk-equals?(type(loc(s)),type(exp(s))) : add(errors,InvalidConnect(info(s)))
(s:OnReset) :
if type(loc(s)) != type(exp(s)) : add(errors,InvalidConnect(info(s)))
(s:Conditionally) :