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

Overflow dropping in summation operation #10

Open
togulcan opened this issue Mar 21, 2022 · 2 comments
Open

Overflow dropping in summation operation #10

togulcan opened this issue Mar 21, 2022 · 2 comments

Comments

@togulcan
Copy link

togulcan commented Mar 21, 2022

I realized in the below operation wrong return value Z is generated during the summation of X and Y:

unsigned<64> foo(unsigned<32> X, unsigned<32> Y){
    unsigned<64> Z = X + Y;
    return Z;
}

I believe this is due to the fact that X and Y are translating to C types (etiss_uint32) and their summation also returns etiss_uint32 which drops the overflow value(32nd bit).

However when I do casting explicitly as follows:

unsigned<64> foo(unsigned<32> X, unsigned<32> Y){
    unsigned<64> Z = (unsigned<64>)X + (unsigned<64>)Y;
    return Z;
}

It works pretty well.

But coredsl2 manual guarantees no dropping is occurring by simply setting the width of the result value to wr = max(w1 + 1, w2 + 1). Should not M2-ISA-R also guarantee this? This is leading to a lot of unexpected behaviors.

Thanks a lot!

@neithernut
Copy link

AFAIU this is a bug.

@wysiwyng
Copy link
Collaborator

This is indeed an oversight in the implementation of at least the ETISS code generator. CoreDSL type promotion rules are more or less ignored completely in M2-ISA-R as of now, therefore standard C type promotion rules are used in ETISS. I will look into this, but it will probably take a moment to properly fix.

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

No branches or pull requests

3 participants