-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into coreir-conn-metadata
- Loading branch information
Showing
18 changed files
with
182 additions
and
78 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
This file was deleted.
Oops, something went wrong.
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
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
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,47 @@ | ||
import magma as m | ||
|
||
|
||
def test_str_repr(): | ||
And2 = m.DeclareCircuit('And2', "I0", m.In(m.Bit), "I1", m.In(m.Bit), | ||
"O", m.Out(m.Bit)) | ||
XOr2 = m.DeclareCircuit('XOr2', "I0", m.In(m.Bit), "I1", m.In(m.Bit), | ||
"O", m.Out(m.Bit)) | ||
Logic2 = m.DefineCircuit('Logic2', 'I0', m.In(m.Bit), 'I1', m.In(m.Bit), 'O', m.Out(m.Bit)) | ||
m.wire(XOr2()(And2()(Logic2.I0, Logic2.I1), 1), Logic2.O) | ||
m.EndCircuit() | ||
|
||
assert str(Logic2) == "Logic2(I0: In(Bit), I1: In(Bit), O: Out(Bit))" | ||
assert repr(Logic2) == """\ | ||
Logic2 = DefineCircuit("Logic2", "I0", In(Bit), "I1", In(Bit), "O", Out(Bit)) | ||
inst0 = XOr2() | ||
inst1 = And2() | ||
wire(inst1.O, inst0.I0) | ||
wire(1, inst0.I1) | ||
wire(Logic2.I0, inst1.I0) | ||
wire(Logic2.I1, inst1.I1) | ||
wire(inst0.O, Logic2.O) | ||
EndCircuit()\ | ||
""" | ||
|
||
expected = [ | ||
"inst0<XOr2(I0: In(Bit), I1: In(Bit), O: Out(Bit))>", | ||
"inst1<And2(I0: In(Bit), I1: In(Bit), O: Out(Bit))>" | ||
] | ||
for inst, expected in zip(Logic2.instances, expected): | ||
assert str(inst) == expected | ||
|
||
|
||
def test_str_repr_anon(): | ||
And2 = m.DeclareCircuit('And2', "I0", m.In(m.Bit), "I1", m.In(m.Bit), | ||
"O", m.Out(m.Bit)) | ||
circ = m.DefineCircuit("Test", "I0", m.In(m.Bits(3)), "I1", m.In(m.Bits(3)), "O", m.Out(m.Bits(3))) | ||
anon = m.join(m.map_(And2, 3)) | ||
m.wire(circ.I0, anon.I0) | ||
m.wire(circ.I1, anon.I1) | ||
m.wire(circ.O, anon.O) | ||
m.EndCircuit() | ||
|
||
string = str(anon) | ||
assert string[:len("AnonymousCircuitInst")] == "AnonymousCircuitInst" | ||
assert string[-len("<I0: Array(3,In(Bit)), I1: Array(3,In(Bit)), O: Array(3,Out(Bit))>"):] == "<I0: Array(3,In(Bit)), I1: Array(3,In(Bit)), O: Array(3,Out(Bit))>" | ||
assert repr(anon) == 'AnonymousCircuitType("I0", array([inst0.I0, inst1.I0, inst2.I0]), "I1", array([inst0.I1, inst1.I1, inst2.I1]), "O", array([inst0.O, inst1.O, inst2.O]))' |
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 |
---|---|---|
@@ -1,25 +1,27 @@ | ||
|
||
|
||
module coreir_const #(parameter value=1, parameter width=1) ( | ||
output [width-1:0] out | ||
); | ||
assign out = value; | ||
|
||
endmodule //coreir_const | ||
endmodule // coreir_const | ||
|
||
module enum_test ( | ||
input [1:0] I, | ||
output [1:0] O_0, | ||
output [1:0] O_1 | ||
); | ||
//Wire declarations for instance 'const_0_2' (Module coreir_const) | ||
|
||
|
||
// Instancing generated Module: coreir.const(width:2) | ||
wire [1:0] const_0_2__out; | ||
coreir_const #(.value(2'b00),.width(2)) const_0_2( | ||
coreir_const #(.value(2'h0),.width(2)) const_0_2( | ||
.out(const_0_2__out) | ||
); | ||
|
||
//All the connections | ||
assign O_1[1:0] = const_0_2__out[1:0]; | ||
|
||
assign O_0[1:0] = I[1:0]; | ||
|
||
endmodule //enum_test | ||
|
||
endmodule // enum_test | ||
|
Oops, something went wrong.