|
| 1 | +// RUN: circt-opt --pass-pipeline='builtin.module(firrtl.circuit(firrtl-annotate-input-only-modules))' %s | FileCheck %s |
| 2 | + |
| 3 | +// Test that modules with non-hardware output ports (Probe, Integer) ARE annotated |
| 4 | +firrtl.circuit "ModuleWithNonHardwareOutput" { |
| 5 | + // CHECK-LABEL: firrtl.module @ModuleWithNonHardwareOutput |
| 6 | + firrtl.module @ModuleWithNonHardwareOutput(in %a: !firrtl.uint<8>, out %p: !firrtl.probe<uint<8>>, out %i: !firrtl.integer) { |
| 7 | + %child_x, %child_probe, %child_int = firrtl.instance child @ChildWithNonHardwareOutput(in x: !firrtl.uint<8>, out probe: !firrtl.probe<uint<8>>, out int: !firrtl.integer) |
| 8 | + firrtl.matchingconnect %child_x, %a : !firrtl.uint<8> |
| 9 | + firrtl.ref.define %p, %child_probe : !firrtl.probe<uint<8>> |
| 10 | + firrtl.propassign %i, %child_int : !firrtl.integer |
| 11 | + } |
| 12 | + |
| 13 | + // CHECK-LABEL: firrtl.module private @ChildWithNonHardwareOutput |
| 14 | + // CHECK-SAME: attributes {annotations = [{class = "firrtl.passes.InlineAnnotation"}]} |
| 15 | + firrtl.module private @ChildWithNonHardwareOutput(in %x: !firrtl.uint<8>, out %probe: !firrtl.probe<uint<8>>, out %int: !firrtl.integer) { |
| 16 | + %0 = firrtl.ref.send %x : !firrtl.uint<8> |
| 17 | + firrtl.ref.define %probe, %0 : !firrtl.probe<uint<8>> |
| 18 | + %c42_i = firrtl.integer 42 |
| 19 | + firrtl.propassign %int, %c42_i : !firrtl.integer |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +// Test that modules with existing annotations are preserved |
| 24 | +firrtl.circuit "ExistingAnnotations" { |
| 25 | + // CHECK-LABEL: firrtl.module @ExistingAnnotations |
| 26 | + firrtl.module @ExistingAnnotations(in %a: !firrtl.uint<8>) { |
| 27 | + %child_x = firrtl.instance child @ChildWithAnnotation(in x: !firrtl.uint<8>) |
| 28 | + firrtl.matchingconnect %child_x, %a : !firrtl.uint<8> |
| 29 | + } |
| 30 | + |
| 31 | + // CHECK-LABEL: firrtl.module private @ChildWithAnnotation |
| 32 | + // CHECK-SAME: annotations = [{class = "some.other.Annotation"}, {class = "firrtl.passes.InlineAnnotation"}] |
| 33 | + firrtl.module private @ChildWithAnnotation(in %x: !firrtl.uint<8>) attributes {annotations = [{class = "some.other.Annotation"}]} { |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +// Test public modules are NOT annotated (even if input-only) |
| 38 | +firrtl.circuit "PublicInputOnly" { |
| 39 | + // CHECK-LABEL: firrtl.module @PublicInputOnly |
| 40 | + // CHECK-NOT: InlineAnnotation |
| 41 | + firrtl.module @PublicInputOnly(in %a: !firrtl.uint<8>) { |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +firrtl.circuit "ModuleWithDontTouch" { |
| 46 | + // CHECK-LABEL: firrtl.module @ModuleWithDontTouch |
| 47 | + firrtl.module @ModuleWithDontTouch(in %a: !firrtl.uint<8>) { |
| 48 | + %child_x = firrtl.instance child @ChildWithNonHardwareOutput(in x: !firrtl.uint<8>) |
| 49 | + firrtl.matchingconnect %child_x, %a : !firrtl.uint<8> |
| 50 | + } |
| 51 | + |
| 52 | + // CHECK-LABEL: firrtl.module private @ChildWithNonHardwareOutput |
| 53 | + // CHECK-NOT: InlineAnnotation |
| 54 | + firrtl.module private @ChildWithNonHardwareOutput(in %x: !firrtl.uint<8>) attributes {annotations = [{class = "firrtl.transforms.DontTouchAnnotation"}]} {} |
| 55 | +} |
| 56 | + |
| 57 | +firrtl.circuit "Bound" { |
| 58 | + // CHECK-LABEL: firrtl.module @Bound |
| 59 | + firrtl.module @Bound(in %a: !firrtl.uint<8>) { |
| 60 | + %child_x = firrtl.instance child {doNotPrint} @ChildWithNonHardwareOutput(in x: !firrtl.uint<8>) |
| 61 | + firrtl.matchingconnect %child_x, %a : !firrtl.uint<8> |
| 62 | + } |
| 63 | + |
| 64 | + // CHECK-LABEL: firrtl.module private @ChildWithNonHardwareOutput |
| 65 | + // CHECK-NOT: InlineAnnotation |
| 66 | + firrtl.module private @ChildWithNonHardwareOutput(in %x: !firrtl.uint<8>) attributes {annotations = [{class = "firrtl.transforms.DontTouchAnnotation"}]} {} |
| 67 | +} |
0 commit comments