aboutsummaryrefslogtreecommitdiff
path: root/src/main/stanza/primop.stanza
diff options
context:
space:
mode:
authorazidar2016-01-26 14:18:29 -0800
committerazidar2016-01-28 09:25:04 -0800
commit8c288f7b159b3f4ca1cb0d5c5012eb8fb52d5214 (patch)
tree89b75b682988164fc41e557916c98f762405ba41 /src/main/stanza/primop.stanza
parentc319b07576a574caa5061892d6e565b9f9370854 (diff)
Updated with new primops. Removed addw,subw,quo,rem,bit. Added head,tail,asClock.
Diffstat (limited to 'src/main/stanza/primop.stanza')
-rw-r--r--src/main/stanza/primop.stanza137
1 files changed, 77 insertions, 60 deletions
diff --git a/src/main/stanza/primop.stanza b/src/main/stanza/primop.stanza
index 4b8d0cbc..b6e81be1 100644
--- a/src/main/stanza/primop.stanza
+++ b/src/main/stanza/primop.stanza
@@ -12,6 +12,7 @@ public defn set-primop-type (e:DoPrim) -> DoPrim :
defn MAX (w1:Width,w2:Width) -> Width : MaxWidth(list(w1,w2))
defn MINUS (w1:Width,w2:Width) -> Width : MinusWidth(w1,w2)
defn POW (w1:Width) -> Width : ExpWidth(w1)
+ defn MIN (w1:Width,w2:Width) -> Width : MinWidth(list(w1,w2))
val o = op(e)
val a = args(e)
val c = consts(e)
@@ -38,20 +39,6 @@ public defn set-primop-type (e:DoPrim) -> DoPrim :
(t1:SIntType, t2:UIntType) : SIntType(PLUS(MAX(w1(),w2()),ONE))
(t1:SIntType, t2:SIntType) : SIntType(PLUS(MAX(w1(),w2()),ONE))
(t1, t2) : UnknownType()
- ADD-WRAP-OP : DoPrim{o,a,c,_} $
- match(t1(),t2()) :
- (t1:UIntType, t2:UIntType) : UIntType(MAX(w1(),w2()))
- (t1:UIntType, t2:SIntType) : SIntType(MAX(w1(),w2()))
- (t1:SIntType, t2:UIntType) : SIntType(MAX(w1(),w2()))
- (t1:SIntType, t2:SIntType) : SIntType(MAX(w1(),w2()))
- (t1, t2) : UnknownType()
- SUB-WRAP-OP : DoPrim{o,a,c,_} $
- match(t1(),t2()) :
- (t1:UIntType, t2:UIntType) : UIntType(MAX(w1(),w2()))
- (t1:UIntType, t2:SIntType) : SIntType(MAX(w1(),w2()))
- (t1:SIntType, t2:UIntType) : SIntType(MAX(w1(),w2()))
- (t1:SIntType, t2:SIntType) : SIntType(MAX(w1(),w2()))
- (t1, t2) : UnknownType()
MUL-OP : DoPrim{o,a,c,_} $
match(t1(),t2()) :
(t1:UIntType, t2:UIntType) : UIntType(PLUS(w1(),w2()))
@@ -62,58 +49,63 @@ public defn set-primop-type (e:DoPrim) -> DoPrim :
DIV-OP : DoPrim{o,a,c,_} $
match(t1(),t2()) :
(t1:UIntType, t2:UIntType) : UIntType(w1())
- (t1:UIntType, t2:SIntType) : SIntType(PLUS(w1(),w2()))
+ (t1:UIntType, t2:SIntType) : SIntType(PLUS(w1(),ONE))
(t1:SIntType, t2:UIntType) : SIntType(w1())
- (t1:SIntType, t2:SIntType) : SIntType(PLUS(w1(),w2()))
+ (t1:SIntType, t2:SIntType) : SIntType(PLUS(w1(),ONE))
(t1, t2) : UnknownType()
MOD-OP : DoPrim{o,a,c,_} $
match(t1(),t2()) :
- (t1:UIntType, t2:UIntType) : UIntType(w2())
- (t1:UIntType, t2:SIntType) : UIntType(w2())
- (t1:SIntType, t2:UIntType) : SIntType(PLUS(w2(),ONE))
- (t1:SIntType, t2:SIntType) : SIntType(w2())
+ (t1:UIntType, t2:UIntType) : UIntType(MIN(w1(),w2()))
+ (t1:UIntType, t2:SIntType) : UIntType(MIN(w1(),w2()))
+ (t1:SIntType, t2:UIntType) : SIntType(MIN(w1(),PLUS(w2(),ONE)))
+ (t1:SIntType, t2:SIntType) : SIntType(MIN(w1(),w2()))
+ (t1, t2) : UnknownType()
+ LESS-OP : DoPrim{o,a,c,_} $
+ match(t1(),t2()) :
+ (t1:UIntType|SIntType, t2:UIntType|SIntType) : BoolType()
(t1, t2) : UnknownType()
- QUO-OP : DoPrim{o,a,c,_} $
+ LESS-EQ-OP : DoPrim{o,a,c,_} $
match(t1(),t2()) :
- (t1:UIntType, t2:UIntType) : UIntType(PLUS(w1(),ONE))
- (t1:UIntType, t2:SIntType) : SIntType(w1())
- (t1:SIntType, t2:UIntType) : SIntType(PLUS(w1(),ONE))
- (t1:SIntType, t2:SIntType) : SIntType(w1())
+ (t1:UIntType|SIntType, t2:UIntType|SIntType) : BoolType()
(t1, t2) : UnknownType()
- REM-OP : DoPrim{o,a,c,_} $
+ GREATER-OP : DoPrim{o,a,c,_} $
match(t1(),t2()) :
- (t1:UIntType, t2:UIntType) : UIntType(w2())
- (t1:UIntType, t2:SIntType) : SIntType(w2())
- (t1:SIntType, t2:UIntType) : UIntType(PLUS(w2(),ONE))
- (t1:SIntType, t2:SIntType) : SIntType(w2())
+ (t1:UIntType|SIntType, t2:UIntType|SIntType) : BoolType()
+ (t1, t2) : UnknownType()
+ GREATER-EQ-OP : DoPrim{o,a,c,_} $
+ match(t1(),t2()) :
+ (t1:UIntType|SIntType, t2:UIntType|SIntType) : BoolType()
+ (t1, t2) : UnknownType()
+ EQUAL-OP : DoPrim{o,a,c,_} $
+ match(t1(),t2()) :
+ (t1:UIntType|SIntType, t2:UIntType|SIntType) : BoolType()
+ (t1, t2) : UnknownType()
+ NEQUAL-OP : DoPrim{o,a,c,_} $
+ match(t1(),t2()) :
+ (t1:UIntType|SIntType, t2:UIntType|SIntType) : BoolType()
(t1, t2) : UnknownType()
- LESS-OP : DoPrim(o,a,c,BoolType())
- LESS-EQ-OP : DoPrim(o,a,c,BoolType())
- GREATER-OP : DoPrim(o,a,c,BoolType())
- GREATER-EQ-OP : DoPrim(o,a,c,BoolType())
- EQUAL-OP : DoPrim(o,a,c,BoolType())
- NEQUAL-OP : DoPrim(o,a,c,BoolType())
- EQUIV-OP : DoPrim(o,a,c,BoolType())
- NEQUIV-OP : DoPrim(o,a,c,BoolType())
- ;MUX-OP : DoPrim{o,a,c,_} $
- ; match(t2(),t3()) :
- ; (t2:UIntType, t3:UIntType) : UIntType(MAX(w2(),w3()))
- ; (t2:SIntType, t3:SIntType) : SIntType(MAX(w2(),w3()))
- ; (t2, t3) : UnknownType()
PAD-OP : DoPrim{o,a,c,_} $
match(t1()) :
- (t1:UIntType) : UIntType(c1())
- (t1:SIntType) : SIntType(c1())
+ (t1:UIntType) : UIntType(MAX(w1(),c1()))
+ (t1:SIntType) : SIntType(MAX(w1(),c1()))
(t1) : UnknownType()
AS-UINT-OP : DoPrim{o,a,c,_} $
match(t1()) :
(t1:UIntType) : UIntType(w1())
(t1:SIntType) : UIntType(w1())
+ (t1:ClockType) : UIntType(ONE)
(t1) : UnknownType()
AS-SINT-OP : DoPrim{o,a,c,_} $
match(t1()) :
(t1:UIntType) : SIntType(w1())
(t1:SIntType) : SIntType(w1())
+ (t1:ClockType) : SIntType(ONE)
+ (t1) : UnknownType()
+ AS-CLOCK-OP : DoPrim{o,a,c,_} $
+ match(t1()) :
+ (t1:UIntType) : ClockType()
+ (t1:SIntType) : ClockType()
+ (t1:ClockType) : ClockType()
(t1) : UnknownType()
SHIFT-LEFT-OP : DoPrim{o,a,c,_} $
match(t1()) :
@@ -143,30 +135,55 @@ public defn set-primop-type (e:DoPrim) -> DoPrim :
NEG-OP : DoPrim{o,a,c,_} $
match(t1()) :
(t1:UIntType) : SIntType(PLUS(w1(),ONE))
- (t1:SIntType) : SIntType(w1())
+ (t1:SIntType) : SIntType(PLUS(w1(),ONE))
(t1) : UnknownType()
- BIT-NOT-OP : DoPrim(o,a,c,t1())
- BIT-AND-OP : DoPrim{o,a,c,_} $
+ NOT-OP : DoPrim{o,a,c,_} $
+ match(t1()) :
+ (t1:UIntType|SIntType) : UIntType(w1())
+ (t1) : UnknownType()
+ AND-OP : DoPrim{o,a,c,_} $
match(t1()) :
(t1:UIntType) : UIntType(MAX(w1(),w2()))
- (t1:SIntType) : SIntType(MAX(w1(),w2()))
+ (t1:SIntType) : UIntType(MAX(w1(),w2()))
(t1) : UnknownType()
- BIT-OR-OP : DoPrim{o,a,c,_} $
+ OR-OP : DoPrim{o,a,c,_} $
match(t1()) :
(t1:UIntType) : UIntType(MAX(w1(),w2()))
- (t1:SIntType) : SIntType(MAX(w1(),w2()))
+ (t1:SIntType) : UIntType(MAX(w1(),w2()))
(t1) : UnknownType()
- BIT-XOR-OP : DoPrim{o,a,c,_} $
+ XOR-OP : DoPrim{o,a,c,_} $
match(t1()) :
(t1:UIntType) : UIntType(MAX(w1(),w2()))
- (t1:SIntType) : SIntType(MAX(w1(),w2()))
- (t1) : UnknownType()
- BIT-AND-REDUCE-OP : DoPrim(o,a,c,BoolType())
- BIT-OR-REDUCE-OP : DoPrim(o,a,c,BoolType())
- BIT-XOR-REDUCE-OP : DoPrim(o,a,c,BoolType())
- CONCAT-OP : DoPrim(o,a,c,UIntType(PLUS(w1(),w2())))
- BIT-SELECT-OP : DoPrim(o,a,c,BoolType())
- BITS-SELECT-OP : DoPrim(o,a,c,UIntType(PLUS(MINUS(c1(),c2()),ONE)))
+ (t1:SIntType) : UIntType(MAX(w1(),w2()))
+ (t1) : UnknownType()
+ AND-REDUCE-OP : DoPrim{o,a,c,_} $
+ match(t1()) :
+ (t1:UIntType|SIntType) : BoolType()
+ (t1) : UnknownType()
+ OR-REDUCE-OP : DoPrim{o,a,c,_} $
+ match(t1()) :
+ (t1:UIntType|SIntType) : BoolType()
+ (t1) : UnknownType()
+ XOR-REDUCE-OP : DoPrim{o,a,c,_} $
+ match(t1()) :
+ (t1:UIntType|SIntType) : BoolType()
+ (t1) : UnknownType()
+ CONCAT-OP : DoPrim{o,a,c,_} $
+ match(t1(),t2()) :
+ (t1:UIntType|SIntType, t2:UIntType|SIntType) : UIntType(PLUS(w1(),w2()))
+ (t1, t2) : UnknownType()
+ BITS-SELECT-OP : DoPrim{o,a,c,_} $
+ match(t1()) :
+ (t1:UIntType|SIntType) : UIntType(PLUS(MINUS(c1(),c2()),ONE))
+ (t1) : UnknownType()
+ HEAD-OP : DoPrim{o,a,c,_} $
+ match(t1()) :
+ (t1:UIntType|SIntType) : UIntType(c1())
+ (t1) : UnknownType()
+ TAIL-OP : DoPrim{o,a,c,_} $
+ match(t1()) :
+ (t1:UIntType|SIntType) : UIntType(MINUS(w1(),c1()))
+ (t1) : UnknownType()
;public defn primop-gen-constraints (e:DoPrim,v:Vector<WGeq>) -> Type :
; defn get-max (i0:Int,i1:Int) -> Width : get-max(list(i0,i1))