Skip to content

Add domain subfield access operation#5238

Merged
seldridge merged 1 commit into
mainfrom
domain-subfield-access
Mar 19, 2026
Merged

Add domain subfield access operation#5238
seldridge merged 1 commit into
mainfrom
domain-subfield-access

Conversation

@seldridge

Copy link
Copy Markdown
Member

This change enables accessing fields of domain ports using dynamic
selection:(e.g., A.name where A is a domain type and name is a field
of that domain). The field access returns a Property of the appropriate
type based on the field's type in the domain schema.

AI-assisted-by: Augment (Claude Sonnet 4.5)

Release Notes

Add domain subfield operation to allow the reading of a domain field as a
property.

@seldridge seldridge added the Feature New feature, will be included in release notes label Mar 19, 2026
@seldridge seldridge force-pushed the domain-subfield-access branch from bd7c41c to a72f912 Compare March 19, 2026 05:12
Base automatically changed from domain-clockdomain-fields to main March 19, 2026 16:35
@seldridge seldridge force-pushed the domain-subfield-access branch 4 times, most recently from 4ede800 to 10e0e94 Compare March 19, 2026 22:20
@seldridge seldridge marked this pull request as ready for review March 19, 2026 22:20
@seldridge seldridge requested a review from jackkoenig March 19, 2026 22:20

@jackkoenig jackkoenig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we will eventually want to replace this with a type-safe dynamic (using a macro), but I think this is fine for the type being.

We should do that more type-safe version in Scala 3 only once the macro comes online for D/I--but that will also require changes to the Domain API so that's something to consider (hard to do with fields being a Seq[(String, Field.Type)].

Comment thread core/src/main/scala/chisel3/domains/ClockDomain.scala
Add a new API for doing static subfield accesses of domain fields.  E.g.,
allow `A.field.name` where `A` is a domain and "name" is a field of the
domain.  The `field` method provides one level of indirection to avoid
name collisions with anything on `Element`, which properties extend.

This opts to use Scala's `Dynamic` [[1]] which allows for dynamic
invocation.  This removes some type safety, as illegal accesses are
discovered at runtime as opposed to at compile time.  However, this is
generally a much cleaner approach compared to alternatives (macros,
compiler plugins, etc.) that requires no porting to Scala 3.

[1]: https://www.scala-lang.org/api/current/scala/Dynamic.html

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
@seldridge seldridge force-pushed the domain-subfield-access branch from 10e0e94 to 4988152 Compare March 19, 2026 22:46
@seldridge seldridge enabled auto-merge (squash) March 19, 2026 23:11
@seldridge seldridge merged commit 4e45f2c into main Mar 19, 2026
27 checks passed
@seldridge seldridge deleted the domain-subfield-access branch March 19, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New feature, will be included in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants