Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions lib/Conversion/MooreToCore/MooreToCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,12 @@ static Value createZeroValue(Type type, Location loc,
return llhd::ConstantTimeOp::create(rewriter, loc, timeAttr);
}

// Handle real values.
if (auto floatType = dyn_cast<FloatType>(type)) {
auto floatAttr = rewriter.getFloatAttr(floatType, 0.0);
return mlir::arith::ConstantOp::create(rewriter, loc, floatAttr);
}

// Otherwise try to create a zero integer and bitcast it to the result type.
int64_t width = hw::getBitWidth(type);
if (width == -1)
Expand Down
8 changes: 8 additions & 0 deletions test/Conversion/MooreToCore/basic.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,14 @@ moore.module @Variable() {
%c42_fs = moore.constant_time 42 fs
moore.variable %c42_fs : <!moore.time>

// CHECK: [[TMP:%.+]] = arith.constant {{0.*}} : f32
// CHECK: llhd.sig [[TMP]] : f32
moore.variable : <!moore.f32>

// CHECK: [[TMP:%.+]] = arith.constant {{0.*}} : f64
// CHECK: llhd.sig [[TMP]] : f64
moore.variable : <!moore.f64>

// CHECK: hw.output
moore.output
}
Expand Down