Skip to content

Commit

Permalink
Restrict allowed always_ff timing
Browse files Browse the repository at this point in the history
  • Loading branch information
povik committed Jul 17, 2024
1 parent 881b4c0 commit 3a59220
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion slang_frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,7 @@ namespace diag {
slang::DiagCode LatchInferred(slang::DiagSubsystem::Netlist, 1011);
slang::DiagCode MissingAload(slang::DiagSubsystem::Netlist, 1012);
slang::DiagCode NoteProcessDriver(slang::DiagSubsystem::Netlist, 1013);
slang::DiagCode AlwaysFFBadTiming(slang::DiagSubsystem::Netlist, 1014);

slang::DiagGroup unsynthesizable("unsynthesizable", {IffUnsupported, SignalSensitivityAmbiguous, GenericTimingUnsyn, BothEdgesUnsupported, ExpectingIfElseAload,
IfElseAloadPolarity, IfElseAloadMismatch});
Expand Down Expand Up @@ -1553,6 +1554,9 @@ namespace diag {
engine.setMessage(NoteProcessDriver, "signal driven from this process");
engine.setSeverity(NoteProcessDriver, slang::DiagnosticSeverity::Note);

engine.setMessage(AlwaysFFBadTiming, "timing control does not model a flip-flop");
engine.setSeverity(AlwaysFFBadTiming, slang::DiagnosticSeverity::Error);

engine.setSeverity(unsynthesizable, slang::DiagnosticSeverity::Error);
engine.setSeverity(sanity, slang::DiagnosticSeverity::Error);
}
Expand Down Expand Up @@ -1891,6 +1895,11 @@ struct PopulateNetlist : public ast::ASTVisitor<PopulateNetlist, true, false> {
switch (sigev.edge) {
case ast::EdgeKind::None:
{
if (symbol.procedureKind == ast::ProceduralBlockKind::AlwaysFF) {
scope->addDiag(diag::AlwaysFFBadTiming, ev->sourceRange);
break;
}

// Report on the top timing node as that makes for nicer reports in case there
// are many signals in the sensitivity list
auto &diag = symbol.getParentScope()->addDiag(diag::SignalSensitivityAmbiguous, top_ast_timing->sourceRange);
Expand Down Expand Up @@ -1924,6 +1933,11 @@ struct PopulateNetlist : public ast::ASTVisitor<PopulateNetlist, true, false> {

case ast::TimingControlKind::ImplicitEvent:
{
if (symbol.procedureKind == ast::ProceduralBlockKind::AlwaysFF) {
scope->addDiag(diag::AlwaysFFBadTiming, ev->sourceRange);
break;
}

implicit = true;
}
break;
Expand All @@ -1941,7 +1955,7 @@ struct PopulateNetlist : public ast::ASTVisitor<PopulateNetlist, true, false> {

if (implicit)
synthesize_procedure_with_implicit_timing(symbol, timed.stmt);
else
else if (!timing.triggers.empty())
synthesize_procedure_with_edge_timing(symbol, timing);
}

Expand Down

0 comments on commit 3a59220

Please sign in to comment.