Skip to content

Commit ce3098d

Browse files
authored
Merge pull request #938 from diffblue/posedge_vector-fix
Verilog: allow vector-typed operands to edge event control
2 parents f6c38d9 + d9ce3a7 commit ce3098d

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

regression/verilog/synthesis/posedge_vector.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
CORE
22
posedge_vector.v
33
--module main
4-
^file posedge_vector.v line \d+: pos/negedge expected to have Boolean as operand, but got \[7:0\]$
5-
^EXIT=2$
4+
^no properties$
5+
^EXIT=10$
66
^SIGNAL=0$
77
--
88
^warning: ignoring
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module main(input [7:0] data);
22

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

56
endmodule

src/verilog/verilog_synthesis.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2729,22 +2729,6 @@ void verilog_synthesist::synth_event_guard(
27292729
<< "pos/negedge expected to have one operand";
27302730
}
27312731

2732-
if(to_unary_expr(*it).op().id() != ID_symbol)
2733-
{
2734-
throw errort().with_location(it->source_location())
2735-
<< "pos/negedge expected to have symbol as operand, "
2736-
"but got " +
2737-
to_unary_expr(*it).op().pretty();
2738-
}
2739-
2740-
if(to_unary_expr(*it).op().type().id() != ID_bool)
2741-
{
2742-
throw errort().with_location(it->source_location())
2743-
<< "pos/negedge expected to have Boolean as operand, "
2744-
"but got " +
2745-
to_string(to_unary_expr(*it).op().type());
2746-
}
2747-
27482732
irep_idt identifier="conf::clock_enable_mode";
27492733

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

2756-
guards.push_back(to_unary_expr(*it).op());
2740+
auto &op = to_unary_expr(*it).op();
2741+
2742+
if(op.type().id() == ID_bool)
2743+
guards.push_back(op);
2744+
else
2745+
{
2746+
// get LSB
2747+
guards.push_back(extractbit_exprt{op, integer_typet{}.zero_expr()});
2748+
}
27572749

27582750
throw errort() << "Notice: using clock guard " << identifier;
27592751
}

0 commit comments

Comments
 (0)