-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eDSL, docs: new eDSL example showing the usage of guards, and a corre…
…ction in syntax in docs (#2133) * Get the builder to generate ops between ports * Small example showing various forms of guards * Tweak & and | docs for guards
- Loading branch information
1 parent
9f0a0ad
commit e18da1b
Showing
6 changed files
with
112 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"mem": { | ||
"data": [ | ||
0 | ||
], | ||
"format": { | ||
"numeric_type": "bitnum", | ||
"is_signed": false, | ||
"width": 32 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"mem": [ | ||
42 | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# pylint: disable=import-error | ||
import calyx.builder as cb | ||
|
||
|
||
def insert_main_component(prog): | ||
"""Insert the main component into the program. | ||
This component will invoke the `muler`, `abs_diff`, `mux`, and `map` components. | ||
""" | ||
|
||
comp = prog.component("main") | ||
|
||
mem = comp.seq_mem_d1("mem", 32, 1, 32, is_external=True) | ||
|
||
mul = comp.mult_pipe(32) | ||
zero = cb.const(32, 0) | ||
one = cb.const(32, 1) | ||
|
||
with comp.group("well-guarded_group") as wgg: | ||
mul.left = zero @ 4 # This will never be executed | ||
mul.left = (one <= zero) @ 5 # This will never be executed | ||
mul.left = ~zero @ 6 # This will work | ||
mul.right = (zero | one) @ 7 # This will work | ||
mul.right = (zero & one) @ 8 # This will never be executed | ||
mul.go = cb.HI | ||
wgg.done = mul.done | ||
|
||
put_ans_in_mem = comp.mem_store_d1(mem, 0, mul.out, "store") | ||
|
||
comp.control += [wgg, put_ans_in_mem] | ||
|
||
|
||
def build(): | ||
prog = cb.Builder() | ||
insert_main_component(prog) | ||
return prog.program | ||
|
||
|
||
if __name__ == "__main__": | ||
build().emit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters