Skip to content

Commit

Permalink
Fix assert/assume/cover emission
Browse files Browse the repository at this point in the history
  • Loading branch information
povik committed Sep 25, 2024
1 parent 5cbec6a commit cb63730
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/slang_frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -943,9 +943,24 @@ struct ProceduralVisitor : public ast::ASTVisitor<ProceduralVisitor, true, false

void handle(const ast::ImmediateAssertionStatement &stmt)
{
std::string flavor;
switch (stmt.assertionKind) {
case ast::AssertionKind::Assert:
flavor = "assert";
break;
case ast::AssertionKind::Assume:
flavor = "assume";
break;
case ast::AssertionKind::CoverProperty:
flavor = "cover";
break;
default:
unimplemented(stmt);
}

auto cell = netlist.canvas->addCell(NEW_ID, ID($check));
set_effects_trigger(cell);
cell->setParam(ID::FLAVOR, std::string("assert"));
cell->setParam(ID::FLAVOR, flavor);
cell->setParam(ID::FORMAT, std::string(""));
cell->setParam(ID::ARGS_WIDTH, 0);
cell->setParam(ID::PRIORITY, --effects_priority);
Expand Down
11 changes: 11 additions & 0 deletions tests/various/formal_stmts.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module m_assert(input logic x);
always_comb assert(x);
endmodule

module m_assume(input logic x);
always_comb assume(x);
endmodule

module m_cover(input logic x);
always_comb cover(x);
endmodule
7 changes: 7 additions & 0 deletions tests/various/formal_stmts.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
read_slang formal_stmts.sv

select -assert-count 3 t:$check
dump m_assert
select -assert-count 1 m_assert/t:$check r:FLAVOR=assert %i
select -assert-count 1 m_assume/t:$check r:FLAVOR=assume %i
select -assert-count 1 m_cover/t:$check r:FLAVOR=cover %i

0 comments on commit cb63730

Please sign in to comment.