Skip to content

feat(sv): support unpacked structures as dynamic container elements - #2422

Open
tignear wants to merge 1 commit into
stack/tignear/feat/sv-uvm-unpacked-structs/support-class-props-unpacked-structure-type--8d7ebe18from
stack/tignear/feat/sv-uvm-unpacked-structs/support-unpacked-structures-dynamic-container--ac820f46
Open

tignear wants to merge 1 commit into
stack/tignear/feat/sv-uvm-unpacked-structs/support-class-props-unpacked-structure-type--8d7ebe18from
stack/tignear/feat/sv-uvm-unpacked-structs/support-unpacked-structures-dynamic-container--ac820f46

Conversation

@tignear

@tignear tignear commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Queues, dynamic arrays and associative arrays of an unpacked structure
type were rejected. A structure of at most 64 bits whose members are all
2-state or all 4-state and hold no handle is kept as its flat value, so
the container's default element is the structure's default. Any other
structure is held as an immutable heap record: ObjectOp::Box builds a
record from the flat value on push, insert or an assignment, and
ObjectOp::Unbox reads it back. Each leaf is a record field, so the
collector traces string and handle members through the record's handle
list, and 4-state members keep their X/Z bits. Record fields are
nullable: the new OBJECT_LOAD_NULLABLE heap operation reads a null
record as zeros without a fault, which is the default structure for a
missing associative entry or a new dynamic array element. Records are not
seeded, so they do not draw from the process RNG.

e.m reads a member of an element q[i], aa[k] or a popped element
directly from the record or the flat value, including a handle member's
properties (q[0].orig.m_type.n). Patterns, typed patterns and values of
the structure type initialize elements. Comparing containers of records
and sorting structures without with are rejected, as is writing a
member of an element.

Assignment patterns passed to a method argument now receive the formal's
shape, which method calls taking a structure need.

Depends-On: #2419

@tignear

tignear commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 feat(sv): support unpacked structures #2415
2 feat(sv): support class properties of unpacked structure type #2419
3 feat(sv): support unpacked structures as dynamic container elements #2422 👈
4 feat(sv): support nested dynamic containers and class handle keys #2424

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T16:20:44.101431Z 15e6872 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 79d36ee85f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/celox-sv-analyzer/src/ast/containers.rs Outdated
Comment thread crates/celox-sv-analyzer/src/ast/expression_binding/direct.rs
@mergify

mergify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@tignear
tignear force-pushed the stack/tignear/feat/sv-uvm-unpacked-structs/support-class-props-unpacked-structure-type--8d7ebe18 branch from c3f54de to c71b11a Compare October 28, 2026 12:49
@tignear
tignear force-pushed the stack/tignear/feat/sv-uvm-unpacked-structs/support-unpacked-structures-dynamic-container--ac820f46 branch from 79d36ee to 437b350 Compare October 28, 2026 12:49
@tignear

tignear commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial 79d36ee 2026-10-28 12:46 UTC
2 content 79d36ee → 437b350 2026-10-28 12:46 UTC
3 content 437b350 → 53dedc6 2026-10-28 13:51 UTC
4 content 53dedc6 → 15e6872 Rebased onto master (method arguments check ref actuals and take formal shapes). Review fix: reject multi-leaf member reads of elements with side-effecting indices. 2026-10-28 16:16 UTC

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 437b350222

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/celox-sv-analyzer/src/ast/expression_binding/direct.rs
Comment thread crates/celox-sv-analyzer/src/ast/unpacked_structs.rs
Comment thread crates/celox-sv-analyzer/src/ast/containers.rs
Comment thread crates/celox-sv-analyzer/src/ast/unpacked_structs.rs
@tignear
tignear force-pushed the stack/tignear/feat/sv-uvm-unpacked-structs/support-class-props-unpacked-structure-type--8d7ebe18 branch from c71b11a to ecce9b8 Compare October 28, 2026 13:52
@tignear
tignear force-pushed the stack/tignear/feat/sv-uvm-unpacked-structs/support-unpacked-structures-dynamic-container--ac820f46 branch from 437b350 to 53dedc6 Compare October 28, 2026 13:52

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 53dedc6898

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/celox-sv-analyzer/src/ast/containers.rs Outdated
Queues, dynamic arrays and associative arrays of an unpacked structure
type were rejected. A structure of at most 64 bits whose members are all
2-state or all 4-state and hold no handle is kept as its flat value, so
the container's default element is the structure's default. Any other
structure is held as an immutable heap record: `ObjectOp::Box` builds a
record from the flat value on `push`, `insert` or an assignment, and
`ObjectOp::Unbox` reads it back. Each leaf is a record field, so the
collector traces string and handle members through the record's handle
list, and 4-state members keep their X/Z bits. Record fields are
`nullable`: the new `OBJECT_LOAD_NULLABLE` heap operation reads a null
record as zeros without a fault, which is the default structure for a
missing associative entry or a new dynamic array element. Records are not
seeded, so they do not draw from the process RNG.

`e.m` reads a member of an element `q[i]`, `aa[k]` or a popped element
directly from the record or the flat value, including a handle member's
properties (`q[0].orig.m_type.n`). Patterns, typed patterns and values of
the structure type initialize elements. Comparing containers of records
and sorting structures without `with` are rejected, as is writing a
member of an element.

Assignment patterns passed to a method argument now receive the formal's
shape, which method calls taking a structure need.

Change-Id: Iac820f46cbee8d792f4b0fbde28baccdd54ecf31
@tignear
tignear force-pushed the stack/tignear/feat/sv-uvm-unpacked-structs/support-class-props-unpacked-structure-type--8d7ebe18 branch from ecce9b8 to 9c93687 Compare October 28, 2026 16:17
@tignear
tignear force-pushed the stack/tignear/feat/sv-uvm-unpacked-structs/support-unpacked-structures-dynamic-container--ac820f46 branch from 53dedc6 to 15e6872 Compare October 28, 2026 16:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15e6872922

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

.expect("a leaf of the structure");
match &target.record {
Some(record) => {
classes::object_call(ObjectOp::Load(record.fields[index]), vec![raw.clone()])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve four-state classification for record member reads

In four-state simulation, a record-backed element such as struct { string name; logic flag; } can return X from this load, but case::expr_is_two_state currently classifies every non-container object operation as two-state. Consequently, if (q[0].flag || !q[0].flag) is folded to unconditional true by statements::simplify_condition, even when flag is X and neither branch condition should be true. Update the two-state classifier to account for the field's four_state metadata when introducing these record loads.

Useful? React with 👍 / 👎.

Comment on lines +168 to +171
let object = self.heap_call(
ops::encode(ops::OBJECT_NEW, u64::from(sv::ir::Record::CLASS)),
&[size],
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Canonicalize record values before storing container elements

For record-backed structures, assigning an element its existing value now spuriously triggers whole-container events. For example, after initializing a module-level queue of struct { string name; int value; }, executing q[0] = q[0] allocates a fresh record here. Heap::finish_container canonicalizes containers by their stored element handles, not the records' contents, so the unchanged queue receives a different handle and wakes @(q). This breaks the equal-update event behavior already covered by containers::equal_updates_preserve_event_waits. Canonicalize immutable records by value, or otherwise preserve container identity for equal record updates.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant