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

[ImportVerilog] add real literal support, refine real type, and add real format support #8020

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

chenbo-again
Copy link
Contributor

This PR is aimed to support systemverilog real, shortreal, realtime, and there conversion and operation.

One thing I'm not so sure about is that

class BinaryOpBase<string mnemonic, list<Trait> traits = []> :
    MooreOp<mnemonic, traits # [Pure, SameOperandsAndResultType]> {
  let arguments = (ins SimpleBitVectorType:$lhs, SimpleBitVectorType:$rhs);
  let results = (outs SimpleBitVectorType:$result);
  let assemblyFormat = [{
    $lhs `,` $rhs attr-dict `:` type($result)
  }];
}

why this opbase just support SimpleBitVectorType? is there any shortcoming to just convert it to a UnpackedType? I also want to use this OpBase support float point operation.

@chenbo-again chenbo-again marked this pull request as draft December 29, 2024 18:04
@hailongSun2000
Copy link
Member

Maybe we can extend its argument and result type, like AnyStaticArrayType defined in MooreTypes.td.

@hailongSun2000
Copy link
Member

Could you add some test cases? And thanks for your work on this 😄.

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.

Please remove unnecessary header files.

Comment on lines +283 to +284
let description = [{
}];
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let description = [{
}];

Comment on lines +1528 to +1529
$value `,`
attr-dict `:` type($value)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$value `,`
attr-dict `:` type($value)
$value `,` attr-dict `:` type($value)

Comment on lines +228 to +242
// The result of using logical or relational operators or the inside operator on real operands shall be a
// single-bit scalar value.
// For other operators, if any operand, except before the ? in the conditional operator, is real, the result is
// real. Otherwise, if any operand, except before the ? in the conditional operator, is shortreal, the result is
// shortreal.
if(isa<moore::RealType>(lhsType) || isa<moore::RealType>(rhsType)) {
if(!isa<moore::RealType>(lhsType))
lhs = builder.create<moore::ConversionOp>(lhs.getLoc(), moore::RealType::get(context.getContext()), lhs);
if(!isa<moore::RealType>(rhsType))
rhs = builder.create<moore::ConversionOp>(rhs.getLoc(), moore::RealType::get(context.getContext()), rhs);
} else if(isa<moore::ShortRealType>(lhsType) || isa<moore::ShortRealType>(rhsType)) {
if(!isa<moore::ShortRealType>(lhsType))
lhs = builder.create<moore::ConversionOp>(lhs.getLoc(), moore::ShortRealType::get(context.getContext()), lhs);
if(!isa<moore::ShortRealType>(rhsType))
rhs = builder.create<moore::ConversionOp>(rhs.getLoc(), moore::ShortRealType::get(context.getContext()), rhs);
Copy link
Member

Choose a reason for hiding this comment

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

We need to limit code <= 80 chars.

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