Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verilog: allow vector-typed operands to edge event control #938

Merged
merged 1 commit into from
Jan 17, 2025
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
4 changes: 2 additions & 2 deletions regression/verilog/synthesis/posedge_vector.desc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CORE
posedge_vector.v
--module main
^file posedge_vector.v line \d+: pos/negedge expected to have Boolean as operand, but got \[7:0\]$
^EXIT=2$
^no properties$
^EXIT=10$
^SIGNAL=0$
--
^warning: ignoring
Expand Down
1 change: 1 addition & 0 deletions regression/verilog/synthesis/posedge_vector.v
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module main(input [7:0] data);

// Allowed; only the LSB will be considered.
always @(posedge data);

endmodule
26 changes: 9 additions & 17 deletions src/verilog/verilog_synthesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2729,22 +2729,6 @@ void verilog_synthesist::synth_event_guard(
<< "pos/negedge expected to have one operand";
}

if(to_unary_expr(*it).op().id() != ID_symbol)
{
throw errort().with_location(it->source_location())
<< "pos/negedge expected to have symbol as operand, "
"but got " +
to_unary_expr(*it).op().pretty();
}

if(to_unary_expr(*it).op().type().id() != ID_bool)
{
throw errort().with_location(it->source_location())
<< "pos/negedge expected to have Boolean as operand, "
"but got " +
to_string(to_unary_expr(*it).op().type());
}

irep_idt identifier="conf::clock_enable_mode";

// check symbol_table for clock guard
Expand All @@ -2753,7 +2737,15 @@ void verilog_synthesist::synth_event_guard(
{
// found! we make it a guard

guards.push_back(to_unary_expr(*it).op());
auto &op = to_unary_expr(*it).op();

if(op.type().id() == ID_bool)
guards.push_back(op);
else
{
// get LSB
guards.push_back(extractbit_exprt{op, integer_typet{}.zero_expr()});
}

throw errort() << "Notice: using clock guard " << identifier;
}
Expand Down
Loading