diff --git a/frontends/PyCDE/test/test_handshake.py b/frontends/PyCDE/test/test_handshake.py index effe5faf3689..463085a65092 100644 --- a/frontends/PyCDE/test/test_handshake.py +++ b/frontends/PyCDE/test/test_handshake.py @@ -15,6 +15,15 @@ # CHECK: return %0 : i8 # CHECK: } +# CHECK: hw.module @Top(in %clk : i1, in %rst : i1, in %a : i8, in %a_valid : i1, in %x_ready : i1, out a_ready : i1, out x : i8, out x_valid : i1) +# CHECK: %TestFunc.in0_ready, %TestFunc.out0, %TestFunc.out0_valid = hw.instance "TestFunc" @TestFunc(in0: %a: i8, in0_valid: %a_valid: i1, clk: %clk: i1, rst: %rst: i1, out0_ready: %x_ready: i1) -> (in0_ready: i1, out0: i8, out0_valid: i1) +# CHECK: hw.output %TestFunc.in0_ready, %TestFunc.out0, %TestFunc.out0_valid : i1, i8, i1 +# CHECK: hw.module @TestFunc(in %in0 : i8, in %in0_valid : i1, in %clk : i1, in %rst : i1, in %out0_ready : i1, out in0_ready : i1, out out0 : i8, out out0_valid : i1) +# CHECK: %c15_i8 = hw.constant 15 : i8 +# CHECK: [[R0:%.+]] = comb.and %out0_ready, %in0_valid : i1 +# CHECK: [[R1:%.+]] = comb.and bin %in0, %c15_i8 : i8 +# CHECK: hw.output [[R0]], [[R1]], %in0_valid : i1, i8, i1 + class TestFunc(Func): a = Input(Bits(8)) @@ -28,10 +37,7 @@ def build(ports): BarType = types.struct({"foo": types.i12}, "bar") -@unittestmodule(print=True, - run_passes=True, - print_after_passes=True, - debug=True) +@unittestmodule(print=True, run_passes=True, print_after_passes=True) class Top(Module): clk = Clock() rst = Input(Bits(1)) diff --git a/frontends/PyCDE/test/test_polynomial.py b/frontends/PyCDE/test/test_polynomial.py index a8563ca5a4bb..0b2fd9e74090 100755 --- a/frontends/PyCDE/test/test_polynomial.py +++ b/frontends/PyCDE/test/test_polynomial.py @@ -122,7 +122,7 @@ def construct(self): print("Generating rest...") poly.generate() -poly.run_passes() +poly.run_passes(debug=True) print("=== Final IR...") poly.print() diff --git a/lib/Conversion/DCToHW/DCToHW.cpp b/lib/Conversion/DCToHW/DCToHW.cpp index 0db54b34f8a9..1e221cf29505 100644 --- a/lib/Conversion/DCToHW/DCToHW.cpp +++ b/lib/Conversion/DCToHW/DCToHW.cpp @@ -838,10 +838,8 @@ static bool isDCType(Type type) { return isa(type); } /// Returns true if the given `op` is considered as legal - i.e. it does not /// contain any dc-typed values. static bool isLegalOp(Operation *op) { - if (auto funcOp = dyn_cast(op)) { - return llvm::none_of(funcOp.getPortTypes(), isDCType) && - llvm::none_of(funcOp.getBodyBlock()->getArgumentTypes(), isDCType); - } + if (auto funcOp = dyn_cast(op)) + return llvm::none_of(funcOp.getPortTypes(), isDCType); bool operandsOK = llvm::none_of(op->getOperandTypes(), isDCType); bool resultsOK = llvm::none_of(op->getResultTypes(), isDCType); diff --git a/lib/Conversion/HandshakeToDC/HandshakeToDC.cpp b/lib/Conversion/HandshakeToDC/HandshakeToDC.cpp index 5f12fd419bec..a7404d1814cd 100644 --- a/lib/Conversion/HandshakeToDC/HandshakeToDC.cpp +++ b/lib/Conversion/HandshakeToDC/HandshakeToDC.cpp @@ -763,7 +763,7 @@ class HandshakeToDCPass void runOnOperation() override { mlir::ModuleOp mod = getOperation(); auto targetModifier = [](mlir::ConversionTarget &target) { - target.addLegalDialect(); + // target.addLegalDialect(); }; auto patternBuilder = [&](TypeConverter &typeConverter, @@ -807,7 +807,8 @@ LogicalResult circt::handshaketodc::runHandshakeToDC( ConversionTarget target(*ctx); target.addIllegalDialect(); target.addLegalDialect(); - target.addLegalOp(); + target.addLegalOp(); // And any user-specified target adjustments if (configureTarget) diff --git a/test/Conversion/DCToHW/basic.mlir b/test/Conversion/DCToHW/basic.mlir index 52a436dbcb85..002c7e600d8c 100644 --- a/test/Conversion/DCToHW/basic.mlir +++ b/test/Conversion/DCToHW/basic.mlir @@ -196,3 +196,9 @@ hw.module @merge(in %first : !dc.token, in %second : !dc.token, out token : !dc. %selected = dc.merge %first, %second hw.output %selected : !dc.value } + +// CHECK: hw.module.extern @ext(in %a : i32, out b : i32) +hw.module.extern @ext(in %a : i32, out b : i32) + +// CHECK: hw.module.extern @extDC(in %a : !esi.channel, out b : i32) +hw.module.extern @extDC(in %a : !dc.value, out b : i32)