Skip to content

fix(difftest): fix alignment for C++ type declarations#611

Merged
klin02 merged 1 commit intomasterfrom
fix-tocpp
Dec 3, 2025
Merged

fix(difftest): fix alignment for C++ type declarations#611
klin02 merged 1 commit intomasterfrom
fix-tocpp

Conversation

@NewPaulWalker
Copy link
Copy Markdown
Contributor

When generating arrayType, not all 8-bit-aligned types are valid in C++.

For example, if someone defines a 41-bit-wide signal, it may result in generating an unsupported C++ type like uint48_t instead of a valid uint64_t.

This change ensures that for any given bit width, a C++-supported type is generated.

@poemonsense poemonsense requested a review from klin02 April 26, 2025 14:26
@klin02
Copy link
Copy Markdown
Member

klin02 commented Apr 27, 2025

We have used the same alignment in many other places. If such a situation (like a 41-bit-wide signal) does exist, we will make the changes together in this PR.

@NewPaulWalker
Copy link
Copy Markdown
Contributor Author

We have used the same alignment in many other places. If such a situation (like a 41-bit-wide signal) does exist, we will make the changes together in this PR.

It's OK! Should I close this PR directly now, or temporarily convert it to a draft?

@poemonsense
Copy link
Copy Markdown
Member

We have used the same alignment in many other places. If such a situation (like a 41-bit-wide signal) does exist, we will make the changes together in this PR.

How is this PR going?

@klin02
Copy link
Copy Markdown
Member

klin02 commented Nov 30, 2025

How is this PR going?

I think if necessary, we can replace all (size + 7) / 8 * 8 with a common method, or simply leave it as it is.

@poemonsense
Copy link
Copy Markdown
Member

How is this PR going?

I think if necessary, we can replace all (size + 7) / 8 * 8 with a common method, or simply leave it as it is.

We need a conclusion for each PR whose author has done his/her work.

Either we, as maintainers, will accept it in the future or now (then do it ASAP) or not accept it (and close it)

@klin02
Copy link
Copy Markdown
Member

klin02 commented Nov 30, 2025

How is this PR going?

I think if necessary, we can replace all (size + 7) / 8 * 8 with a common method, or simply leave it as it is.

We need a conclusion for each PR whose author has done his/her work.

Either we, as maintainers, will accept it in the future or now (then do it ASAP) or not accept it (and close it)

OK. I will try to find other similar alignment issue, and fix them ASAP.

@klin02 klin02 changed the title fix(DifftestBundle): fix incorrect C++ type declarations in code gen fix(difftest): fix alignment for C++ type declarations Dec 2, 2025
@klin02
Copy link
Copy Markdown
Member

klin02 commented Dec 2, 2025

This update refines the alignment for difftest elems. Previously, element widths
were simply rounded up to the nearest multiple of 8 bits, which could produce
unsupported C++ types such as uint48_t (e.g., for a 41-bit signal). We now align
each element to the nearest supported C++ type (uint8_t, uint16_t, uint32_t,
uint64_t), ensuring correct code generation and type safety in the C++ logic.

This update refines the alignment for difftest elems. Previously, element widths
were simply rounded up to the nearest multiple of 8 bits, which could produce
unsupported C++ types such as uint48_t (e.g., for a 41-bit signal). We now align
each element to the nearest supported C++ type (uint8_t, uint16_t, uint32_t,
uint64_t), ensuring correct code generation and type safety in the C++ logic.

Co-authored-by: linzhida <linzhida19@mails.ucas.ac.cn>
@klin02 klin02 merged commit 38d2229 into master Dec 3, 2025
5 checks passed
@klin02 klin02 deleted the fix-tocpp branch December 3, 2025 02:12
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.

3 participants