[ESI][PyCDE] Fix tests, integration tests, NFC.

Follow up to 5e74206. Fix more ESI as well as PyCDE tests and
integration tests to use the new HW dialect module/instance format.
This commit is contained in:
Mike Urbach 2021-09-13 17:19:52 -06:00
parent 21f713689b
commit de0bd5a69b
11 changed files with 36 additions and 36 deletions

View File

@ -99,7 +99,7 @@ poly.generate(iters=1)
print("Printing...")
poly.print()
# CHECK-LABEL: hw.module @pycde.PolynomialSystem() -> (%y: i32)
# CHECK-LABEL: hw.module @pycde.PolynomialSystem() -> (y: i32)
# CHECK: [[REG0:%.+]] = "pycde.PolynomialCompute"(%c23_i32) {instanceName = "example", opNames = ["x"], parameters = {coefficients = {coeff = [62, 42, 6]}, module_name = "PolyComputeForCoeff_62_42_6", unused_parameter = true}, resultNames = ["y"]} : (i32) -> i32
# CHECK: [[REG1:%.+]] = "pycde.PolynomialCompute"([[REG0]]) {instanceName = "example2", opNames = ["x"], parameters = {coefficients = {coeff = [62, 42, 6]}, module_name = "PolyComputeForCoeff_62_42_6", unused_parameter = true}, resultNames = ["y"]} : (i32) -> i32
# CHECK: [[REG2:%.+]] = "pycde.PolynomialCompute"([[REG0]]) {instanceName = "example2", opNames = ["x"], parameters = {coefficients = {coeff = [1, 2, 3, 4, 5]}, module_name = "PolyComputeForCoeff_1_2_3_4_5", unused_parameter = true}, resultNames = ["y"]} : (i32) -> i32
@ -112,15 +112,15 @@ poly.generate(iters=1)
print("Printing...")
poly.print()
# CHECK-LABEL: hw.module @pycde.PolynomialSystem
# CHECK: %example.y = hw.instance "example" @PolyComputeForCoeff_62_42_6(%c23_i32) {parameters = {}} : (i32) -> i32
# CHECK: %example2.y = hw.instance "example2" @PolyComputeForCoeff_62_42_6(%example.y) {parameters = {}} : (i32) -> i32
# CHECK: %example2.y_0 = hw.instance "example2" @PolyComputeForCoeff_1_2_3_4_5(%example.y) {parameters = {}} : (i32) -> i32
# CHECK: %pycde.CoolPolynomialCompute.y = hw.instance "pycde.CoolPolynomialCompute" @supercooldevice(%c23_i32{{.*}}) {coefficients = [4, 42], parameters = {}} : (i32) -> i32
# CHECK-LABEL: hw.module @PolyComputeForCoeff_62_42_6(%x: i32) -> (%y: i32)
# CHECK: %example.y = hw.instance "example" @PolyComputeForCoeff_62_42_6(x: %c23_i32: i32) -> (y: i32) {parameters = {}}
# CHECK: %example2.y = hw.instance "example2" @PolyComputeForCoeff_62_42_6(x: %example.y: i32) -> (y: i32) {parameters = {}}
# CHECK: %example2.y_0 = hw.instance "example2" @PolyComputeForCoeff_1_2_3_4_5(x: %example.y: i32) -> (y: i32) {parameters = {}}
# CHECK: %pycde.CoolPolynomialCompute.y = hw.instance "pycde.CoolPolynomialCompute" @supercooldevice(x: %c23_i32{{.*}}: i32) -> (y: i32) {coefficients = [4, 42], parameters = {}}
# CHECK-LABEL: hw.module @PolyComputeForCoeff_62_42_6(%x: i32) -> (y: i32)
# CHECK: hw.constant 62
# CHECK: hw.constant 42
# CHECK: hw.constant 6
# CHECK-LABEL: hw.module @PolyComputeForCoeff_1_2_3_4_5(%x: i32) -> (%y: i32)
# CHECK-LABEL: hw.module @PolyComputeForCoeff_1_2_3_4_5(%x: i32) -> (y: i32)
# CHECK: hw.constant 1
# CHECK: hw.constant 2
# CHECK: hw.constant 3

View File

@ -72,7 +72,7 @@ top.print()
# CHECK: %c7_i12_0 = hw.constant 7 : i12
# CHECK: %2 = hw.struct_create (%c7_i12_0) : !hw.typealias<@pycde::@bar, !hw.struct<foo: i12>>
# CHECK: hw.module @pycde.Taps() -> (%taps: !hw.array<3xi8>)
# CHECK: hw.module @pycde.Taps() -> (taps: !hw.array<3xi8>)
# CHECK: %c-53_i8 = hw.constant -53 : i8
# CHECK: %c100_i8 = hw.constant 100 : i8
# CHECK: %c23_i8 = hw.constant 23 : i8
@ -82,7 +82,7 @@ top.print()
sys = System([ComplexPorts])
sys.generate()
sys.print()
# CHECK: hw.module @pycde.Comple_Ports(%clk: i1, %data_in: !hw.array<3xi32>, %sel: i2, %struct_data_in: !hw.struct<foo: i36>) -> (%a: i32, %b: i32, %c: i32) {
# CHECK: hw.module @pycde.Comple_Ports(%clk: i1, %data_in: !hw.array<3xi32>, %sel: i2, %struct_data_in: !hw.struct<foo: i36>) -> (a: i32, b: i32, c: i32) {
# CHECK: %c0_i2 = hw.constant 0 : i2
# CHECK: [[REG0:%.+]] = hw.array_get %data_in[%c0_i2] {name = "data_in__0"} : !hw.array<3xi32>
# CHECK: [[REGR1:%data_in__0__reg1]] = seq.compreg [[REG0]], %clk : i32

View File

@ -26,7 +26,7 @@ class WireNames:
sys = System([WireNames])
sys.generate()
sys.print()
# CHECK: hw.module @pycde.WireNames(%clk: i1, %data_in: !hw.array<3xi32>, %sel: i2) -> (%a: i32, %b: i32) {
# CHECK: hw.module @pycde.WireNames(%clk: i1, %data_in: !hw.array<3xi32>, %sel: i2) -> (a: i32, b: i32) {
# CHECK: %c0_i2 = hw.constant 0 : i2
# CHECK: %0 = hw.array_get %data_in[%c0_i2] {name = "foo"} : !hw.array<3xi32>
# CHECK: %c1_i32 = hw.constant 1 : i32

View File

@ -46,22 +46,22 @@ prod = esisys.lookup("IntProducer")
assert (prod is not None)
prod.print()
print() # Newline.
# CHECK: hw.module.extern @IntProducer(%clk: i1) -> (%ints: !esi.channel<i32>)
# CHECK: hw.module.extern @IntProducer(%clk: i1) -> (ints: !esi.channel<i32>)
acc = esisys.lookup("IntAccumulator")
assert (acc is not None)
acc.print()
print() # Newline.
# CHECK: hw.module.extern @IntAccumulator(%clk: i1, %ints: i32, %ints_valid: i1) -> (%ints_ready: i1, %sum: i32)
# CHECK: hw.module.extern @IntAccumulator(%clk: i1, %ints: i32, %ints_valid: i1) -> (ints_ready: i1, sum: i32)
esisys.print()
# CHECK-LABEL: hw.module @MyWidget_esi(%foo: !esi.channel<i32>) {
# CHECK-NEXT: %rawOutput, %valid = esi.unwrap.vr %foo, %pearl.foo_ready : i32
# CHECK-NEXT: %pearl.foo_ready = hw.instance "pearl" @MyWidget(%rawOutput, %valid) : (i32, i1) -> i1
# CHECK-NEXT: %pearl.foo_ready = hw.instance "pearl" @MyWidget(foo: %rawOutput: i32, foo_valid: %valid: i1) -> (foo_ready: i1)
# CHECK-NEXT: hw.output
# CHECK-LABEL: hw.module @MyWidget(%foo: i32, %foo_valid: i1) -> (%foo_ready: i1) {
# CHECK-LABEL: hw.module @MyWidget(%foo: i32, %foo_valid: i1) -> (foo_ready: i1) {
# CHECK-NEXT: hw.output %foo_valid : i1
# CHECK-LABEL: hw.module @I32Snoop(%foo_in: !esi.channel<i32>) -> (%foo_out: !esi.channel<i32>) {
# CHECK-LABEL: hw.module @I32Snoop(%foo_in: !esi.channel<i32>) -> (foo_out: !esi.channel<i32>) {
# CHECK-NEXT: hw.output %foo_in : !esi.channel<i32>
print("\n\n=== Verilog ===")

View File

@ -1 +1 @@
hw.module.extern @IntProducer(%clk: i1) -> (%ints: !esi.channel<i32>)
hw.module.extern @IntProducer(%clk: i1) -> (ints: !esi.channel<i32>)

View File

@ -1 +1 @@
hw.module.extern @IntAccumulator(%clk: i1, %ints: i32, %ints_valid: i1) -> (%ints_ready: i1, %sum: i32)
hw.module.extern @IntAccumulator(%clk: i1, %ints: i32, %ints_valid: i1) -> (ints_ready: i1, sum: i32)

View File

@ -73,7 +73,7 @@ with ir.Context() as ctx, ir.Location.unknown():
num_failed = db.add_design_placements()
assert num_failed == 1
# ERR: error: 'hw.instance' op Could not apply placement #msft.physloc<M20K, 2, 6, 1>. Position already occupied by hw.instance "ext1" @MyExternMod() {"loc:subpath" = #msft.switch.inst<@top["inst1","ext1"]=#msft.physloc<M20K, 2, 6, 1>>, parameters = {}}
# ERR: error: 'hw.instance' op Could not apply placement #msft.physloc<M20K, 2, 6, 1>. Position already occupied by hw.instance "ext1" @MyExternMod() -> () {"loc:subpath" = #msft.switch.inst<@top["inst1","ext1"]=#msft.physloc<M20K, 2, 6, 1>>, parameters = {}}
# CHECK-LABEL: === tcl ===
print("=== tcl ===")

View File

@ -31,7 +31,7 @@ with Context() as ctx, Location.unknown():
m = Module.create()
with InsertionPoint(m.body):
# CHECK: hw.module @MyWidget(%my_input: i32) -> (%my_output: i32)
# CHECK: hw.module @MyWidget(%my_input: i32) -> (my_output: i32)
# CHECK: hw.output %my_input : i32
op = hw.HWModuleOp(
name='MyWidget',
@ -39,20 +39,20 @@ with Context() as ctx, Location.unknown():
output_ports=[('my_output', i32)],
body_builder=lambda module: hw.OutputOp([module.my_input]))
# CHECK: hw.module.extern @FancyThing(%input0: i32) -> (%output0: i32)
# CHECK: hw.module.extern @FancyThing(%input0: i32) -> (output0: i32)
extern = hw.HWModuleExternOp(name="FancyThing",
input_ports=[("input0", i32)],
output_ports=[("output0", i32)])
# CHECK: hw.module @swap(%a: i32, %b: i32) -> (%{{.+}}: i32, %{{.+}}: i32)
# CHECK: hw.module @swap(%a: i32, %b: i32) -> ({{.+}}: i32, {{.+}}: i32)
# CHECK: hw.output %b, %a : i32, i32
@hw.HWModuleOp.from_py_func(i32, i32)
def swap(a, b):
return b, a
# CHECK: hw.module @top(%a: i32, %b: i32) -> (%{{.+}}: i32, %{{.+}}: i32)
# CHECK: %[[a0:.+]], %[[b0:.+]] = hw.instance "" @swap(%a, %b)
# CHECK: %[[a1:.+]], %[[b1:.+]] = hw.instance "" @swap(%[[a0]], %[[b0]])
# CHECK: hw.module @top(%a: i32, %b: i32) -> ({{.+}}: i32, {{.+}}: i32)
# CHECK: %[[a0:.+]], %[[b0:.+]] = hw.instance "" @swap(a: %a: i32, b: %b: i32)
# CHECK: %[[a1:.+]], %[[b1:.+]] = hw.instance "" @swap(a: %[[a0]]: i32, b: %[[b0]]: i32)
# CHECK: hw.output %[[a1:.+]], %[[b1:.+]] : i32, i32
@hw.HWModuleOp.from_py_func(i32, i32)
def top(a, b):
@ -95,14 +95,14 @@ with Context() as ctx, Location.unknown():
# CHECK: %[[INST1_RESULT:.+]] = hw.instance "inst1" @one_output()
inst1 = one_output.create("inst1")
# CHECK: hw.instance "inst2" @one_input(%[[INST1_RESULT]])
# CHECK: hw.instance "inst2" @one_input(a: %[[INST1_RESULT]]: i32)
inst2 = one_input.create("inst2", a=inst1.a)
# CHECK: hw.instance "inst4" @two_inputs(%[[INST1_RESULT]], %[[INST1_RESULT]])
# CHECK: hw.instance "inst4" @two_inputs(a: %[[INST1_RESULT]]: i32, b: %[[INST1_RESULT]]: i32)
inst4 = two_inputs.create("inst4", a=inst1.a)
connect(inst4.b, inst1.a)
# CHECK: %[[INST5_RESULT:.+]] = hw.instance "inst5" @MyWidget(%[[INST5_RESULT]])
# CHECK: %[[INST5_RESULT:.+]] = hw.instance "inst5" @MyWidget(my_input: %[[INST5_RESULT]]: i32)
inst5 = op.create("inst5")
connect(inst5.my_input, inst5.my_output)

View File

@ -15,7 +15,7 @@ def build(mod, dummy_mod):
connect(inst.x, inst.y)
connect(inst.x, const)
connect(inst.x, const.result)
# CHECK: hw.instance "d" @Dummy(%[[C0]])
# CHECK: hw.instance "d" @Dummy(x: %[[C0]]: i32)
with mlir.ir.Context() as ctx, mlir.ir.Location.unknown():

View File

@ -8,22 +8,22 @@ hw.module.extern @Sender() -> (x: !esi.channel<si14>)
hw.module.extern @Reciever(%a: !esi.channel<i32>)
hw.module.extern @ArrReciever(%x: !esi.channel<!hw.array<4xsi64>>)
// CHECK-LABEL: hw.module.extern @Sender() -> (%x: !esi.channel<si14>)
// CHECK-LABEL: hw.module.extern @Sender() -> (x: !esi.channel<si14>)
// CHECK-LABEL: hw.module.extern @Reciever(%a: !esi.channel<i32>)
// CHECK-LABEL: hw.module.extern @ArrReciever(%x: !esi.channel<!hw.array<4xsi64>>)
hw.module @top(%clk:i1, %rstn:i1) -> () {
hw.instance "recv" @Reciever (a: %cosimRecv: !esi.channel<i32>) -> ()
// CHECK: hw.instance "recv" @Reciever(%0) : (!esi.channel<i32>) -> ()
// CHECK: hw.instance "recv" @Reciever(a: %0: !esi.channel<i32>) -> ()
%send.x = hw.instance "send" @Sender () -> (x: !esi.channel<si14>)
// CHECK: %send.x = hw.instance "send" @Sender() : () -> !esi.channel<si14>
// CHECK: %send.x = hw.instance "send" @Sender() -> (x: !esi.channel<si14>)
%cosimRecv = esi.cosim %clk, %rstn, %send.x, 1 {name="TestEP"} : !esi.channel<si14> -> !esi.channel<i32>
// CHECK: esi.cosim %clk, %rstn, %send.x, 1 {name = "TestEP"} : !esi.channel<si14> -> !esi.channel<i32>
%send2.x = hw.instance "send2" @Sender () -> (x: !esi.channel<si14>)
// CHECK: %send2.x = hw.instance "send2" @Sender() : () -> !esi.channel<si14>
// CHECK: %send2.x = hw.instance "send2" @Sender() -> (x: !esi.channel<si14>)
%cosimArrRecv = esi.cosim %clk, %rstn, %send2.x, 2 {name="ArrTestEP"} : !esi.channel<si14> -> !esi.channel<!hw.array<4xsi64>>
// CHECK: esi.cosim %clk, %rstn, %send2.x, 2 {name = "ArrTestEP"} : !esi.channel<si14> -> !esi.channel<!hw.array<4xsi64>>
@ -41,7 +41,7 @@ hw.module @top(%clk:i1, %rstn:i1) -> () {
// CAPNP: list @0 () -> (ifaces :List(EsiDpiInterfaceDesc));
// CAPNP: open @1 [S, T] (iface :EsiDpiInterfaceDesc) -> (iface :EsiDpiEndpoint(S, T));
// COSIM: hw.instance "TestEP" @Cosim_Endpoint(%clk, %rstn, %{{.+}}, %{{.+}}, %{{.+}}) {parameters = {ENDPOINT_ID = 1 : i32, RECV_TYPE_ID = 10578209918096690139 : ui64, RECV_TYPE_SIZE_BITS = 128 : i32, SEND_TYPE_ID = 11229133067582987457 : ui64, SEND_TYPE_SIZE_BITS = 128 : i32}} : (i1, i1, i1, i1, !hw.array<128xi1>) -> (i1, !hw.array<128xi1>, i1)
// COSIM: hw.instance "TestEP" @Cosim_Endpoint(clk: %clk: i1, rstn: %rstn: i1, {{.+}}, {{.+}}, {{.+}}) -> (DataOutValid: i1, DataOut: !hw.array<128xi1>, DataInReady: i1) {parameters = {ENDPOINT_ID = 1 : i32, RECV_TYPE_ID = 10578209918096690139 : ui64, RECV_TYPE_SIZE_BITS = 128 : i32, SEND_TYPE_ID = 11229133067582987457 : ui64, SEND_TYPE_SIZE_BITS = 128 : i32}}
// SV: assign _T.valid = TestEP_DataOutValid;
// SV: assign _T.data = dataSection[6'h0+:32];

View File

@ -17,6 +17,6 @@ hw.module @top(%clk:i1, %rstn:i1) -> () {
// CAPNP-NEXT: compressionLevel @1 :UInt8;
// CAPNP-NEXT: blob @2 :List(UInt8);
// COSIM: hw.instance "encodeStruct{{.+}}Inst" @encodeStruct{{.+}}(%clk, %6, %7) : (i1, i1, !hw.struct<encrypted: i1, compressionLevel: ui4, blob: !hw.array<32xi8>>) -> !hw.array<448xi1>
// COSIM: hw.instance "Compressor" @Cosim_Endpoint(%clk, %rstn, %{{.+}}, %{{.+}}, %{{.+}}) {parameters = {ENDPOINT_ID = 1 : i32, RECV_TYPE_ID = {{[0-9]+}} : ui64, RECV_TYPE_SIZE_BITS = 128 : i32, SEND_TYPE_ID = {{[0-9]+}} : ui64, SEND_TYPE_SIZE_BITS = 448 : i32}}
// COSIM: hw.module @encode{{.+}}(%clk: i1, %valid: i1, %unencodedInput: !hw.struct<encrypted: i1, compressionLevel: ui4, blob: !hw.array<32xi8>>) -> (%encoded: !hw.array<448xi1>)
// COSIM: hw.instance "encodeStruct{{.+}}Inst" @encodeStruct{{.+}}(clk: %clk: i1, valid: %6: i1, unencodedInput: %7: !hw.struct<encrypted: i1, compressionLevel: ui4, blob: !hw.array<32xi8>>) -> (encoded: !hw.array<448xi1>)
// COSIM: hw.instance "Compressor" @Cosim_Endpoint(clk: %clk: i1, rstn: %rstn: i1, {{.+}}, {{.+}}, {{.+}}) -> ({{.+}}) {parameters = {ENDPOINT_ID = 1 : i32, RECV_TYPE_ID = {{[0-9]+}} : ui64, RECV_TYPE_SIZE_BITS = 128 : i32, SEND_TYPE_ID = {{[0-9]+}} : ui64, SEND_TYPE_SIZE_BITS = 448 : i32}}
// COSIM: hw.module @encode{{.+}}(%clk: i1, %valid: i1, %unencodedInput: !hw.struct<encrypted: i1, compressionLevel: ui4, blob: !hw.array<32xi8>>) -> (encoded: !hw.array<448xi1>)