aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO10
-rw-r--r--notes/notes.02.17.15.txt8
-rw-r--r--notes/stanza-cheatsheet.txt48
-rw-r--r--src/main/stanza/firrtl-main.stanza20
-rw-r--r--src/main/stanza/passes.stanza78
-rw-r--r--test/unit/gcd.fir2
6 files changed, 103 insertions, 63 deletions
diff --git a/TODO b/TODO
new file mode 100644
index 00000000..c323a783
--- /dev/null
+++ b/TODO
@@ -0,0 +1,10 @@
+TODO Read initialization spec
+TODO Read through make-explicit-reset
+TODO If you feel up for it, rewrite make-explicit-reset
+TODO If you feel up for it, read through initialize-registers
+
+TODO
+Make stanza a git repo
+Write installation instructions for stanza
+Need 2 different prints, one with IR-internal information, and another that matches correct FIRRTL
+
diff --git a/notes/notes.02.17.15.txt b/notes/notes.02.17.15.txt
index 133565fd..1a04d607 100644
--- a/notes/notes.02.17.15.txt
+++ b/notes/notes.02.17.15.txt
@@ -1,6 +1,5 @@
February 17, 2015.
-
Functions (defn) have (1) a static type signature and (2) an implementation
You can define them seperately
type signature -> defmulti
@@ -12,19 +11,12 @@ However, you cannot have:
defn a(x:Int) -> Int
because it is unclear which to call (2 matching static type signatures)
-TODO Implement resolve-kinds
TODO Read initialization spec
TODO Read through make-explicit-reset
TODO If you feel up for it, rewrite make-explicit-reset
TODO If you feel up for it, read through initialize-registers
-TODO Look into testing framework
TODO
Make stanza a git repo
-Write Makefile
Write installation instructions for stanza
-Add P-Money as admin to github/firrtl (CuppoJava)
-
-TOTHINK
Need 2 different prints, one with IR-internal information, and another that matches correct FIRRTL
-Add input file argument...
diff --git a/notes/stanza-cheatsheet.txt b/notes/stanza-cheatsheet.txt
new file mode 100644
index 00000000..d8f5c070
--- /dev/null
+++ b/notes/stanza-cheatsheet.txt
@@ -0,0 +1,48 @@
+Functions (defn) have (1) a static type signature and (2) an implementation
+You can define them seperately
+ type signature -> defmulti
+ implementation -> defmethod
+
+Thus, you can have multiple defmethods per defmulti.
+However, you cannot have:
+ defmulti a(x:?) -> ?
+ defn a(x:Int) -> Int
+because it is unclear which to call (2 matching static type signatures)
+
+; [a b c] <- a tuple
+;
+; val rest = List(1,2,3)
+; val b = List(0,rest) --> (0,1,2,3)
+; val c = list(0,rest) --> (0,(1,2,3))
+
+; label<Int> myret :
+; for i in 0 to 10 do :
+; if i == 5:
+; myret(i)
+; 0
+
+; val v = Vector<Int>()
+; add(v,10)
+; add(v,20)
+; add(v,32)
+; for x in v do :
+; println(x)
+
+
+1. explain curly braces in
+ print{o, _} $
+ match(k) :
+ (k:RegKind) : "reg:"
+ My guess is you are passing in a different function depending on the type of k, so you need to lazily evaluate the print, which signifies the {}'s.
+2. explain where in
+ Circuit(modules*, main(c)) where :
+ val modules* =
+ for m in modules(c) map :
+ Module(name(m), ports(m), to-command(body(m)))
+ My guess is you are again evaluating modules* before Circuit, so you are passing in modules lazily?
+3. difference between defn and defmethod?
+
+a typeof T
+a and b
+a or b
+a as T
diff --git a/src/main/stanza/firrtl-main.stanza b/src/main/stanza/firrtl-main.stanza
index e8e01fd5..29edbc14 100644
--- a/src/main/stanza/firrtl-main.stanza
+++ b/src/main/stanza/firrtl-main.stanza
@@ -28,23 +28,3 @@ defn main () :
main()
-; [a b c] <- a tuple
-;
-; val rest = List(1,2,3)
-; val b = List(0,rest) --> (0,1,2,3)
-; val c = list(0,rest) --> (0,(1,2,3))
-
-; label<Int> myret :
-; for i in 0 to 10 do :
-; if i == 5:
-; myret(i)
-; 0
-
-; val v = Vector<Int>()
-; add(v,10)
-; add(v,20)
-; add(v,32)
-; for x in v do :
-; println(x)
-
-
diff --git a/src/main/stanza/passes.stanza b/src/main/stanza/passes.stanza
index 6051ac8d..8c25342d 100644
--- a/src/main/stanza/passes.stanza
+++ b/src/main/stanza/passes.stanza
@@ -116,46 +116,54 @@ defn to-working-ir (c:Circuit) :
; Circuit where all WRef kinds are resolved
defn resolve-kinds (c:Circuit) :
- defn resolve-exp (e:Expression, kinds:HashTable<Symbol,Kind>) :
- match(e) :
- (e:WRef) : WRef(name(e), type(e), kinds[name(e)], dir(e))
- (e) : map(resolve-exp{_, kinds}, e)
-
- defn resolve-comm (c:Stmt, kinds:HashTable<Symbol,Kind>) -> Stmt :
- map{resolve-comm{_, kinds}, _} $
- map(resolve-exp{_, kinds}, c)
+ defn resolve (body:Stmt, kinds:HashTable<Symbol,Kind>) :
+ defn resolve-stmt (s:Stmt) -> Stmt :
+ map{resolve-expr,_} $
+ map(resolve-stmt,s)
- defn find-kinds (c:Stmt, kinds:HashTable<Symbol,Kind>) :
- match(c) :
- (c:LetRec) :
- for entry in entries(c) do :
- kinds[key(entry)] = element-kind(value(entry))
- (c:DefWire) : kinds[name(c)] = NodeKind()
- (c:DefRegister) : kinds[name(c)] = RegKind()
- (c:DefInstance) : kinds[name(c)] = InstanceKind()
- (c:DefMemory) : kinds[name(c)] = MemKind()
- (c:WDefAccessor) : kinds[name(c)] = AccessorKind()
- (c) : false
- do(find-kinds{_, kinds}, children(c))
-
- defn element-kind (e:Element) :
- match(e) :
- (e:Memory) : StructuralMemKind()
- (e) : NodeKind()
+ defn resolve-expr (e:Expression) -> Expression :
+ match(e) :
+ (e:WRef) : WRef(name(e),type(e),kinds[name(e)],dir(e))
+ (e) : map(resolve-expr,e)
+
+ resolve-stmt(body)
+
+ defn find (m:Module, kinds:HashTable<Symbol,Kind>) :
+ defn find-stmt (s:Stmt) -> Stmt :
+ match(s) :
+ (s:LetRec) :
+ for e in entries(s) do :
+ kinds[key(e)] = get-elem-kind(value(e))
+ (s:DefWire) : kinds[name(s)] = NodeKind()
+ (s:DefRegister) : kinds[name(s)] = RegKind()
+ (s:DefInstance) : kinds[name(s)] = InstanceKind()
+ (s:DefMemory) : kinds[name(s)] = MemKind()
+ (s:WDefAccessor) : kinds[name(s)] = AccessorKind()
+ (s) : false
+ map(find-stmt,s)
+
+ defn get-elem-kind (e:Element) :
+ match(e) :
+ (e: Memory) : StructuralMemKind()
+ (e) : NodeKind()
- defn resolve-mod (m:Module, modules:List<Symbol>) :
+ kinds[name(m)] = ModuleKind()
+ for p in ports(m) do :
+ kinds[name(p)] = PortKind()
+ find-stmt(body(m))
+
+ defn resolve-module (m:Module, c:Circuit) -> Module :
val kinds = HashTable<Symbol,Kind>(symbol-hash)
- for module in modules do :
- kinds[module] = ModuleKind()
- for port in ports(m) do :
- kinds[name(port)] = PortKind()
- find-kinds(body(m), kinds)
- Module(name(m), ports(m), body*) where :
- val body* = resolve-comm(body(m), kinds)
+ for m in modules(c) do :
+ kinds[name(m)] = ModuleKind()
+ find(m,kinds)
+ val body! = resolve(body(m),kinds)
+ Module(name(m),ports(m),body!)
Circuit(modules*, main(c)) where :
- val mod-names = map(name, modules(c))
- val modules* = map(resolve-mod{_, mod-names}, modules(c))
+ val modules* =
+ for m in modules(c) map :
+ resolve-module(m,c)
;=============== MAKE RESET EXPLICIT =======================
defn make-explicit-reset (c:Circuit) :
diff --git a/test/unit/gcd.fir b/test/unit/gcd.fir
index 1da09070..e6f28c21 100644
--- a/test/unit/gcd.fir
+++ b/test/unit/gcd.fir
@@ -38,9 +38,11 @@ circuit top :
input b : UInt(16)
output z : UInt
inst i of gcd
+; CHECK: inst i of module:gcd
i.a := a
i.b := b
i.e := UInt(1)
z := i.z
+; CHECK: port:z := inst:i.z