Skip to content
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
27 changes: 23 additions & 4 deletions crates/celox-sv-analyzer/src/ast/procedural.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,23 @@ impl<'s, 't, 'a> BodyBuilder<'s, 't, 'a> {
StatementKind::ProceduralAssign(_) | StatementKind::ProceduralRelease(_) => {
Err(unsupported("procedural continuous assignment"))
}
StatementKind::Disable(_) => Err(unsupported("disable statement")),
StatementKind::Disable(tokens) => {
let disables_fork = self
.tree
.declarations()
.tokens
.get(tokens.start..tokens.end)
.into_iter()
.flatten()
.filter(|token| !token.is_trivia())
.find(|token| token.text != "disable")
.is_some_and(|token| token.text == "fork");
Err(unsupported(if disables_fork {
"disable fork statement"
} else {
"disable statement"
}))
}
StatementKind::Parallel { .. } => Err(unsupported("fork-join block")),
_ => Err(unsupported("procedural statement")),
}
Expand All @@ -904,9 +920,12 @@ impl<'s, 't, 'a> BodyBuilder<'s, 't, 'a> {
context: "an always_comb or always_ff body",
}),
system_functions::Body::Subroutine if self.task_timing => Ok(()),
system_functions::Body::Subroutine => {
Err(unsupported(format!("{construct} in a subroutine")))
}
// IEEE 1800-2023 13.4: a function shall not contain a timing
// control.
system_functions::Body::Subroutine => Err(AnalyzerError::TimingControlOutsideProcess {
construct,
context: "a function",
}),
}
}

Expand Down
7 changes: 7 additions & 0 deletions crates/celox-sv-analyzer/src/ast/type_binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ pub(super) fn local_signals(
) -> Converted<Vec<Signal>> {
let context = PackedDimensions::new(HashMap::default(), env, aliases);
let Some(base) = bind(declaration.data_type, tree, &context)? else {
// A named event (IEEE 1800-2023 6.17) is a data type of its own.
if matches!(
&tree.declarations().data_type(declaration.data_type).kind,
celox_sv_syntax::DataTypeKind::Builtin(name) if name == "event"
) {
return Err(unsupported("named event"));
}
return Err(unsupported("unsupported internal data type"));
};
let mut signals = Vec::new();
Expand Down
23 changes: 15 additions & 8 deletions crates/celox-sv-analyzer/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3493,9 +3493,9 @@ fn rejects_unimplemented_timing_constructs() {
for (body, construct) in [
("initial begin fork #1; join end", "fork-join block"),
("initial wait fork;", "wait fork statement"),
// The `event` data type is rejected before its uses.
("event e; initial @e;", "unsupported internal data type"),
("event e; initial ->e;", "unsupported internal data type"),
// The `event` data type is rejected by name before its uses.
("event e; initial @e;", "named event"),
("event e; initial ->e;", "named event"),
(
"logic clk, en; initial @(posedge clk iff en);",
"iff-qualified event",
Expand All @@ -3509,14 +3509,11 @@ fn rejects_unimplemented_timing_constructs() {
"intra-assignment timing control",
),
("initial begin : b disable b; end", "disable statement"),
("initial disable fork;", "disable fork statement"),
(
"logic a, y; always_latch y <= a;",
"nonblocking assignment inside always_latch",
),
(
"function void t(); #1; endfunction",
"delay control in a subroutine",
),
] {
let code = format!("module Top; {body} endmodule");
let error = analyze_source(&code, Path::new("timing.sv"))
Expand Down Expand Up @@ -6113,7 +6110,17 @@ fn functions_still_reject_direct_timing_controls() {
);
let error = analyze_source(&source, Path::new("function_timing.sv"))
.expect_err("functions cannot suspend");
assert!(error.to_string().contains("in a subroutine"), "{error}");
// IEEE 1800-2023 13.4 makes it illegal, not unimplemented.
assert!(
matches!(
error,
AnalyzerError::TimingControlOutsideProcess {
context: "a function",
..
}
),
"{error:?}"
);
}
}

Expand Down
13 changes: 3 additions & 10 deletions crates/celox/tests/frontends/systemverilog/timing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,7 @@ fn unimplemented_timing_features_are_rejected() {
("bit a; initial @(a iff a);", "iff-qualified event", 1444),
("initial fork #1; join", "fork-join block", 88),
("initial fork #1; join_none", "fork-join block", 88),
// #1711 names the construct.
(
"event e; initial -> e;",
"unsupported internal data type",
88,
),
("event e; initial -> e;", "named event", 88),
(
"bit a, b; initial a = #1 b;",
"intra-assignment timing control",
Expand All @@ -450,8 +445,7 @@ fn unimplemented_timing_features_are_rejected() {
88,
),
("initial wait fork;", "wait fork statement", 88),
// #1711 names the construct.
("initial disable fork;", "disable statement", 88),
("initial disable fork;", "disable fork statement", 88),
(
"bit a; task t(input bit x); wait (a ^ x); endtask initial t(0);",
"wait condition reading a static task argument",
Expand Down Expand Up @@ -585,10 +579,9 @@ fn timing_controls_outside_suspendable_processes_are_rejected() {
"bit clk, a, q; always_ff @(posedge clk) begin @(a); q <= a; end",
"event control in an always_comb or always_ff body",
),
// #1711 reports this as illegal rather than unsupported.
(
"bit a; function automatic bit f(); #1; return a; endfunction",
"delay control in a subroutine",
"delay control in a function",
),
] {
let source = format!("module Top; {body} endmodule");
Expand Down
Loading