Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@fabianschuiki
Copy link
Contributor

Add the moore.trunc operation to explicitly truncate the bit width of IntType values, and moore.zext and moore.sext to explicitly extend such a value with zeroes or its sign bit.

This requires tweaking the way how ImportVerilog generates conversion ops. Currently moore.conversion is used as a catch-all operation that expresses any kind of type conversion. In the future, we'll want to split this up into multiple dedicated operations. These width adjustment ops are the first step in that direction.

Making sign-extension explicit also fixes a long-standing issue where a $signed or signed'(x) expression would be erroneously converted into a zero-extension.

Add the `moore.trunc` operation to explicitly truncate the bit width of
`IntType` values, and `moore.zext` and `moore.sext` to explicitly extend
such a value with zeroes or its sign bit.

This requires tweaking the way how ImportVerilog generates conversion
ops. Currently `moore.conversion` is used as a catch-all operation that
expresses any kind of type conversion. In the future, we'll want to
split this up into multiple dedicated operations. These width adjustment
ops are the first step in that direction.

Making sign-extension explicit also fixes a long-standing issue where a
`$signed` or `signed'(x)` expression would be erroneously converted into
a zero-extension.
Copy link
Member

@terapines-osc-circt terapines-osc-circt left a comment

Choose a reason for hiding this comment

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

I don't have any questions. Perfect πŸ‘!

Comment on lines +1082 to +1084
if (value.getType() != srcWidthType)
value = builder.create<moore::ConversionOp>(value.getLoc(), srcWidthType,
value);
Copy link
Member

Choose a reason for hiding this comment

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

So cool 😎!

@fabianschuiki fabianschuiki merged commit 1a592a7 into main Nov 8, 2024
4 checks passed
@fabianschuiki fabianschuiki deleted the fschuiki/moore-trunc-ext branch November 8, 2024 22:03
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.

2 participants