Skip to content
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

[MooreToCore] Lower the unpacked array type to hw.array #7893

Merged
merged 2 commits into from
Dec 16, 2024

Conversation

slowlime
Copy link
Contributor

This add a type conversion for unpacked arrays, mapping them to hw.array. The approach is analogous to how unpacked structs are currently handled.

As far as I understand, hw.uarray would be more appropriate in the future, especially once it's moved to SV. However, no operation accepts this type yet. I'm not sure what the consensus is as to whether the operation set should be extended to accommodate unpacked arrays (by adding new operations or "overloading" existing ones that deal with hw.arrays). Using packed arrays for the time being sidesteps this question.

Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for adding this 👍. I like the idea of just treating unpacked arrays as packed for now, and then build out the subtle differences later on.

@fabianschuiki
Copy link
Contributor

Feel free to get LLVM commit access such that the CI builds for your PRs run automatically and you can merge your own PRs one you've gotten reviews and are happy with everything 🙂.

The semantics do not exactly align between these two types, but they do
match closely enough. There is also `hw.uarray`, which could seem like a
more suitable choice; however, there are no operations defined for this
type yet.
@slowlime slowlime force-pushed the unpacked-array-lowering branch from 5584aa1 to 6a46320 Compare November 25, 2024 20:13
@hailongSun2000
Copy link
Member

Hey, @slowlime. I ever attempted to convert moore.unpacked_array into hw.array. But I failed if I remember correctly. Maybe you can test logic [3:0][7:0] uarr [0:3][0:7];.

@slowlime
Copy link
Contributor Author

I ever attempted to convert moore.unpacked_array into hw.array. But I failed if I remember correctly. Maybe you can test logic [3:0][7:0] uarr [0:3][0:7];.

@hailongSun2000 Hm, that's interesting because the type conversion itself succeeds even given nested arrays — I've just pushed a commit to test this too. (FWIW, I've also tried running circt-verilog on a SV module containing the code you've suggested, along with stuff to prevent it from getting DCE'd, and found it works fine.)

On the other hand, multidimensional arrays don't seem usable currently because moore.extract is translated to hw.array_slice instead of hw.array_get (#7918).

@hailongSun2000
Copy link
Member

Yeah, great catch 😃. The moore. unpacked_array is unavailable now in moore.extract(_ref).

@slowlime
Copy link
Contributor Author

Hey, I was wondering if you could merge this, please? I'm not sure if I want commit access for myself yet.

@fabianschuiki fabianschuiki merged commit 134617d into llvm:main Dec 16, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants