From 0c7aca561aef907314b0d9c9737fcea04ae6ce82 Mon Sep 17 00:00:00 2001 From: Adam Izraelevitz Date: Tue, 28 Jul 2015 13:29:55 -0700 Subject: Integrated bigint. Mostly works, but getting "cast" error for make Test. --- src/main/stanza/passes.stanza | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/main/stanza/passes.stanza') diff --git a/src/main/stanza/passes.stanza b/src/main/stanza/passes.stanza index 33ef666c..255354a3 100644 --- a/src/main/stanza/passes.stanza +++ b/src/main/stanza/passes.stanza @@ -6,6 +6,7 @@ defpackage firrtl/passes : import firrtl/primops import firrtl-main import firrtl/errors + import bigint ;============== Pass List ================ public val standard-passes = to-list $ [ @@ -1150,7 +1151,7 @@ defn expand-connect-indexed-stmt (s: Stmt,sh:HashTable) -> Stmt : to-list $ for (i in 0 to false, l in locs(s)) stream : Conditionally( info(s), - equality(ref,UIntValue(to-long $ i,UnknownWidth())), + equality(ref,UIntValue(BigIntLit(i),UnknownWidth())), Connect(info(s),l,exp(s)), EmptyStmt() ) @@ -1164,7 +1165,7 @@ defn expand-connect-indexed-stmt (s: Stmt,sh:HashTable) -> Stmt : to-list $ for (i in 1 to false, e in tail(exps(s))) stream : Conditionally( info(s), - equality(ref,UIntValue(to-long $ i,UnknownWidth())), + equality(ref,UIntValue(BigIntLit(i),UnknownWidth())), Connect(info(s),loc(s),e), EmptyStmt() ) @@ -1210,8 +1211,8 @@ public defmethod short-name (b:ExpandWhens) -> String : "expand-whens" ; ======== Expression Computation Library =========== -val zero = UIntValue(to-long $ 0,IntWidth(1)) -val one = UIntValue(to-long $ 1,IntWidth(1)) +val zero = UIntValue(BigIntLit("b0"),IntWidth(1)) +val one = UIntValue(BigIntLit("b1"),IntWidth(1)) defmethod equal? (e1:Expression,e2:Expression) -> True|False : match(e1,e2) : @@ -1547,7 +1548,7 @@ public defn expand-whens (c:Circuit) -> Circuit : (e:Expression) : val ref = WRef(name(s),type(s),NodeKind(),FEMALE) val en = to-exp(optimize $ get-write-enable(table[name(s)])) as Expression - if en == UIntValue(to-long(1),UnknownWidth()) : + if en == UIntValue(BigIntLit("b1"),UnknownWidth()) : add{cons,_} $ Connect(info(s),ref,e) else : add{cons,_} $ Conditionally(info(s),en,Connect(info(s),ref,e),EmptyStmt()) @@ -1562,7 +1563,7 @@ public defn expand-whens (c:Circuit) -> Circuit : match(e) : (e:Expression) : val en = (to-exp $ optimize $ get-write-enable(table[n])) as Expression - if en == UIntValue(to-long(1),UnknownWidth()) : + if en == UIntValue(BigIntLit("b1"),UnknownWidth()) : add{cons,_} $ Connect(info(s),ref,e) else : add{cons,_} $ Conditionally(info(s),en,Connect(info(s),ref,e),EmptyStmt()) @@ -1957,14 +1958,14 @@ defn gen-constraints (m:Module, h:HashTable, v:Vector) -> Mod match(width(e)) : (w:UnknownWidth) : val w* = VarWidth(firrtl-gensym(`w,width-name-hash)) - add(v,WGeq(w*,IntWidth(to-int $ to-string $ ceil-log2(value(e))))) + add(v,WGeq(w*,IntWidth(length(to-bin(value(e)))))) UIntValue(value(e),w*) (w) : e (e:SIntValue) : match(width(e)) : (w:UnknownWidth) : val w* = VarWidth(firrtl-gensym(`w,width-name-hash)) - add(v,WGeq(w*,IntWidth(1 + to-int $ to-string $ ceil-log2(abs(value(e)))))) + add(v,WGeq(w*,IntWidth(1 + length(to-bin(value(e)))))) SIntValue(value(e),w*) (w) : e (e) : e -- cgit v1.2.3 From 7646c2e3edf90ea13a83b76c97f35877263c5e63 Mon Sep 17 00:00:00 2001 From: Adam Izraelevitz Date: Wed, 29 Jul 2015 15:00:37 -0700 Subject: Finished supporting Chisel 2.0 Ref Chip --- src/main/stanza/passes.stanza | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/main/stanza/passes.stanza') diff --git a/src/main/stanza/passes.stanza b/src/main/stanza/passes.stanza index 255354a3..db1a056e 100644 --- a/src/main/stanza/passes.stanza +++ b/src/main/stanza/passes.stanza @@ -1151,7 +1151,7 @@ defn expand-connect-indexed-stmt (s: Stmt,sh:HashTable) -> Stmt : to-list $ for (i in 0 to false, l in locs(s)) stream : Conditionally( info(s), - equality(ref,UIntValue(BigIntLit(i),UnknownWidth())), + equality(ref,UIntValue(BigIntLit(i,32),UnknownWidth())), Connect(info(s),l,exp(s)), EmptyStmt() ) @@ -1165,7 +1165,7 @@ defn expand-connect-indexed-stmt (s: Stmt,sh:HashTable) -> Stmt : to-list $ for (i in 1 to false, e in tail(exps(s))) stream : Conditionally( info(s), - equality(ref,UIntValue(BigIntLit(i),UnknownWidth())), + equality(ref,UIntValue(BigIntLit(i,32),UnknownWidth())), Connect(info(s),loc(s),e), EmptyStmt() ) @@ -1211,8 +1211,8 @@ public defmethod short-name (b:ExpandWhens) -> String : "expand-whens" ; ======== Expression Computation Library =========== -val zero = UIntValue(BigIntLit("b0"),IntWidth(1)) -val one = UIntValue(BigIntLit("b1"),IntWidth(1)) +val zero = UIntValue(BigIntLit(0,32),IntWidth(1)) +val one = UIntValue(BigIntLit(1,32),IntWidth(1)) defmethod equal? (e1:Expression,e2:Expression) -> True|False : match(e1,e2) : @@ -1548,7 +1548,7 @@ public defn expand-whens (c:Circuit) -> Circuit : (e:Expression) : val ref = WRef(name(s),type(s),NodeKind(),FEMALE) val en = to-exp(optimize $ get-write-enable(table[name(s)])) as Expression - if en == UIntValue(BigIntLit("b1"),UnknownWidth()) : + if en == one : add{cons,_} $ Connect(info(s),ref,e) else : add{cons,_} $ Conditionally(info(s),en,Connect(info(s),ref,e),EmptyStmt()) @@ -1563,7 +1563,7 @@ public defn expand-whens (c:Circuit) -> Circuit : match(e) : (e:Expression) : val en = (to-exp $ optimize $ get-write-enable(table[n])) as Expression - if en == UIntValue(BigIntLit("b1"),UnknownWidth()) : + if en == one : add{cons,_} $ Connect(info(s),ref,e) else : add{cons,_} $ Conditionally(info(s),en,Connect(info(s),ref,e),EmptyStmt()) -- cgit v1.2.3