diff --git a/conformance/sv-tests/expected.tsv b/conformance/sv-tests/expected.tsv index dd7fd87a78c..b4e64f909ce 100644 --- a/conformance/sv-tests/expected.tsv +++ b/conformance/sv-tests/expected.tsv @@ -1833,22 +1833,22 @@ generated/binary_op/11.4.8--binary_op_bit_xor.sv 2state pass generated/binary_op/11.4.8--binary_op_bit_xor.sv 4state pass generated/easyUVM/top.sv 2state fail generated/easyUVM/top.sv 4state fail -generated/encapsulation/8.18--inherited_local_from_inside.sv 2state fail -generated/encapsulation/8.18--inherited_local_from_inside.sv 4state fail -generated/encapsulation/8.18--inherited_local_from_outside.sv 2state fail -generated/encapsulation/8.18--inherited_local_from_outside.sv 4state fail +generated/encapsulation/8.18--inherited_local_from_inside.sv 2state pass +generated/encapsulation/8.18--inherited_local_from_inside.sv 4state pass +generated/encapsulation/8.18--inherited_local_from_outside.sv 2state pass +generated/encapsulation/8.18--inherited_local_from_outside.sv 4state pass generated/encapsulation/8.18--inherited_prot_from_inside.sv 2state pass generated/encapsulation/8.18--inherited_prot_from_inside.sv 4state pass -generated/encapsulation/8.18--inherited_prot_from_outside.sv 2state fail -generated/encapsulation/8.18--inherited_prot_from_outside.sv 4state fail +generated/encapsulation/8.18--inherited_prot_from_outside.sv 2state pass +generated/encapsulation/8.18--inherited_prot_from_outside.sv 4state pass generated/encapsulation/8.18--local_from_inside.sv 2state pass generated/encapsulation/8.18--local_from_inside.sv 4state pass -generated/encapsulation/8.18--local_from_outside.sv 2state fail -generated/encapsulation/8.18--local_from_outside.sv 4state fail +generated/encapsulation/8.18--local_from_outside.sv 2state pass +generated/encapsulation/8.18--local_from_outside.sv 4state pass generated/encapsulation/8.18--prot_from_inside.sv 2state pass generated/encapsulation/8.18--prot_from_inside.sv 4state pass -generated/encapsulation/8.18--prot_from_outside.sv 2state fail -generated/encapsulation/8.18--prot_from_outside.sv 4state fail +generated/encapsulation/8.18--prot_from_outside.sv 2state pass +generated/encapsulation/8.18--prot_from_outside.sv 4state pass generated/equality_operators_sim/11.4.5--equality_operator_0.sv 2state fail generated/equality_operators_sim/11.4.5--equality_operator_0.sv 4state fail generated/equality_operators_sim/11.4.5--equality_operator_1.sv 2state fail diff --git a/crates/celox-frontend-sv/src/lowering.rs b/crates/celox-frontend-sv/src/lowering.rs index 04e2ab43bc7..fa54240afe6 100644 --- a/crates/celox-frontend-sv/src/lowering.rs +++ b/crates/celox-frontend-sv/src/lowering.rs @@ -5092,11 +5092,36 @@ fn lower_initial_processes( .zip(slots) .enumerate() .map(|(index, ((process, random_seed), slots))| { - let kernel = ff::Ff::new(&mut pm, random_seed).lower_initial_kernel( - process.body(), - slots, - index, - )?; + // `always @(list) statement` waits for a change (IEEE 1800-2023 + // 9.4.2). In two-state mode its outputs would then start as a + // real 0, so it runs once at time zero, after the time-zero + // statements of the initial blocks, before it waits, as + // Verilator settles it: `#0; forever begin statement; @(list); end`. + let settled; + let body = match process.level_sensitive().filter(|_| !four_state) { + Some((items, statements)) => { + let mut looped = statements.to_vec(); + looped.push(sv::ir::Stmt::WaitEvent(items.to_vec())); + settled = [ + sv::ir::Stmt::Delay { + amount: sv::ir::Expr::Literal("0".to_string()), + ticks_per_unit: 1, + ticks_per_precision: 1, + }, + sv::ir::Stmt::Loop { + kind: sv::ir::LoopKind::Forever, + init: Vec::new(), + condition: None, + step: Vec::new(), + body: looped, + }, + ]; + &settled[..] + } + None => process.body(), + }; + let kernel = + ff::Ff::new(&mut pm, random_seed).lower_initial_kernel(body, slots, index)?; wait_sites.extend(kernel.wait_sites); nba_sites.extend(kernel.nba_sites); nba_switches.extend(kernel.nba_switches); diff --git a/crates/celox-frontend-sv/src/lowering/ff.rs b/crates/celox-frontend-sv/src/lowering/ff.rs index 7c9c153da7c..3dc8a09386f 100644 --- a/crates/celox-frontend-sv/src/lowering/ff.rs +++ b/crates/celox-frontend-sv/src/lowering/ff.rs @@ -3950,6 +3950,11 @@ impl<'p, 'a> Ff<'p, 'a> { arena: &mut SLTNodeArena, ) -> Result>, sv::AnalyzerError> { let always_comb = kind != sv::ir::CombProcessKind::AlwaysStar; + // `always @*` and a sensitivity list wait for a change (IEEE + // 1800-2023 9.2.2.2). In two-state mode their outputs would then + // start as a real 0, so they run once at time zero, after the + // `initial` blocks, like `always_comb`, as Verilator settles them. + let runs_at_time_zero = always_comb || !self.m.four_state; self.direct = true; let mut reads = self.m.implicit_reads(body, always_comb); reads.extend(self.m.implicit_reads(sensitivity_body, always_comb)); @@ -4113,7 +4118,7 @@ impl<'p, 'a> Ff<'p, 'a> { counter_snapshots.push((counter, saved_counter)); } let run = self.b.alloc_bit(1, false); - if always_comb { + if runs_at_time_zero { let first = self.b.alloc_bit(1, false); self.b .emit(SIRInstruction::Unary(first, UnaryOp::LogicNot, init)); @@ -4227,7 +4232,7 @@ impl<'p, 'a> Ff<'p, 'a> { target: LogicPathTarget::Process { process: initialized, sensitivity_counters: sensitivity_counters.clone(), - startup: (!always_comb).then(|| celox_slt::CombStartup { + startup: (!runs_at_time_zero).then(|| celox_slt::CombStartup { initialized, counters: counter_snapshots.clone(), inputs: sources @@ -4239,7 +4244,8 @@ impl<'p, 'a> Ff<'p, 'a> { after_initials: matches!( kind, sv::ir::CombProcessKind::AlwaysComb | sv::ir::CombProcessKind::AlwaysLatch - ), + ) || (kind == sv::ir::CombProcessKind::AlwaysStar + && !self.m.four_state), target, unit: Box::new(unit.clone()), }, diff --git a/crates/celox-sv-analyzer/src/ast/classes.rs b/crates/celox-sv-analyzer/src/ast/classes.rs index 467292a8c8e..4d60ddf1d3c 100644 --- a/crates/celox-sv-analyzer/src/ast/classes.rs +++ b/crates/celox-sv-analyzer/src/ast/classes.rs @@ -58,6 +58,8 @@ impl Property { #[derive(Debug, Clone, PartialEq, Eq)] pub(super) struct StaticProperty { pub name: String, + pub local: bool, + pub protected: bool, /// The class that declares the property. pub owner: String, pub r#type: Type, @@ -460,6 +462,8 @@ pub(super) fn class( if property.qualifiers.is_static { statics.retain(|known| known.name != property_name); statics.push(StaticProperty { + local: property.qualifiers.local, + protected: property.qualifiers.protected, variable: Class::subroutine_name(name, &property_name), name: property_name, owner: name.to_owned(), diff --git a/crates/celox-sv-analyzer/src/ast/expression_binding.rs b/crates/celox-sv-analyzer/src/ast/expression_binding.rs index aa217e1c1b2..dc6bc26f503 100644 --- a/crates/celox-sv-analyzer/src/ast/expression_binding.rs +++ b/crates/celox-sv-analyzer/src/ast/expression_binding.rs @@ -16,9 +16,9 @@ pub(super) use direct::{ pub(super) use lvalues::{net_lvalue, variable_lvalue}; pub(super) use objects::{ Cast as ObjectCast, Receiver as ObjectReceiver, cast as object_cast, - check_assignment as check_handle_assignment, constructor as object_constructor, - method as object_method, property as object_property, rand_mode_call as object_rand_mode_call, - receiver as object_receiver, this as object_this, + check_access as check_member_access, check_assignment as check_handle_assignment, + constructor as object_constructor, method as object_method, property as object_property, + rand_mode_call as object_rand_mode_call, receiver as object_receiver, this as object_this, }; pub(super) use strings::{ call as string_call, method as string_method, native_string, to_string as string_operand, diff --git a/crates/celox-sv-analyzer/src/ast/expression_binding/objects.rs b/crates/celox-sv-analyzer/src/ast/expression_binding/objects.rs index 1c91118b142..c5417adf83e 100644 --- a/crates/celox-sv-analyzer/src/ast/expression_binding/objects.rs +++ b/crates/celox-sv-analyzer/src/ast/expression_binding/objects.rs @@ -53,6 +53,38 @@ pub(in crate::ast) fn native_class( property.r#type.class().map(str::to_owned) } +/// Access depends on the lexical class, not the class of the receiver (8.18). +pub(in crate::ast) fn check_access( + tree: &AnalysisContext<'_>, + dimensions: &PackedDimensions, + owner: &str, + name: &str, + local: bool, + protected: bool, +) -> Converted<()> { + if !local && !protected { + return Ok(()); + } + if let Some(scope) = dimensions.class_scope.as_deref() { + if scope == owner + || (!local + && class(tree, dimensions, scope)?.derives_from( + tree, + owner, + &dimensions.const_env, + &dimensions.type_aliases, + )) + { + return Ok(()); + } + } + Err(AnalyzerError::InaccessibleClassMember { + owner: owner.to_owned(), + name: name.to_owned(), + visibility: if local { "local" } else { "protected" }, + }) +} + /// The class whose method is being bound, whose properties and methods /// unqualified names may refer to. pub(in crate::ast) fn scope_class(dimensions: &PackedDimensions) -> Option { @@ -115,9 +147,20 @@ pub(in crate::ast) fn static_property( let Some(class_name) = class_name else { return Ok(None); }; - Ok(class(tree, dimensions, &class_name)? - .static_property(&instances::normalize_identifier(&name.spelling)) - .map(|property| property.variable.clone())) + let class = class(tree, dimensions, &class_name)?; + let Some(property) = class.static_property(&instances::normalize_identifier(&name.spelling)) + else { + return Ok(None); + }; + check_access( + tree, + dimensions, + &property.owner, + &property.name, + property.local, + property.protected, + )?; + Ok(Some(property.variable.clone())) } /// The property that native expression `id` names, `h.p` or an unqualified @@ -157,9 +200,28 @@ pub(in crate::ast) fn property( _ => return Ok(None), }; let class = class(tree, dimensions, &class_name)?; - let Some(property) = class.property(&instances::normalize_identifier(&name.spelling)) else { + let name = instances::normalize_identifier(&name.spelling); + let Some(property) = class.property(&name) else { + if let Some(property) = class.static_property(&name) { + check_access( + tree, + dimensions, + &property.owner, + &property.name, + property.local, + property.protected, + )?; + } return Ok(None); }; + check_access( + tree, + dimensions, + &property.owner, + &property.name, + property.local, + property.protected, + )?; if receiver.is_none() && dimensions.get(THIS).is_none() { return Err(unsupported(format!( "non-static property `{}` in a static method", @@ -202,8 +264,26 @@ pub(in crate::ast) fn unqualified_property( }; let class = class(tree, dimensions, &class_name)?; let Some(property) = class.property(name) else { + if let Some(property) = class.static_property(name) { + check_access( + tree, + dimensions, + &property.owner, + &property.name, + property.local, + property.protected, + )?; + } return Ok(None); }; + check_access( + tree, + dimensions, + &property.owner, + &property.name, + property.local, + property.protected, + )?; if dimensions.get(THIS).is_none() { return Err(unsupported(format!( "non-static property `{name}` in a static method" @@ -300,6 +380,14 @@ pub(in crate::ast) fn method( let Some(method) = class.method(&method_name) else { return Ok(None); }; + check_access( + tree, + dimensions, + &method.owner, + &method.name, + method.qualifiers.local, + method.qualifiers.protected, + )?; if through_super && method.is_pure() { return Err(unsupported(format!( "pure virtual method `{}` called through `super`", @@ -485,6 +573,16 @@ pub(in crate::ast) fn constructor( _ => return Ok(None), }; let class = class(tree, dimensions, &class_name)?; + if let Some(method) = class.method("new") { + check_access( + tree, + dimensions, + &method.owner, + &method.name, + method.qualifiers.local, + method.qualifiers.protected, + )?; + } if class.is_abstract { return Err(unsupported(format!( "object of abstract class `{class_name}`" @@ -674,28 +772,12 @@ fn check_random_access( dimensions: &PackedDimensions, property: &classes::Property, ) -> Converted<()> { - let scope = scope_class(dimensions); - let accessible = if property.local { - scope.as_deref() == Some(&property.owner) - } else if property.protected { - scope - .and_then(|name| class(tree, dimensions, &name).ok()) - .is_some_and(|class| { - class.derives_from( - tree, - &property.owner, - &dimensions.const_env, - &dimensions.type_aliases, - ) - }) - } else { - true - }; - if !accessible { - return Err(unsupported(format!( - "randomization access to non-public property `{}`", - property.name - ))); - } - Ok(()) + check_access( + tree, + dimensions, + &property.owner, + &property.name, + property.local, + property.protected, + ) } diff --git a/crates/celox-sv-analyzer/src/ast/procedural.rs b/crates/celox-sv-analyzer/src/ast/procedural.rs index 17604d9017c..ec9374ac1a0 100644 --- a/crates/celox-sv-analyzer/src/ast/procedural.rs +++ b/crates/celox-sv-analyzer/src/ast/procedural.rs @@ -283,6 +283,11 @@ impl<'s, 't, 'a> BodyBuilder<'s, 't, 'a> { .push(entry); } for property in &class.statics { + // A base's local static is not visible in the derived class (8.18). + // Keep it out of the alias table so binding can diagnose its use. + if property.local && property.owner != class.name { + continue; + } let entry = self.take_binding( &property.name, Some(property.variable.clone()), @@ -2468,6 +2473,16 @@ impl BodyBuilder<'_, '_, '_> { &self.dims.const_env, &self.dims.type_aliases, )?; + if let Some(method) = base.method("new") { + expression_binding::check_member_access( + self.tree, + &self.dims, + &method.owner, + &method.name, + method.qualifiers.local, + method.qualifiers.protected, + )?; + } let formals = base.constructor_formals(native); if arguments.len() > formals { return Err(unsupported(format!( diff --git a/crates/celox-sv-analyzer/src/lib.rs b/crates/celox-sv-analyzer/src/lib.rs index 35997a2c289..09e54787e5b 100644 --- a/crates/celox-sv-analyzer/src/lib.rs +++ b/crates/celox-sv-analyzer/src/lib.rs @@ -66,6 +66,13 @@ pub enum AnalyzerError { Parse(String), #[error("Unsupported SystemVerilog construct: {0}")] Unsupported(String), + /// A class member is inaccessible from the lexical scope (IEEE 1800-2023 8.18). + #[error("{visibility} class member `{owner}::{name}` is not accessible from this scope")] + InaccessibleClassMember { + owner: String, + name: String, + visibility: &'static str, + }, /// A dotted name whose first component names no variable or interface /// of the scope: a hierarchical name (IEEE 1800-2023 23.6) that the /// caller did not resolve to a signal of another instance. diff --git a/crates/celox-sv-analyzer/src/tests.rs b/crates/celox-sv-analyzer/src/tests.rs index c3c271322e4..5c6a2c29d8c 100644 --- a/crates/celox-sv-analyzer/src/tests.rs +++ b/crates/celox-sv-analyzer/src/tests.rs @@ -6628,8 +6628,8 @@ fn class_randomize_rejects_unsupported_semantics() { "not an instance property", ), ("const int x = 1;", "c.randomize(x)", "const"), - ("local int x;", "c.randomize(x)", "non-public"), - ("protected int x;", "c.randomize(x)", "non-public"), + ("local int x;", "c.randomize(x)", "not accessible"), + ("protected int x;", "c.randomize(x)", "not accessible"), ("rand int x;", "c.rand_mode()", "getter requires"), ("int x;", "c.x.rand_mode()", "rand or randc"), ( @@ -6822,3 +6822,140 @@ fn class_randc_checks_domain_limits() { } } } + +#[test] +fn class_visibility_rejects_inaccessible_members() { + for visibility in ["local", "protected"] { + for member in [ + "int x;", + "static int x;", + "function int x(); return 1; endfunction", + "static function int x(); return 1; endfunction", + ] { + let access = if member.contains("function") { + "c.x()" + } else { + "c.x" + }; + for derived in [false, true] { + let declaration = if derived { + "class D extends C; endclass D c;" + } else { + "C c;" + }; + let source = format!( + "module Top; class C; {visibility} {member} endclass {declaration} int result; initial begin c=new; result={access}; end endmodule" + ); + let error = analyze_source(&source, Path::new("visibility.sv")).unwrap_err(); + assert!( + matches!(&error, AnalyzerError::InaccessibleClassMember { owner, .. } if owner == "C"), + "{source}: {error}" + ); + } + } + } + for member in [ + "int x;", + "static int x;", + "function int x(); return 1; endfunction", + "static function int x(); return 1; endfunction", + ] { + let access = if member.contains("function") { + "x()" + } else { + "x" + }; + for prefix in ["", "this.", "super."] { + let source = format!( + "module Top; class C; local {member} endclass class D extends C; function int read(); return {prefix}{access}; endfunction endclass D c; int result; initial begin c=new; result=c.read(); end endmodule" + ); + let error = analyze_source(&source, Path::new("visibility.sv")).unwrap_err(); + assert!( + matches!(&error, AnalyzerError::InaccessibleClassMember { owner, .. } if owner == "C"), + "{source}: {error}" + ); + } + } + for access in ["x=2", "x++"] { + let source = format!( + "module Top; class C; local static int x; endclass class D extends C; function void write(); {access}; endfunction endclass D c; initial begin c=new; c.write(); end endmodule" + ); + let error = analyze_source(&source, Path::new("visibility.sv")).unwrap_err(); + assert!( + matches!(&error, AnalyzerError::InaccessibleClassMember { owner, .. } if owner == "C"), + "{source}: {error}" + ); + } + for access in ["c.x=2", "c.x++", "C::x=2"] { + let source = format!( + "module Top; class C; local static int x; endclass C c; initial begin c=new; {access}; end endmodule" + ); + let error = analyze_source(&source, Path::new("visibility.sv")).unwrap_err(); + assert!( + matches!(&error, AnalyzerError::InaccessibleClassMember { owner, .. } if owner == "C"), + "{source}: {error}" + ); + } +} + +#[test] +fn class_visibility_accepts_lexical_access_and_shadowing() { + for member in [ + "int x;", + "static int x;", + "function int x(); return 1; endfunction", + "static function int x(); return 1; endfunction", + ] { + let access = if member.contains("function") { + "x()" + } else { + "x" + }; + for visibility in ["local", "protected"] { + let source = format!( + "module Top; class C; {visibility} {member} function int read(C other); return other.{access}; endfunction endclass class D extends C; endclass D c; int result; initial begin c=new; result=c.read(c); end endmodule" + ); + analyze_source(&source, Path::new("visibility.sv")) + .unwrap_or_else(|e| panic!("{source}: {e}")); + } + for prefix in ["", "this.", "super."] { + let source = format!( + "module Top; class C; protected {member} endclass class D extends C; function int read(); return {prefix}{access}; endfunction endclass D c; int result; initial begin c=new; result=c.read(); end endmodule" + ); + analyze_source(&source, Path::new("visibility.sv")) + .unwrap_or_else(|e| panic!("{source}: {e}")); + } + } + for storage in ["", "static"] { + let source = format!( + "module Top; class C; local {storage} int x; endclass class D extends C; int x; function int read(int x); return x; endfunction function int own(); return x; endfunction endclass D c; int result; initial begin c=new; c.x=2; result=c.own(); end endmodule" + ); + analyze_source(&source, Path::new("visibility.sv")).unwrap(); + } +} + +#[test] +fn class_visibility_checks_constructors() { + for visibility in ["local", "protected"] { + let source = format!( + "module Top; class C; {visibility} function new(); endfunction endclass C c; initial c=new; endmodule" + ); + let error = analyze_source(&source, Path::new("visibility.sv")).unwrap_err(); + assert!( + matches!(&error, AnalyzerError::InaccessibleClassMember { owner, .. } if owner == "C"), + "{source}: {error}" + ); + let source = format!( + "module Top; class C; {visibility} function new(); endfunction endclass class D extends C; endclass D c; initial c=new; endmodule" + ); + let result = analyze_source(&source, Path::new("visibility.sv")); + if visibility == "local" { + assert!(matches!( + result.unwrap_err(), + AnalyzerError::InaccessibleClassMember { .. } + )); + } else { + result.unwrap(); + } + } +} diff --git a/crates/celox-test-suite/LIMITATIONS.md b/crates/celox-test-suite/LIMITATIONS.md index bc57d47a063..65deec8647c 100644 --- a/crates/celox-test-suite/LIMITATIONS.md +++ b/crates/celox-test-suite/LIMITATIONS.md @@ -465,7 +465,7 @@ including its positive check that changing the argument does wake the procedures The [standalone comparison](verification/repros/wildcard_task_sensitivity_verilator.json) records both executions. Only this Verilator case is excluded for this reason. -The SystemVerilog suite's exclusions are listed in [`verification/sv/limitations.json`](verification/sv/limitations.json), with the failures observed before them in [`verification/sv/limitations/`](verification/sv/limitations). A case is excluded for a tool only when the expected value follows IEEE 1800 and the tool either cannot run the design or disagrees with the standard; where the two tools disagree with each other, the entry says so. +The SystemVerilog suite's exclusions are listed in [`verification/sv/limitations.json`](verification/sv/limitations.json), with the failures observed before them in [`verification/sv/limitations/`](verification/sv/limitations). A case is excluded for a tool only when the expected value follows IEEE 1800 and the tool either cannot run the design or disagrees with the standard; where the two tools disagree with each other, the entry says so. A case tagged with an expectation stronger than SV (see the [tag table](README.md)) may also be excluded for a tool whose state model cannot produce it. The interface-array connection cases cover packed distribution, unpacked connections and array ports, and multidimensional instance arrays (IEEE @@ -541,6 +541,7 @@ four-state expectations; the assertions remain enabled on all Celox variants. | `sv_icarus_unpacked_array_patterns` | compile | icarus | 1 | Icarus 13.0 reports that an assignment pattern with unpacked array items assigned to a multidimensional unpacked array is not yet supported ("Procedural assignment of array or array slice"), so the run cannot count it as a language rejection. The design is invalid (IEEE 1800-2023 7.6, 10.8). | | `sv_icarus_display_field_width` | execute | icarus | 1 | Icarus 13.0 zero-pads a value wider than an explicit field width of %h or %o to the argument's full width (%3h of 32'h1234 prints 00001234); IEEE 1800-2023 21.2.1.2 expands the field to the value without leading zeros (1234). Verilator agrees with the expected value. | | `sv_verilator_constant_unknown_bits` | execute | verilator | 1 | Verilator 5.052 is two-state: unknown bits in constant system function arguments ($onehot(2'bx1)) are not kept unknown, so a generate condition differs from IEEE 1800-2023 20.9. Icarus agrees with the expected values. | +| `sv_icarus_two_state_time_zero_settle` | execute | icarus | 2 | Icarus 13.0 simulates the emitted design in four-state SV, where `always @*` and a sensitivity-list process wait for a change (IEEE 1800-2023 9.2.2.2, 9.4.2), so an output whose inputs never change stays X. The case's two-state oracle follows Verilator 5.052, which runs these processes once at time zero after the initial blocks, as Celox's two-state mode does; a [standalone probe](verification/repros/sv_two_state_time_zero_settle.json) prints `1 ffff 1` in Verilator and `x xxxx x` in Icarus. | | `sv_verilator_generate_case_unknown_label` | compile | verilator | 1 | Verilator 5.052 rejects an x or ? digit in a case-generate label ("no such thing as generate casez"). Icarus passes the case. | | `sv_verilator_self_determined_index` | execute | verilator | 1 | Verilator 5.052 does not wrap a self-determined index expression (2'd3 + 2'd1) to its width before selecting; IEEE 1800-2023 11.5.1 and 11.6.1 make the index 0. Icarus agrees with the expected value. | | `sv_verilator_short_circuit_calls` | execute | verilator | 1 | Verilator 5.052 runs a function call in the right operand of && in a select index when the left operand is false, so its output argument is written; IEEE 1800-2023 11.4.7 does not evaluate that operand. Icarus cannot compile the design (sv_icarus_function_outputs). | diff --git a/crates/celox-test-suite/README.md b/crates/celox-test-suite/README.md index 8931a473d01..0cd2495c6b6 100644 --- a/crates/celox-test-suite/README.md +++ b/crates/celox-test-suite/README.md @@ -177,6 +177,7 @@ case still runs its original assertions by default. | `eager_assertion_messages` | Veryl `$assert` / `$assert_continue` message argument effects occur even on success; these calls have no standard SV counterpart | | `two_state_zero_division` | The suite's two-state model returns zero for division/remainder by zero, including four-state `logic` destinations in emitted SV (11.3.4, 11.4.3) | | `two_state_initialization` | An explicit check of zero-initialized storage even for emitted four-state `logic` (6.8, Table 6-7) | +| `two_state_time_zero_settle` | Two-state `always @*` and sensitivity-list processes run once at time zero, after the initial blocks, as Verilator settles them, whereas SV has them wait for a change (9.2.2.2, 9.4.2) | The initial review tags 21 cases; cases may carry multiple tags. Matching a word such as `source_order` in a case name is insufficient: the two output diff --git a/crates/celox-test-suite/src/lib.rs b/crates/celox-test-suite/src/lib.rs index 4ff79bb0570..b9c5aa4dfce 100644 --- a/crates/celox-test-suite/src/lib.rs +++ b/crates/celox-test-suite/src/lib.rs @@ -89,6 +89,7 @@ pub enum TestTag { EagerAssertionMessages, TwoStateZeroDivision, TwoStateInitialization, + TwoStateTimeZeroSettle, } impl TestTag { @@ -101,6 +102,7 @@ impl TestTag { Self::EagerAssertionMessages => "eager_assertion_messages", Self::TwoStateZeroDivision => "two_state_zero_division", Self::TwoStateInitialization => "two_state_initialization", + Self::TwoStateTimeZeroSettle => "two_state_time_zero_settle", } } @@ -125,6 +127,9 @@ impl TestTag { Self::TwoStateInitialization => { "Explicitly requires the suite's zero-initialized two-state storage even for emitted four-state logic; SV default initialization depends on the declared type (IEEE 1800-2023 6.8, Table 6-7)." } + Self::TwoStateTimeZeroSettle => { + "Requires two-state `always @*` and sensitivity-list processes to run once at time zero, after the initial blocks, as Verilator settles them; SV has them wait for a change (IEEE 1800-2023 9.2.2.2, 9.4.2)." + } } } } diff --git a/crates/celox-test-suite/src/script/ast.rs b/crates/celox-test-suite/src/script/ast.rs index 820ef77050c..ebb58447d42 100644 --- a/crates/celox-test-suite/src/script/ast.rs +++ b/crates/celox-test-suite/src/script/ast.rs @@ -384,6 +384,7 @@ fn tag(name: &str, pos: Pos) -> Result { "eager_assertion_messages" => TestTag::EagerAssertionMessages, "two_state_zero_division" => TestTag::TwoStateZeroDivision, "two_state_initialization" => TestTag::TwoStateInitialization, + "two_state_time_zero_settle" => TestTag::TwoStateTimeZeroSettle, _ => return error(pos, format!("unknown tag `{name}`")), }) } diff --git a/crates/celox-test-suite/src/sv/cases/always_comb.vtest b/crates/celox-test-suite/src/sv/cases/always_comb.vtest index fd365ba0700..1c65de34d59 100644 --- a/crates/celox-test-suite/src/sv/cases/always_comb.vtest +++ b/crates/celox-test-suite/src/sv/cases/always_comb.vtest @@ -105,3 +105,66 @@ (modify (set a 10)) (assert_eq y 15) (assert_eq z 5)) + +; In two-state mode, `always @*` and a sensitivity list run once at time +; zero, after the initial blocks, as Verilator settles them: C906's memory +; enable would otherwise start as a real 0, a write enable (#2021). IEEE +; 1800-2023 9.2.2.2 has them wait for a change, which four-state mode keeps. +(case two_state_sensitivity_lists_run_at_time_zero + (tags two_state_time_zero_settle) + (source "time_zero.sv" #" + module Top; + localparam logic [1:0] READ = 2'd1; + logic [1:0] cur_state; + logic wvalid, wready; + logic [15:0] wstrb; + logic cen; + logic [15:0] wen; + logic [3:0] st = 4'd2; + logic hit; + always @(cur_state or wvalid or wready or wstrb[15:0]) begin + if (cur_state == READ) begin + cen = 1'b0; + wen = 16'hffff; + end else if (wvalid && wready) begin + cen = 1'b0; + wen = ~wstrb; + end else begin + cen = 1'b1; + wen = 16'hffff; + end + end + always @* hit = (st == 4'd2); + initial begin + #1 $display("%b %h %b", cen, wen, hit); + $finish; + end + endmodule + "#) + (top Top) + (run_to_finish) + (expect_output "1 ffff 1\n")) + +; Two-state mode also runs a sensitivity list that does not name exactly the +; reads of its statement once at time zero, after the initial blocks, and then +; waits at it, as Verilator settles it (#2026): `y` lists a variable it does +; not read, and `z` reads `b` without listing it. +(case two_state_other_sensitivity_lists_run_at_time_zero + (tags two_state_time_zero_settle) + (source "time_zero_lists.sv" #" + module Top; + logic [3:0] a, b; + logic [3:0] y, z; + always @(a or b) y = a + 4'd1; + always @(a) z = a + b + 4'd2; + initial begin + b = 4'd5; + #1 $display("%0d %0d", y, z); + $finish; + end + endmodule + "#) + (top Top) + (run_to_finish) + (expect_output "1 7\n")) + diff --git a/crates/celox-test-suite/src/sv/cases/latch.vtest b/crates/celox-test-suite/src/sv/cases/latch.vtest index b57e6242195..19eb1cf2573 100644 --- a/crates/celox-test-suite/src/sv/cases/latch.vtest +++ b/crates/celox-test-suite/src/sv/cases/latch.vtest @@ -105,6 +105,8 @@ endmodule (top Top) (run_to_finish)) +; `always @*` waits for a change in four-state mode only; two-state mode runs +; it at time zero (#2021). (case classic_star_declaration_startup (source "declaration_startup.sv" #" module Top; @@ -120,6 +122,7 @@ module Top; endmodule "#) (top Top) + (four_state) (run_to_finish)) (case classic_star_initial_startup @@ -178,6 +181,8 @@ endmodule (top Top) (run_to_finish)) +; `always @*` waits for a change in four-state mode only; two-state mode runs +; it at time zero (#2021). (case same_activation_change_return (source "change_return.sv" #" module Top; @@ -201,8 +206,11 @@ module Top; endmodule "#) (top Top) + (four_state) (run_to_finish)) +; `always @*` waits for a change in four-state mode only; two-state mode runs +; it at time zero (#2021). (case hierarchy_same_activation_change_return (source "hierarchy_change_return.sv" #" module Latch(input wire a, output wire [7:0] q); @@ -224,6 +232,7 @@ module Top(output wire [7:0] q); endmodule "#) (top Top) + (four_state) (run_to_finish)) (case star_select_sensitivity @@ -245,6 +254,8 @@ endmodule (top Top) (run_to_finish)) +; `always @*` waits for a change in four-state mode only; two-state mode runs +; it at time zero (#2021). (case star_complete_declaration_startup (source "star_complete_declaration_startup.sv" #" module Top; @@ -260,6 +271,7 @@ module Top; endmodule "#) (top Top) + (four_state) (run_to_finish)) (case task_call_sensitivity diff --git a/crates/celox-test-suite/src/sv/cases/program.vtest b/crates/celox-test-suite/src/sv/cases/program.vtest index 033758f52d1..8a6bf5410dd 100644 --- a/crates/celox-test-suite/src/sv/cases/program.vtest +++ b/crates/celox-test-suite/src/sv/cases/program.vtest @@ -35,6 +35,8 @@ ; A program's nonblocking assignment updates in the Re-NBA region, after the ; design's NBA region; the design processes the update wakes run in the ; active region set that follows. +; Four-state, so that `always @(r)` waits for a change; two-state mode would +; also run it once at time zero (#2026). (case program_nonblocking_updates_follow_design_updates (source "program_renba.sv" #" module Top; @@ -58,6 +60,7 @@ endprogram "#) (top Top) + (four_state) (run_to_finish) (expect_output "design sees r=1 count=0\nprogram count=1 r=1\ndesign sees r=11 count=1\nprogram count=2 r=11\ndesign sees r=12 count=2\n")) diff --git a/crates/celox-test-suite/src/sv/cases/timing.vtest b/crates/celox-test-suite/src/sv/cases/timing.vtest index 04d74494fac..5249c27248d 100644 --- a/crates/celox-test-suite/src/sv/cases/timing.vtest +++ b/crates/celox-test-suite/src/sv/cases/timing.vtest @@ -171,8 +171,9 @@ (assert_eq y 9)) (case explicit_list_of_every_read_waits_for_a_change - ; Like `always @*`, the list waits before its first run: neither the - ; declaration initializers nor the write of `y` wake it (9.4.2). + ; In four-state mode, like `always @*`, the list waits before its first + ; run: neither the declaration initializers nor the write of `y` wake it + ; (9.4.2). Two-state mode runs it at time zero (#2021). (source "level_list.sv" #" module Top(output logic [7:0] y); logic [7:0] a = 8'd0; @@ -187,6 +188,7 @@ endmodule "#) (top Top) + (four_state) (run_until 1) (assert_eq y 1) (run_until 3) @@ -217,6 +219,8 @@ (run_to_finish) (assert_eq y 9)) +; In four-state mode the list waits for a change; two-state mode also runs +; it once at time zero (#2026). (case list_with_an_extra_signal_wakes_on_it (source "extra_signal.sv" #" module Top; @@ -232,6 +236,7 @@ endmodule "#) (top Top) + (four_state) (run_to_finish) (expect_output "sum=3\nsum=3\n")) diff --git a/crates/celox-test-suite/verification/repros/sv_two_state_time_zero_settle.json b/crates/celox-test-suite/verification/repros/sv_two_state_time_zero_settle.json new file mode 100644 index 00000000000..bfe14ec8b71 --- /dev/null +++ b/crates/celox-test-suite/verification/repros/sv_two_state_time_zero_settle.json @@ -0,0 +1,52 @@ +{ + "standard": "IEEE 1800-2023 9.2.2.2 and 9.4.2", + "expected": "In four-state SV, `always @*` and a sensitivity-list process wait at their event control until an input changes, so an output whose inputs never change stays X. The suite case's two-state oracle follows Verilator, which runs these processes once at time zero after the initial blocks.", + "probes": [ + { + "name": "time_zero_settle", + "note": "The suite case always_comb::two_state_sensitivity_lists_run_at_time_zero.", + "source": "module Top;\n localparam logic [1:0] READ = 2'd1;\n logic [1:0] cur_state;\n logic wvalid, wready;\n logic [15:0] wstrb;\n logic cen;\n logic [15:0] wen;\n logic [3:0] st = 4'd2;\n logic hit;\n always @(cur_state or wvalid or wready or wstrb[15:0]) begin\n if (cur_state == READ) begin\n cen = 1'b0;\n wen = 16'hffff;\n end else if (wvalid && wready) begin\n cen = 1'b0;\n wen = ~wstrb;\n end else begin\n cen = 1'b1;\n wen = 16'hffff;\n end\n end\n always @* hit = (st == 4'd2);\n initial begin\n #1 $display(\"%b %h %b\", cen, wen, hit);\n $finish;\n end\nendmodule\n", + "verilator_compile": { + "command": "verilator --binary --timing -Wno-fatal --top-module Top --Mdir /obj /probe.sv", + "exit_code": 0 + }, + "verilator_run": { + "command": "/obj/VTop", + "exit_code": 0, + "output": "1 ffff 1\n- /probe.sv:25: Verilog $finish\n- S i m u l a t i o n R e p o r t: Verilator 5.052 2026-09-05\n- Verilator: $finish at 1ps; walltime 0.000 s; speed 36.075 ns/s\n- Verilator: cpu 0.000 s on 1 threads; allocated 4 MB\n" + }, + "icarus_compile": { + "command": "iverilog -g2012 -s Top -o /probe.vvp /probe.sv", + "exit_code": 0 + }, + "icarus_run": { + "command": "vvp /probe.vvp", + "exit_code": 0, + "output": "x xxxx x\n/probe.sv:25: $finish called at 1 (1s)\n" + } + }, + { + "name": "other_lists", + "note": "The suite case always_comb::two_state_other_sensitivity_lists_run_at_time_zero: lists that do not name exactly the reads of their statement.", + "source": "module Top;\n logic [3:0] a, b;\n logic [3:0] y, z;\n always @(a or b) y = a + 4'd1;\n always @(a) z = a + b + 4'd2;\n initial begin\n b = 4'd5;\n #1 $display(\"%0d %0d\", y, z);\n $finish;\n end\nendmodule\n", + "verilator_compile": { + "command": "verilator --binary --timing -Wno-fatal --top-module Top --Mdir /obj /probe.sv", + "exit_code": 0 + }, + "verilator_run": { + "command": "/obj/VTop", + "exit_code": 0, + "output": "1 7\n- /probe.sv:9: Verilog $finish\n- S i m u l a t i o n R e p o r t: Verilator 5.052 2026-09-05\n- Verilator: $finish at 1ps; walltime 0.000 s; speed 37.509 ns/s\n- Verilator: cpu 0.000 s on 1 threads; allocated 4 MB\n" + }, + "icarus_compile": { + "command": "iverilog -g2012 -s Top -o /probe.vvp /probe.sv", + "exit_code": 0 + }, + "icarus_run": { + "command": "vvp /probe.vvp", + "exit_code": 0, + "output": "x x\n/probe.sv:9: $finish called at 1 (1s)\n" + } + } + ] +} diff --git a/crates/celox-test-suite/verification/sv/icarus/always_comb.json b/crates/celox-test-suite/verification/sv/icarus/always_comb.json index d1fc38dfad0..0128850f1b4 100644 --- a/crates/celox-test-suite/verification/sv/icarus/always_comb.json +++ b/crates/celox-test-suite/verification/sv/icarus/always_comb.json @@ -43,6 +43,60 @@ "stronger_than_sv": false, "tag_reasons": {}, "tags": [] + }, + { + "category": "Combinational", + "detail": "Icarus 13.0 simulates the emitted design in four-state SV, where `always @*` and a sensitivity-list process wait for a change (IEEE 1800-2023 9.2.2.2, 9.4.2), so an output whose inputs never change stays X. The case's two-state oracle follows Verilator 5.052, which runs these processes once at time zero after the initial blocks, as Celox's two-state mode does; a standalone probe prints `1 ffff 1` in Verilator and `x xxxx x` in Icarus.", + "expectation": "Simulation", + "known_issue": { + "category": "simulator_two_state", + "evidence": [ + "verification/repros/sv_two_state_time_zero_settle.json", + "LIMITATIONS.md#systemverilog-suite" + ], + "id": "sv_icarus_two_state_time_zero_settle", + "observed_version": "Icarus 13.0 / Verilator 5.052", + "phase": "execute", + "reason": "Icarus 13.0 simulates the emitted design in four-state SV, where `always @*` and a sensitivity-list process wait for a change (IEEE 1800-2023 9.2.2.2, 9.4.2), so an output whose inputs never change stays X. The case's two-state oracle follows Verilator 5.052, which runs these processes once at time zero after the initial blocks, as Celox's two-state mode does; a standalone probe prints `1 ffff 1` in Verilator and `x xxxx x` in Icarus.", + "upstream": [] + }, + "name": "always_comb::two_state_other_sensitivity_lists_run_at_time_zero", + "phase": "skip", + "status": "ignored", + "stronger_than_sv": true, + "tag_reasons": { + "two_state_time_zero_settle": "Requires two-state `always @*` and sensitivity-list processes to run once at time zero, after the initial blocks, as Verilator settles them; SV has them wait for a change (IEEE 1800-2023 9.2.2.2, 9.4.2)." + }, + "tags": [ + "two_state_time_zero_settle" + ] + }, + { + "category": "Combinational", + "detail": "Icarus 13.0 simulates the emitted design in four-state SV, where `always @*` and a sensitivity-list process wait for a change (IEEE 1800-2023 9.2.2.2, 9.4.2), so an output whose inputs never change stays X. The case's two-state oracle follows Verilator 5.052, which runs these processes once at time zero after the initial blocks, as Celox's two-state mode does; a standalone probe prints `1 ffff 1` in Verilator and `x xxxx x` in Icarus.", + "expectation": "Simulation", + "known_issue": { + "category": "simulator_two_state", + "evidence": [ + "verification/repros/sv_two_state_time_zero_settle.json", + "LIMITATIONS.md#systemverilog-suite" + ], + "id": "sv_icarus_two_state_time_zero_settle", + "observed_version": "Icarus 13.0 / Verilator 5.052", + "phase": "execute", + "reason": "Icarus 13.0 simulates the emitted design in four-state SV, where `always @*` and a sensitivity-list process wait for a change (IEEE 1800-2023 9.2.2.2, 9.4.2), so an output whose inputs never change stays X. The case's two-state oracle follows Verilator 5.052, which runs these processes once at time zero after the initial blocks, as Celox's two-state mode does; a standalone probe prints `1 ffff 1` in Verilator and `x xxxx x` in Icarus.", + "upstream": [] + }, + "name": "always_comb::two_state_sensitivity_lists_run_at_time_zero", + "phase": "skip", + "status": "ignored", + "stronger_than_sv": true, + "tag_reasons": { + "two_state_time_zero_settle": "Requires two-state `always @*` and sensitivity-list processes to run once at time zero, after the initial blocks, as Verilator settles them; SV has them wait for a change (IEEE 1800-2023 9.2.2.2, 9.4.2)." + }, + "tags": [ + "two_state_time_zero_settle" + ] } ] } diff --git a/crates/celox-test-suite/verification/sv/limitations.json b/crates/celox-test-suite/verification/sv/limitations.json index 3f5e9c99ed6..1a3d03d220e 100644 --- a/crates/celox-test-suite/verification/sv/limitations.json +++ b/crates/celox-test-suite/verification/sv/limitations.json @@ -552,6 +552,24 @@ ] } }, + { + "id": "sv_icarus_two_state_time_zero_settle", + "category": "simulator_two_state", + "phase": "execute", + "observed_version": "Icarus 13.0 / Verilator 5.052", + "reason": "Icarus 13.0 simulates the emitted design in four-state SV, where `always @*` and a sensitivity-list process wait for a change (IEEE 1800-2023 9.2.2.2, 9.4.2), so an output whose inputs never change stays X. The case's two-state oracle follows Verilator 5.052, which runs these processes once at time zero after the initial blocks, as Celox's two-state mode does; a standalone probe prints `1 ffff 1` in Verilator and `x xxxx x` in Icarus.", + "upstream": [], + "evidence": [ + "verification/repros/sv_two_state_time_zero_settle.json", + "LIMITATIONS.md#systemverilog-suite" + ], + "cases": { + "icarus": [ + "always_comb::two_state_sensitivity_lists_run_at_time_zero", + "always_comb::two_state_other_sensitivity_lists_run_at_time_zero" + ] + } + }, { "id": "sv_verilator_generate_case_unknown_label", "category": "simulator_compile_limitation", diff --git a/crates/celox/tests/frontends/systemverilog/always_comb.rs b/crates/celox/tests/frontends/systemverilog/always_comb.rs index 217da03437b..010bffac2c0 100644 --- a/crates/celox/tests/frontends/systemverilog/always_comb.rs +++ b/crates/celox/tests/frontends/systemverilog/always_comb.rs @@ -27,3 +27,15 @@ sv_backends! { @case "always_comb::explicit_list_of_every_read_settles_like_a_wildcard"; } } + +sv_backends! { + fn two_state_sensitivity_lists_run_at_time_zero(sim) { + @case "always_comb::two_state_sensitivity_lists_run_at_time_zero"; + } +} + +sv_backends! { + fn two_state_other_sensitivity_lists_run_at_time_zero(sim) { + @case "always_comb::two_state_other_sensitivity_lists_run_at_time_zero"; + } +} diff --git a/crates/celox/tests/frontends/systemverilog/latch.rs b/crates/celox/tests/frontends/systemverilog/latch.rs index cc5b7d756b5..54629006c10 100644 --- a/crates/celox/tests/frontends/systemverilog/latch.rs +++ b/crates/celox/tests/frontends/systemverilog/latch.rs @@ -228,35 +228,30 @@ fn latch_policy_preserves_compilation_diagnostic_overrides() { } #[test] -fn change_return_activation_in_both_state_modes_at_o0_and_o2() { +fn change_return_activation_at_o0_and_o2() { for name in [ "latch::same_activation_change_return", "latch::hierarchy_same_activation_change_return", ] { let case = celox_test_suite::sv::case(name).unwrap(); let design = case.design(); - for four_state in [false, true] { - for level in [celox::OptLevel::O0, celox::OptLevel::O2] { - let mut sim = celox::Simulation::from_sv_sources( - design - .sources - .iter() - .map(|source| (source.text.as_str(), source.path.as_path())) - .collect(), - "Top", - ) - .four_state(four_state) - .opt_level(level) - .build_interpreter() - .unwrap(); - sim.run_until(10_000).unwrap_or_else(|error| { - panic!("{name}, four_state={four_state}, {level:?}: {error}") - }); - assert!( - sim.is_finished(), - "{name}, four_state={four_state}, {level:?}" - ); - } + // The cases are four-state: two-state mode runs `always @*` at time zero. + for level in [celox::OptLevel::O0, celox::OptLevel::O2] { + let mut sim = celox::Simulation::from_sv_sources( + design + .sources + .iter() + .map(|source| (source.text.as_str(), source.path.as_path())) + .collect(), + "Top", + ) + .four_state(true) + .opt_level(level) + .build_interpreter() + .unwrap(); + sim.run_until(10_000) + .unwrap_or_else(|error| panic!("{name}, {level:?}: {error}")); + assert!(sim.is_finished(), "{name}, {level:?}"); } } } diff --git a/crates/celox/tests/frontends/systemverilog/system_functions.rs b/crates/celox/tests/frontends/systemverilog/system_functions.rs index e56ff78d97a..597c2b2438f 100644 --- a/crates/celox/tests/frontends/systemverilog/system_functions.rs +++ b/crates/celox/tests/frontends/systemverilog/system_functions.rs @@ -280,21 +280,24 @@ sv_backends! { @build Simulator::from_sv_sources(vec![(source, Path::new("random_sensitivity.sv"))], "Top").four_state(false); let a = sim.signal("a"); let b = sim.signal("b"); + // Two-state mode runs `always @*` once at time zero, like always_comb. let first = sim.get(a); assert_ne!(first, 0u8.into()); - assert_eq!(sim.get(b), 0u8.into()); + let first_b = sim.get(b); + assert_ne!(first_b, 0u8.into()); let initial_draw = sim.get(sim.signal("initial_draw")); assert_ne!(initial_draw, 0u8.into()); - assert_eq!(sim.get(sim.signal("star_draw")), 0u8.into()); + let star_draw = sim.get(sim.signal("star_draw")); + assert_ne!(star_draw, 0u8.into()); let global_input = sim.signal("global_input"); sim.modify(|io| io.set(global_input, 1u8)).unwrap(); assert_ne!(sim.get(a), first); - assert_eq!(sim.get(b), 0u8.into()); + assert_eq!(sim.get(b), first_b); let trigger = sim.signal("trigger"); sim.modify(|io| io.set(trigger, 1u8)).unwrap(); - assert_ne!(sim.get(b), 0u8.into()); + assert_ne!(sim.get(b), first_b); assert_eq!(sim.get(sim.signal("initial_draw")), initial_draw); - assert_eq!(sim.get(sim.signal("star_draw")), 0u8.into()); + assert_eq!(sim.get(sim.signal("star_draw")), star_draw); } fn urandom_select_keeps_distinct_source_calls(sim) { diff --git a/crates/celox/tests/sv_declaration_startup.rs b/crates/celox/tests/sv_declaration_startup.rs index 6bb88b8f387..2a0558ac244 100644 --- a/crates/celox/tests/sv_declaration_startup.rs +++ b/crates/celox/tests/sv_declaration_startup.rs @@ -5,6 +5,9 @@ use std::path::Path; // IEEE 1800-2023 6.8 initializes static declarations before initial/always // procedures, including initializers that require runtime evaluation. +// `always @*` waits for a change only in four-state mode; in two-state mode it +// runs once at time zero (#2021), so the tests of its startup guard build +// four-state simulations. const RANDOM_DECLARATION: &str = r#" module Top; int a = $urandom | 1; @@ -247,17 +250,15 @@ macro_rules! declaration_backend { #[test] fn runtime_declaration_does_not_wake_wildcard() { - for four_state in [false, true] { - finishes( - Simulation::from_sv_sources( - vec![(RANDOM_DECLARATION, Path::new("runtime_declaration.sv"))], - "Top", - ) - .four_state(four_state) - .$build() - .unwrap(), - ); - } + finishes( + Simulation::from_sv_sources( + vec![(RANDOM_DECLARATION, Path::new("runtime_declaration.sv"))], + "Top", + ) + .four_state(true) + .$build() + .unwrap(), + ); } #[test] @@ -317,35 +318,31 @@ macro_rules! declaration_backend { #[test] fn host_request_declaration_finishes_before_wildcard_registration() { - for four_state in [false, true] { - finishes( - Simulation::from_sv_sources( - vec![(HOST_DECLARATION, Path::new("declaration_plusargs.sv"))], - "Top", - ) - .four_state(four_state) - .plusargs(["+on"]) - .$build() - .unwrap(), - ); - } + finishes( + Simulation::from_sv_sources( + vec![(HOST_DECLARATION, Path::new("declaration_plusargs.sv"))], + "Top", + ) + .four_state(true) + .plusargs(["+on"]) + .$build() + .unwrap(), + ); } #[test] fn host_reads_and_eval_do_not_activate_a_stopped_declaration() { - for four_state in [false, true] { - stopped_declaration_keeps_comb_inert( - Simulation::from_sv_sources( - vec![(STOPPED_DECLARATION, Path::new("declaration_stop.sv"))], - "Top", - ) - .four_state(four_state) - .live_signal(Vec::new(), vec!["a".into()]) - .live_signal(Vec::new(), vec!["q".into()]) - .$build() - .unwrap(), - ); - } + stopped_declaration_keeps_comb_inert( + Simulation::from_sv_sources( + vec![(STOPPED_DECLARATION, Path::new("declaration_stop.sv"))], + "Top", + ) + .four_state(true) + .live_signal(Vec::new(), vec!["a".into()]) + .live_signal(Vec::new(), vec!["q".into()]) + .$build() + .unwrap(), + ); } #[test] @@ -391,19 +388,17 @@ macro_rules! declaration_backend { #[test] fn checkpoint_restores_the_armed_startup_guard() { - for four_state in [false, true] { - restored_guard_remains_inert( - Simulation::from_sv_sources( - vec![(HOST_WRITES, Path::new("declaration_checkpoint.sv"))], - "Top", - ) - .four_state(four_state) - .live_signal(Vec::new(), vec!["a".into()]) - .live_signal(Vec::new(), vec!["q".into()]) - .$build() - .unwrap(), - ); - } + restored_guard_remains_inert( + Simulation::from_sv_sources( + vec![(HOST_WRITES, Path::new("declaration_checkpoint.sv"))], + "Top", + ) + .four_state(true) + .live_signal(Vec::new(), vec!["a".into()]) + .live_signal(Vec::new(), vec!["q".into()]) + .$build() + .unwrap(), + ); } } }; @@ -425,18 +420,16 @@ declaration_backend!(wasm, build_wasm); ))] fn native_runtime_declaration_startup_at_o0_and_o2() { for level in [celox::OptLevel::O0, celox::OptLevel::O2] { - for four_state in [false, true] { - finishes( - Simulation::from_sv_sources( - vec![(RANDOM_DECLARATION, Path::new("declaration_opt_level.sv"))], - "Top", - ) - .four_state(four_state) - .opt_level(level) - .build_native() - .unwrap(), - ); - } + finishes( + Simulation::from_sv_sources( + vec![(RANDOM_DECLARATION, Path::new("declaration_opt_level.sv"))], + "Top", + ) + .four_state(true) + .opt_level(level) + .build_native() + .unwrap(), + ); } }