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
12 changes: 9 additions & 3 deletions lib/Conversion/HWToBTOR2/HWToBTOR2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,15 @@ struct ConvertHWToBTOR2Pass
auto operands = op->getOperands();
size_t sid = sortToLIDMap.at(width);

if (operands.size() < 2) {
op->emitError("variadic operations with less than 2 operands are not "
"currently supported");
// No need to consider 0-operand case as it'll be rejected by the verifier
// If there's only one operand, then we don't generate a BTOR2 instruction,
// we just reuse the operand's existing LID
if (operands.size() == 1) {
auto existingLID = getOpLID(operands[0]);
// Check that we haven't somehow got a value that doesn't have a
// corresponding LID
assert(existingLID != noLID);
opLIDMap[op] = existingLID;
return;
}

Expand Down
12 changes: 8 additions & 4 deletions test/Conversion/HWToBTOR2/comb.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ module {
// CHECK: [[NID18:[0-9]+]] and [[NID0]] [[NID17]] [[NID10]]
%10 = comb.and %a, %3, %3 : i32


// CHECK: [[NID19:[0-9]+]] implies [[NID3]] [[NID5]] [[NID12]]
// CHECK: [[NID20:[0-9]+]] not [[NID3]] [[NID19]]
// CHECK: [[NID21:[0-9]+]] bad [[NID20:[0-9]+]]
// Variadic ops with one operand should be forwarded to the operand's LID
// CHECK: [[NID19:[0-9]+]] and [[NID0]] 2 [[NID18]]
%11 = comb.and %10 : i32
%12 = comb.and %a, %11 : i32

// CHECK: [[ASSERTNID1:[0-9]+]] implies [[NID3]] [[NID5]] [[NID12]]
// CHECK: [[ASSERTNID2:[0-9]+]] not [[NID3]] [[ASSERTNID1]]
// CHECK: [[ASSERTNID3:[0-9]+]] bad [[ASSERTNID2:[0-9]+]]
sv.always posedge %0 {
sv.if %true {
sv.assert %5, immediate message "a + 1 should be greater than a"
Expand Down