Skip to content
Closed
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
2 changes: 1 addition & 1 deletion benchmarks/taxi/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cocotb-bus==0.3.0
cocotbext-axi==0.1.28
cocotbext-eth==0.1.28
find_libpython==0.5.1
pytest==9.0.3
pytest==9.2.0
scapy==2.8.0
iniconfig==2.3.1
packaging==26.3
Expand Down
9 changes: 9 additions & 0 deletions crates/celox-sv-analyzer/src/ast/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,15 @@ fn validate_scope(
if !selected(data.tokens) {
continue;
}
// A structure of a class may name the typedefs of the class and its
// bases, which only the class scope resolves; the class binds it.
if native
.classes
.iter()
.any(|class| contains(class.tokens, data.tokens))
{
continue;
}
if matches!(data.kind, DataTypeKind::Struct { .. })
&& type_binding::bind(id, syntax_tree, indexed_dimensions)?.is_none()
{
Expand Down
31 changes: 31 additions & 0 deletions crates/celox/tests/frontends/systemverilog/unpacked_structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,37 @@ sv_backends! {
let value = sim.signal("value");
assert_eq!(sim.get(value), BigUint::from(1231u16));
}
fn structure_members_of_class_typedefs(sim) {
@setup {
let source = r#"module Top(output int value);
class Base;
typedef enum { NEVER, STARTED, FINISHED } rs_e;
endclass
class C extends Base;
typedef bit [3:0] nibble_t;
typedef struct { rs_e state; nibble_t n; bit ret_val; } st_t;
st_t m[string];
function int f();
st_t s;
s.state = rs_e'(2);
s.n = 4'h9;
s.ret_val = 1;
m["a"] = s;
return m["a"].state * 100 + m["a"].n * 10 + m["a"].ret_val;
endfunction
endclass
initial begin
C c;
c = new;
value = c.f();
end
endmodule"#;
}
@build celox::Simulation::from_sv_sources(vec![(source, Path::new("struct.sv"))], "Top");
sim.run_until(0).unwrap();
let value = sim.signal("value");
assert_eq!(sim.get(value), BigUint::from(291u16));
}
fn structure_defaults_descend_to_members_of_their_type(sim) {
@setup {
let source = r#"module Top(output int value);
Expand Down
Loading