From 5a1d0eea905adb40c42c3638ac0435c59700f313 Mon Sep 17 00:00:00 2001 From: Morten Borup Petersen Date: Fri, 22 Sep 2023 12:00:28 +0000 Subject: [PATCH] [Ibis] Add container instantiation test --- .../Ibis/Transforms/containers_to_hw.mlir | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/Dialect/Ibis/Transforms/containers_to_hw.mlir b/test/Dialect/Ibis/Transforms/containers_to_hw.mlir index 2e43ee7ce973..94315850fdf2 100644 --- a/test/Dialect/Ibis/Transforms/containers_to_hw.mlir +++ b/test/Dialect/Ibis/Transforms/containers_to_hw.mlir @@ -43,3 +43,29 @@ ibis.container @Parent { %b.out.ref = ibis.get_port %b, @out : !ibis.scoperef<@B> -> !ibis.portref %b.in.ref = ibis.get_port %b, @in : !ibis.scoperef<@B> -> !ibis.portref } + +// Test that we can instantiate and get ports of a container from a hw.module. + +// CHECK: hw.module @C(%in: i1) -> (out: i1) { +// CHECK: hw.output %in : i1 +// CHECK: } +// CHECK: hw.module @Top() { +// CHECK: %c.out = hw.instance "c" @C(in: %c.out: i1) -> (out: i1) +// CHECK: hw.output +// CHECK: } + +ibis.container @C { + %this = ibis.this @C + %in = ibis.port.input @in : i1 + %out = ibis.port.output @out : i1 + %v = ibis.port.read %in : !ibis.portref + ibis.port.write %out, %v : !ibis.portref +} + +hw.module @Top() -> () { + %c = ibis.container.instance @c, @C + %in = ibis.get_port %c, @in : !ibis.scoperef<@C> -> !ibis.portref + %out = ibis.get_port %c, @out : !ibis.scoperef<@C> -> !ibis.portref + %v = ibis.port.read %out : !ibis.portref + ibis.port.write %in, %v : !ibis.portref +}