Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d6bf6ea
[FIRRTL] Add alternative constraint-based InferWidths pass
wky17 Nov 3, 2025
f797ea6
[format] Fix clang-format issues
wky17 Nov 4, 2025
1f3f1f0
remove dependency on boost, using llvm/graphtraits
wky17 Nov 11, 2025
1991339
add a cmdline control over new-inferwidths in firtool
wky17 Nov 11, 2025
564d949
remove unordered_map, use DenseMap instead
wky17 Nov 11, 2025
a7e2e1b
collect new tests in issue9140
wky17 Nov 11, 2025
023f574
remove /test_new_inferwidths folder, add a new file named infer-width…
wky17 Nov 11, 2025
011aab2
add Constraint2 for conditions, w_c <= 1
wky17 Nov 20, 2025
994e0b6
follow clang-format
wky17 Nov 24, 2025
3e38c6e
[InferWidths] Add missing <stack> include for std::stack
wky17 Dec 11, 2025
dad21bc
solve unexpected error: 'firrtl.circuit' op does not contain module w…
wky17 Dec 12, 2025
2c1ce1c
fixed clang-format
wky17 Dec 12, 2025
871de46
put entire debug info for loops under LLVM_DEBUG & including header a…
wky17 Dec 15, 2025
d70580b
working on add some comments for Constraint1/2/Min. TBD
wky17 Dec 15, 2025
f06423f
test new inferwidths pass
wky17 Dec 15, 2025
b139a3f
compilation error due to losing ';'s
wky17 Dec 16, 2025
916be11
compilation error due to losing a 'l'
wky17 Dec 16, 2025
9b17309
compilation error due to losing 'l's
wky17 Dec 16, 2025
db8244b
using bump allocator instead of unsecure deque
wky17 Dec 19, 2025
ea14574
fix clang-format
wky17 Dec 19, 2025
c2ca057
add some comments for the code
wky17 Dec 19, 2025
5ab37d7
clang-format for comments
wky17 Dec 21, 2025
e197140
error: unexpected error: 'firrtl.domain.define' op not supported in w…
wky17 Dec 22, 2025
a57ef92
[FIRRTL] Ignore domain.define in InferWidths
seldridge Dec 19, 2025
8575a2e
[FIRRTL] Alpha-sort InferWidths no-ops, NFC
seldridge Dec 19, 2025
705c142
[FIRRTL] Whitespace cleanup, NFC
seldridge Dec 19, 2025
2fa5598
[ImportVerilog] Add missing `automatic` keyword to test
fabianschuiki Dec 20, 2025
9fbab9e
[ImportVerilog] Add support for program definitions (#9377)
fabianschuiki Dec 21, 2025
19e552b
[MooreToCore] Lower $time to new LLHD current time op (#9378)
fabianschuiki Dec 22, 2025
6e4db92
add support for DomainDefineOp
wky17 Dec 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions include/circt/Dialect/FIRRTL/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,14 @@ def InferWidths : Pass<"firrtl-infer-widths", "firrtl::CircuitOp"> {
}];
}

def InferWidths_new : Pass<"firrtl-infer-widths-new", "firrtl::CircuitOp"> {
let summary = "Infer the width of types(new)";
let description = [{
This pass infers the widths of all types throughout a FIRRTL module, and
emits diagnostics for types that could not be inferred.(new)
}];
}

def InferResets : Pass<"firrtl-infer-resets", "firrtl::CircuitOp"> {
let summary = "Infer reset synchronicity and add implicit resets";
let description = [{
Expand Down
14 changes: 14 additions & 0 deletions include/circt/Dialect/LLHD/IR/LLHDValueOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,17 @@ def ConstantTimeOp : LLHDOp<"constant_time",

let hasFolder = 1;
}

def CurrentTimeOp : LLHDOp<"current_time", [MemoryEffects<[MemRead]>]> {
let summary = "Get the current simulation time";
let description = [{
Materializes the current simulation time as an SSA value. This is equivalent
to the `$time`, `$stime`, and `$realtime` system tasks in SystemVerilog, and
the `now` keyword in VHDL.

This operation has a memory read side effect to avoid motion and CSE across
`llhd.wait` operations, and other operations that may suspend execution.
}];
let results = (outs LLHDTimeType:$result);
let assemblyFormat = "attr-dict";
}
2 changes: 2 additions & 0 deletions include/circt/Firtool/Firtool.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class FirtoolOptions {
bool shouldDisableLayerSink() const { return disableLayerSink; }
bool shouldDisableOptimization() const { return disableOptimization; }
bool shouldLowerMemories() const { return lowerMemories; }
bool shouldUseNewInferWidths() const { return useNewInferWidths; }
bool shouldDedup() const { return !noDedup; }
bool shouldDedupClasses() const { return dedupClasses; }
bool shouldEnableDebugInfo() const { return enableDebugInfo; }
Expand Down Expand Up @@ -416,6 +417,7 @@ class FirtoolOptions {
bool disableOptimization;
bool vbToBV;
bool noDedup;
bool useNewInferWidths;
bool dedupClasses;
firrtl::CompanionMode companionMode;
bool noViews;
Expand Down
7 changes: 4 additions & 3 deletions lib/Conversion/ImportVerilog/Structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,11 +803,12 @@ Context::convertModuleHeader(const slang::ast::InstanceBodySymbol *module) {
auto loc = convertLocation(module->location);
OpBuilder::InsertionGuard g(builder);

// We only support modules for now. Extension to interfaces and programs
// We only support modules and programs for now. Extension to interfaces
// should be trivial though, since they are essentially the same thing with
// only minor differences in semantics.
if (module->getDefinition().definitionKind !=
slang::ast::DefinitionKind::Module) {
auto kind = module->getDefinition().definitionKind;
if (kind != slang::ast::DefinitionKind::Module &&
kind != slang::ast::DefinitionKind::Program) {
mlir::emitError(loc) << "unsupported definition: "
<< module->getDefinition().getKindString();
return {};
Expand Down
14 changes: 14 additions & 0 deletions lib/Conversion/MooreToCore/MooreToCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2100,6 +2100,17 @@ static LogicalResult convert(FinishMessageBIOp op,
return success();
}

//===----------------------------------------------------------------------===//
// Timing Control Conversion
//===----------------------------------------------------------------------===//

// moore.builtin.time
static LogicalResult convert(TimeBIOp op, TimeBIOp::Adaptor adaptor,
ConversionPatternRewriter &rewriter) {
rewriter.replaceOpWithNewOp<llhd::CurrentTimeOp>(op);
return success();
}

//===----------------------------------------------------------------------===//
// Conversion Infrastructure
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -2443,6 +2454,9 @@ static void populateOpConversion(ConversionPatternSet &patterns,
patterns.add<FinishBIOp>(convert);
patterns.add<FinishMessageBIOp>(convert);

// Timing control
patterns.add<TimeBIOp>(convert);

mlir::populateAnyFunctionOpInterfaceTypeConversionPattern(patterns,
typeConverter);
hw::populateHWModuleLikeTypeConversionPattern(
Expand Down
4 changes: 3 additions & 1 deletion lib/Dialect/FIRRTL/FIRRTLReductions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2138,7 +2138,9 @@ void firrtl::FIRRTLReducePatternDialectInterface::populateReducePatterns(
true);
patterns.add<PassReduction, 28>(getContext(),
firrtl::createLowerCHIRRTLPass(), true, true);
patterns.add<PassReduction, 27>(getContext(), firrtl::createInferWidths(),
// patterns.add<PassReduction, 27>(getContext(), firrtl::createInferWidths(),
// true, true);
patterns.add<PassReduction, 27>(getContext(), firrtl::createInferWidths_new(),
true, true);
patterns.add<PassReduction, 26>(getContext(), firrtl::createInferResets(),
true, true);
Expand Down
1 change: 1 addition & 0 deletions lib/Dialect/FIRRTL/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ add_circt_dialect_library(CIRCTFIRRTLTransforms
InferReadWrite.cpp
InferResets.cpp
InferWidths.cpp
InferWidths_new.cpp
InjectDUTHierarchy.cpp
InnerSymbolDCE.cpp
LegacyWiring.cpp
Expand Down
4 changes: 2 additions & 2 deletions lib/Dialect/FIRRTL/Transforms/InferWidths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1595,8 +1595,8 @@ LogicalResult InferenceMapping::mapOperation(Operation *op) {
})

// Handle the no-ops that don't interact with width inference.
.Case<PrintFOp, FFlushOp, SkipOp, StopOp, WhenOp, AssertOp, AssumeOp,
UnclockedAssumeIntrinsicOp, CoverOp>([&](auto) {})
.Case<AssertOp, AssumeOp, CoverOp, DomainDefineOp, FFlushOp, PrintFOp,
SkipOp, StopOp, UnclockedAssumeIntrinsicOp, WhenOp>([&](auto) {})

// Handle instances of other modules.
.Case<InstanceOp>([&](auto op) {
Expand Down
Loading