Skip to content

Commit

Permalink
[slang] Fix PATHPULSE limit values (MikePopoloski#1048)
Browse files Browse the repository at this point in the history
  • Loading branch information
likeamahoney authored and JoelSole-Semidyn committed Jul 15, 2024
1 parent 7baaffa commit 89ad96a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
1 change: 0 additions & 1 deletion scripts/diagnostics.txt
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ error WrongSpecifyDelayCount "expected one, two, three, six, or twelve delay val
error IfNoneEdgeSensitive "ifnone specify path cannot be an edge-sensitive path"
error PulseControlSpecifyParent "pulse control specparams can only be declared in specify blocks"
error PulseControlPATHPULSE "pulse control specparam names must start with 'PATHPULSE$'"
error PulseControlTwoValues "pulse control specparams must be assigned two values (reject limit and error limit)"
error TooManyEdgeDescriptors "cannot have more than six pairs of edge transitions in list"
error EdgeDescWrongKeyword "edge descriptor list cannot be used after '{}'"
error BindDirectiveInvalidName "bind target name must be a simple module or interface identifier when a list of instances is provided"
Expand Down
11 changes: 4 additions & 7 deletions source/parsing/Parser_members.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3223,13 +3223,10 @@ SpecparamDeclaratorSyntax& Parser::parseSpecparamDeclarator(SyntaxKind parentKin
closeParen = expect(TokenKind::CloseParenthesis);

if (!name.isMissing()) {
if (isPathPulse) {
if (parentKind != SyntaxKind::SpecifyBlock)
addDiag(diag::PulseControlSpecifyParent, name.range());
else if (!expr2)
addDiag(diag::PulseControlTwoValues, expr1.sourceRange()) << name.range();
}
else if (expr2) {
if (isPathPulse && parentKind != SyntaxKind::SpecifyBlock)
addDiag(diag::PulseControlSpecifyParent, name.range());

if (!isPathPulse && expr2) {
auto last = expr2->getLastToken();
SourceRange range(expr1.getFirstToken().location(),
last.location() + last.rawText().length());
Expand Down
19 changes: 16 additions & 3 deletions tests/unittests/parsing/MemberParsingTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,20 @@ module m;
specparam PATHPULSE$a$b = (1:2:3, 4:5:6);
endspecify
endmodule
module m1;
specify
specparam PATHPULSE$ = 1;
specparam PATHPULSE$a$b = 1;
endspecify
endmodule
module m2;
specify
specparam PATHPULSE$ = (1);
specparam PATHPULSE$a$b = (1);
endspecify
endmodule
)";

parseCompilationUnit(text);
Expand All @@ -710,10 +724,9 @@ endmodule

parseCompilationUnit(text);

REQUIRE(diagnostics.size() == 3);
REQUIRE(diagnostics.size() == 2);
CHECK(diagnostics[0].code == diag::PulseControlSpecifyParent);
CHECK(diagnostics[1].code == diag::PulseControlTwoValues);
CHECK(diagnostics[2].code == diag::PulseControlPATHPULSE);
CHECK(diagnostics[1].code == diag::PulseControlPATHPULSE);
}

TEST_CASE("Invalid package decls") {
Expand Down

0 comments on commit 89ad96a

Please sign in to comment.