-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Factor out common circuits into tests/common.py. Furthermore, each of these circuits are just simple pass through circuits, so there is a common generator for all of them (with type T as a paramter). Also some other minor changes.
- Loading branch information
Showing
3 changed files
with
23 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
import magma as m | ||
|
||
|
||
class TestNestedArraysCircuit(m.Circuit): | ||
IO = ["I", m.In(m.Array(3, m.Bits(4))), "O", m.Out(m.Array(3, m.Bits(4)))] | ||
def define_simple_circuit(T, circ_name, has_clk=False): | ||
class _Circuit(m.Circuit): | ||
name = circ_name | ||
IO = ["I", m.In(T), "O", m.Out(T)] | ||
if has_clk: | ||
IO += ["CLK", m.In(m.Clock)] | ||
|
||
@classmethod | ||
def definition(io): | ||
m.wire(io.I, io.O) | ||
@classmethod | ||
def definition(io): | ||
m.wire(io.I, io.O) | ||
|
||
return _Circuit | ||
|
||
|
||
TestBasicCircuit = define_simple_circuit(m.Bit, "BasicCircuit") | ||
TestNestedArraysCircuit = define_simple_circuit(m.Array(3, m.Bits(4)), | ||
"NestedArraysCircuit") | ||
TestBasicClkCircuit = define_simple_circuit(m.Bit, "BasicClkCircuit", True) |
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