Skip to content

Commit

Permalink
Support iff in sensitivity list
Browse files Browse the repository at this point in the history
Signed-off-by: Krzysztof Bieganski <[email protected]>
  • Loading branch information
kbieganski committed Oct 26, 2023
1 parent cf6e362 commit d1814f0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
4 changes: 3 additions & 1 deletion src/V3AstNodeOther.h
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,7 @@ class AstScope final : public AstNode {
class AstSenItem final : public AstNode {
// Parents: SENTREE
// @astgen op1 := sensp : Optional[AstNodeExpr] // Sensitivity expression
// @astgen op2 := condp : Optional[AstNodeExpr] // Sensitivity condition
VEdgeType m_edgeType; // Edge type
public:
class Combo {}; // for constructor type-overload selection
Expand All @@ -1446,10 +1447,11 @@ class AstSenItem final : public AstNode {
class Initial {}; // for constructor type-overload selection
class Final {}; // for constructor type-overload selection
class Never {}; // for constructor type-overload selection
AstSenItem(FileLine* fl, VEdgeType edgeType, AstNodeExpr* senp)
AstSenItem(FileLine* fl, VEdgeType edgeType, AstNodeExpr* senp, AstNodeExpr* condp = nullptr)
: ASTGEN_SUPER_SenItem(fl)
, m_edgeType{edgeType} {
this->sensp(senp);
this->condp(condp);
}
AstSenItem(FileLine* fl, Combo)
: ASTGEN_SUPER_SenItem(fl)
Expand Down
4 changes: 3 additions & 1 deletion src/V3SenExprBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ class SenExprBuilder final {
for (AstSenItem* senItemp = senTreep->sensesp(); senItemp;
senItemp = VN_AS(senItemp->nextp(), SenItem)) {
const auto& pair = createTerm(senItemp);
if (AstNodeExpr* const termp = pair.first) {
if (AstNodeExpr* termp = pair.first) {
AstNodeExpr* const condp = senItemp->condp();
if (condp) termp = new AstAnd{flp, condp->cloneTree(false), termp};
resultp = resultp ? new AstOr{flp, resultp, termp} : termp;
firedAtInitialization |= pair.second;
}
Expand Down
12 changes: 4 additions & 8 deletions src/verilog.y
Original file line number Diff line number Diff line change
Expand Up @@ -3348,8 +3348,7 @@ senitem<senItemp>: // IEEE: part of event_expression, non-'OR' ','
| expr
{ $$ = new AstSenItem{$<fl>1, VEdgeType::ET_CHANGED, $1}; }
| expr yIFF expr
{ $$ = new AstSenItem{$<fl>1, VEdgeType::ET_CHANGED, $1};
if ($2) BBUNSUP($2, "Unsupported: event expression 'iff'"); }
{ $$ = new AstSenItem{$<fl>1, VEdgeType::ET_CHANGED, $1, $3}; }
;

senitemVar<senItemp>:
Expand All @@ -3364,14 +3363,11 @@ senitemEdge<senItemp>: // IEEE: part of event_expression
| yEDGE expr
{ $$ = new AstSenItem{$1, VEdgeType::ET_BOTHEDGE, $2}; }
| yPOSEDGE expr yIFF expr
{ $$ = new AstSenItem{$1, VEdgeType::ET_POSEDGE, $2};
BBUNSUP($3, "Unsupported: event expression 'iff'"); }
{ $$ = new AstSenItem{$1, VEdgeType::ET_POSEDGE, $2, $4}; }
| yNEGEDGE expr yIFF expr
{ $$ = new AstSenItem{$1, VEdgeType::ET_NEGEDGE, $2};
BBUNSUP($3, "Unsupported: event expression 'iff'"); }
{ $$ = new AstSenItem{$1, VEdgeType::ET_NEGEDGE, $2, $4}; }
| yEDGE expr yIFF expr
{ $$ = new AstSenItem{$1, VEdgeType::ET_BOTHEDGE, $2};
BBUNSUP($3, "Unsupported: event expression 'iff'"); }
{ $$ = new AstSenItem{$1, VEdgeType::ET_BOTHEDGE, $2, $4}; }
;

//************************************************
Expand Down
5 changes: 1 addition & 4 deletions test_regress/t/t_iff.pl
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@
scenarios(simulator => 1);

compile(
verilator_flags2 => ['--timing'],
fails => $Self->{vlt_all}, # Verilator unsupported, bug1482, iff not supported
expect_filename => $Self->{golden_filename},
);

execute(
check_finished => 1,
) if !$Self->{vlt_all};
);

ok(1);
1;
6 changes: 3 additions & 3 deletions test_regress/t/t_iff.v
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module t (/*AUTOARG*/

/*AUTOWIRE*/
// Beginning of automatic wires (for undeclared instantiated-module outputs)
wire [31:0] result; // From test of Test.v
wire [63:0] result; // From test of Test.v
// End of automatics
Test test (.*);

Expand All @@ -42,7 +42,7 @@ module t (/*AUTOARG*/
$write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum);
if (crc !== 64'hc77bb9b3784ea091) $stop;
// What checksum will we end up with (above print should match)
`define EXPECTED_SUM 64'h390aa8652d33a691
`define EXPECTED_SUM 64'hd55eb7da9ba3354a
if (sum !== `EXPECTED_SUM) $stop;
$write("*-* All Finished *-*\n");
$finish;
Expand All @@ -56,7 +56,7 @@ module Test
input clk,
input [63:0] crc,
input [31:0] cyc,
output wire [31:0] result);
output wire [63:0] result);

wire enable = crc[32];
wire [7:0] d = crc[7:0];
Expand Down

0 comments on commit d1814f0

Please sign in to comment.