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] More extract op lowerings #7499

Merged
merged 1 commit into from
Aug 10, 2024

Conversation

maerhart
Copy link
Member

We need to inset runtime checks for out-of-bound accesses because the semantics of the core dialects don't match the ones of SystemVerilog. I left this for a future PR since there are a few interesting cases to consider and it would increase the size of this PR considerably.

Copy link
Member

@hailongSun2000 hailongSun2000 left a comment

Choose a reason for hiding this comment

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

It makes sense! We ever discussed bits slice. @fabianschuiki thinks we can refactor moore.extract to extract, array_get, and array_slice. But I think hw.array_get cannot handle the unpacked array type, so maybe we can keep moore.extract to extract some bits from the vector, N-dimension packed/unpacked array at the moore level. It's also a great option that distinguishes them at the core level. LGTM 🥳 !

@hailongSun2000
Copy link
Member

I viewed the IEEE 1800-2017 § 7.4.6 "Indexing and slicing of arrays", if we access the index(out of bound), we can return a value based on Table 7-1.

@maerhart
Copy link
Member Author

Yes, it might be worth refactoring the extract operations a bit. I'm also wondering if it's worth having a static extract operation for arrays if we already have the dynamic one and could just pass a constant value. I also agree that using the same operation for array_get and array_slice is strange.

Thanks for looking it up in the standard! The problem we have here is that SV defines exactly that we need to return 0 or X, but CIRCT Core allows any value within the type constraint. So we need to insert a comb.muxthat returns 0/X when out of bounds.

@maerhart maerhart merged commit 62cd9ac into main Aug 10, 2024
4 checks passed
@maerhart maerhart deleted the maerhart-moore-more-extract-lowerings branch August 10, 2024 13:22
@hailongSun2000
Copy link
Member

I think that's worth it. It's a great idea to insert a comb.mux.

@fabianschuiki
Copy link
Contributor

Very nice 🥳!

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