diff --git a/include/circt/Dialect/FIRRTL/FIRRTLIntrinsics.td b/include/circt/Dialect/FIRRTL/FIRRTLIntrinsics.td index 99aa2770d51c..84196b3d6438 100644 --- a/include/circt/Dialect/FIRRTL/FIRRTLIntrinsics.td +++ b/include/circt/Dialect/FIRRTL/FIRRTLIntrinsics.td @@ -231,4 +231,16 @@ def DPICallIntrinsicOp : FIRRTLOp<"int.dpi.call", let hasVerifier = 1; } +def ViewIntrinsicOp : FIRRTLOp<"view", []> { + let summary = "A SystemVerilog Interface only usable for waveform debugging"; + let description = [{ + This will become a SystemVerilog Interface that is driven by its arguments. + This is _not_ intended to be used for anything other than assistance when + debugging in a waveform. This is _not_ a true SystemVerilog Interface, it + is only lowered to one. + }]; + let arguments = (ins StrAttr:$name, AugmentedBundleType:$augmentedType, Variadic:$inputs); + let assemblyFormat = "$name `,` $augmentedType (`,` $inputs^)? attr-dict (`:` type($inputs)^)?"; +} + #endif // CIRCT_DIALECT_FIRRTL_FIRRTLINTRINSICS_TD diff --git a/include/circt/Dialect/FIRRTL/FIRRTLTypes.td b/include/circt/Dialect/FIRRTL/FIRRTLTypes.td index 3051928e458c..33e205a71ea8 100644 --- a/include/circt/Dialect/FIRRTL/FIRRTLTypes.td +++ b/include/circt/Dialect/FIRRTL/FIRRTLTypes.td @@ -81,6 +81,10 @@ def AggregateType : FIRRTLDialectType< CPred<"type_isa($_self)">, "a aggregate type", "::circt::firrtl::FIRRTLBaseType">; +def GroundType : FIRRTLDialectType< + CPred<"llvm::isa($_self) && cast($_self).isGround()">, + "a ground type", "::circt::firrtl::FIRRTLBaseType">; + def PassiveType : FIRRTLDialectType< CPred<"type_isa($_self) && cast($_self).isPassive()">, "a passive base type (contain no flips)", "::circt::firrtl::FIRRTLBaseType">; diff --git a/include/circt/Dialect/FIRRTL/FIRRTLVisitors.h b/include/circt/Dialect/FIRRTL/FIRRTLVisitors.h index 5f9aa0ddac9e..257f32da9e56 100644 --- a/include/circt/Dialect/FIRRTL/FIRRTLVisitors.h +++ b/include/circt/Dialect/FIRRTL/FIRRTLVisitors.h @@ -236,13 +236,13 @@ class StmtVisitor { ResultType dispatchStmtVisitor(Operation *op, ExtraArgs... args) { auto *thisCast = static_cast(this); return TypeSwitch(op) - .template Case( + .template Case< + AttachOp, ConnectOp, MatchingConnectOp, RefDefineOp, ForceOp, + PrintFOp, SkipOp, StopOp, WhenOp, AssertOp, AssumeOp, CoverOp, + PropAssignOp, RefForceOp, RefForceInitialOp, RefReleaseOp, + RefReleaseInitialOp, FPGAProbeIntrinsicOp, VerifAssertIntrinsicOp, + VerifAssumeIntrinsicOp, UnclockedAssumeIntrinsicOp, + VerifCoverIntrinsicOp, LayerBlockOp, MatchOp, ViewIntrinsicOp>( [&](auto opNode) -> ResultType { return thisCast->visitStmt(opNode, args...); }) @@ -292,6 +292,7 @@ class StmtVisitor { HANDLE(UnclockedAssumeIntrinsicOp); HANDLE(LayerBlockOp); HANDLE(MatchOp); + HANDLE(ViewIntrinsicOp); #undef HANDLE }; diff --git a/test/Dialect/FIRRTL/round-trip.mlir b/test/Dialect/FIRRTL/round-trip.mlir index cfda6999fcd5..b20e1c1364c5 100644 --- a/test/Dialect/FIRRTL/round-trip.mlir +++ b/test/Dialect/FIRRTL/round-trip.mlir @@ -40,6 +40,35 @@ firrtl.module @Intrinsics(in %ui : !firrtl.uint, in %clock: !firrtl.clock, in %u %p = firrtl.int.generic "params" : () -> !firrtl.bundle> %po = firrtl.int.generic "params_and_operand" %ui1 : (!firrtl.uint<1>) -> !firrtl.clock firrtl.int.generic "inputs" %clock, %ui1, %clock : (!firrtl.clock, !firrtl.uint<1>, !firrtl.clock) -> () + + %val = firrtl.wire : !firrtl.uint<1> + // CHECK: firrtl.view "View" + // CHECK-SAME: <{ + // CHECK-SAME: elements = [ + // CHECK-SAME: { + // CHECK-SAME: class = "sifive.enterprise.grandcentral.AugmentedGroundType", + // CHECK-SAME: name = "baz" + // CHECK-SAME: }, + // CHECK-SAME: { + // CHECK-SAME: class = "sifive.enterprise.grandcentral.AugmentedGroundType", + // CHECK-SAME: name = "qux" + // CHECK-SAME: } + // CHECK-SAME: ] + // CHECK-SAME: }>, %val, %val : !firrtl.uint<1>, !firrtl.uint<1> + firrtl.view "View", <{ + class = "sifive.enterprise.grandcentral.AugmentedBundleType", + defName = "Bar", + elements = [ + { + class = "sifive.enterprise.grandcentral.AugmentedGroundType", + name = "baz" + }, + { + class = "sifive.enterprise.grandcentral.AugmentedGroundType", + name = "qux" + } + ] + }>, %val, %val : !firrtl.uint<1>, !firrtl.uint<1> } // CHECK-LABEL: firrtl.module @FPGAProbe