-
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.
[Calyx-FIRRTL backend] Guards and non-primitive Cells (#1817)
* Initial commit: added barebones firrtl.rs as a backend option. * Fix formatting errors and try to leverage VerilogBackend * Fix formatting * first pass on inputs and outputs * fix CI formatting issue * more CI formatting fixes * temporary commit before fixing up starter code * Clean up starter firrtl translation code * Fix CI errors * Barebones test containing input/output ports and single assignment * Fix test failure caused by whitespace * clean up unnecessary comments * Port guard support and some refactoring for converting ports to FIRRTL * First steps for recursive guard building + more refactoring * Guard support and tests * Updating firrtl.rs to support guards * Fix formatting issues * additional formatting fix * Added default assignment to 0 for guard failure and fixed expected output * Added default initialization statements for assignments with guards * adding test to make sure that there's only one invalid initialization per unique dest * fixing attributes and "is invalid" initialization * First steps to support non-primitive cells * Fixing hardcoding of main as the top level component * Fix formatting errors * More formatting fixes * Remove unnecessary FIXME * Fix indentation and add comment from PR feedback * Fix small format bug
- Loading branch information
1 parent
4101392
commit 73dec70
Showing
12 changed files
with
282 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
circuit main: | ||
module main: | ||
input in: UInt<32> | ||
input cond: UInt<1> | ||
input cond2: UInt<1> | ||
input cond3: UInt<1> | ||
output out: UInt<32> | ||
input go: UInt<1> | ||
input clk: Clock | ||
input reset: UInt<1> | ||
output done: UInt<1> | ||
; COMPONENT START: main | ||
done <= UInt(1) | ||
out is invalid ; default initialization | ||
when and(or(not(cond), cond2), cond3): | ||
out <= in | ||
; COMPONENT END: main | ||
|
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,9 @@ | ||
// -b firrtl | ||
component main(in : 32, cond: 1, cond2 : 1, cond3 : 1) -> (out : 32) { | ||
cells {} | ||
wires { | ||
out = (!cond | cond2) & cond3 ? in; | ||
done = 1'd1; | ||
} | ||
control {} | ||
} |
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,16 @@ | ||
circuit main: | ||
module main: | ||
input in: UInt<32> | ||
input cond: UInt<1> | ||
output out: UInt<32> | ||
input go: UInt<1> | ||
input clk: Clock | ||
input reset: UInt<1> | ||
output done: UInt<1> | ||
; COMPONENT START: main | ||
done <= UInt(1) | ||
out is invalid ; default initialization | ||
when cond: | ||
out <= in | ||
; COMPONENT END: main | ||
|
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,9 @@ | ||
// -b firrtl | ||
component main(in : 32, cond: 1) -> (out : 32) { | ||
cells {} | ||
wires { | ||
out = cond ? in; | ||
done = 1'd1; | ||
} | ||
control {} | ||
} |
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 |
---|---|---|
|
@@ -10,3 +10,4 @@ circuit main: | |
done <= UInt(1) | ||
out <= in | ||
; COMPONENT END: main | ||
|
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,18 @@ | ||
circuit main: | ||
module main: | ||
input in: UInt<32> | ||
input var: UInt<32> | ||
input var2: UInt<32> | ||
input cond3: UInt<1> | ||
output out: UInt<32> | ||
input go: UInt<1> | ||
input clk: Clock | ||
input reset: UInt<1> | ||
output done: UInt<1> | ||
; COMPONENT START: main | ||
done <= UInt(1) | ||
out is invalid ; default initialization | ||
when and(leq(var, var2), cond3): | ||
out <= in | ||
; COMPONENT END: main | ||
|
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,9 @@ | ||
// -b firrtl | ||
component main(in : 32, var: 32, var2 : 32, cond3 : 1) -> (out : 32) { | ||
cells {} | ||
wires { | ||
out = (var <= var2) & cond3 ? in; | ||
done = 1'd1; | ||
} | ||
control {} | ||
} |
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,17 @@ | ||
circuit main: | ||
module main: | ||
input in: UInt<32> | ||
input cond: UInt<1> | ||
input cond2: UInt<1> | ||
output out: UInt<32> | ||
input go: UInt<1> | ||
input clk: Clock | ||
input reset: UInt<1> | ||
output done: UInt<1> | ||
; COMPONENT START: main | ||
done <= UInt(1) | ||
out is invalid ; default initialization | ||
when or(cond, cond2): | ||
out <= in | ||
; COMPONENT END: main | ||
|
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,9 @@ | ||
// -b firrtl | ||
component main(in : 32, cond: 1, cond2 : 1) -> (out : 32) { | ||
cells {} | ||
wires { | ||
out = cond | cond2 ? in; | ||
done = 1'd1; | ||
} | ||
control {} | ||
} |
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,21 @@ | ||
circuit main: | ||
module main: | ||
input in: UInt<32> | ||
input in2: UInt<32> | ||
input cond: UInt<1> | ||
input cond2: UInt<1> | ||
input cond3: UInt<1> | ||
output out: UInt<32> | ||
input go: UInt<1> | ||
input clk: Clock | ||
input reset: UInt<1> | ||
output done: UInt<1> | ||
; COMPONENT START: main | ||
done <= UInt(1) | ||
out is invalid ; default initialization | ||
when or(cond, cond2): | ||
out <= in | ||
when or(cond2, cond3): | ||
out <= in2 | ||
; COMPONENT END: main | ||
|
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,10 @@ | ||
// -b firrtl | ||
component main(in : 32, in2 : 32, cond: 1, cond2 : 1, cond3 : 1) -> (out : 32) { | ||
cells {} | ||
wires { | ||
out = cond | cond2 ? in; | ||
out = cond2 | cond3 ? in2; | ||
done = 1'd1; | ||
} | ||
control {} | ||
} |