Skip to content

hdl._dsl: Change FSM codegen to avoid mutating AST nodes. #1164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

wanda-phi
Copy link
Member

Fixes #1066.

Copy link

codecov bot commented Feb 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.37%. Comparing base (f524dd0) to head (a7c649e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1164      +/-   ##
==========================================
+ Coverage   87.32%   87.37%   +0.04%     
==========================================
  Files          43       43              
  Lines        8629     8663      +34     
  Branches     2041     2048       +7     
==========================================
+ Hits         7535     7569      +34     
+ Misses        903      902       -1     
- Partials      191      192       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@whitequark whitequark left a comment

Choose a reason for hiding this comment

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

Cursed but ultimately necessary.

Copy link
Member

@whitequark whitequark left a comment

Choose a reason for hiding this comment

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

LGTM. This is pretty cursed but I see no real choice. Hopefully much of this (_top_comb_statements for example) will be replaced when we design and implement scopes.

@whitequark whitequark added this pull request to the merge queue Feb 27, 2024
@whitequark
Copy link
Member

Thanks!

Merged via the queue into amaranth-lang:main with commit 85bb5ee Feb 27, 2024
@wanda-phi wanda-phi deleted the late-bound-statement branch February 27, 2024 16:49
@whitequark whitequark added this to the 0.5 milestone Mar 19, 2024
@bl0x
Copy link
Contributor

bl0x commented Jul 4, 2024

Just a note:
This change makes it impossible to refer to FSM.state inside of the FSM context. It used to be possible before, but now any code doing this throws the error:
AttributeError: 'FSM' object has no attribute 'state'.
Referring to state is only possible after the FSM context.

@whitequark
Copy link
Member

Yes, that's expected. It was never particularly well-defined, for example if you used len(fsm.state) within the FSM context, or Signal.like(fsm.state) your code was silently broken.

@bl0x
Copy link
Contributor

bl0x commented Jul 4, 2024

Very good that this is fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Improve code generation strategy for FSMs
3 participants