-
Notifications
You must be signed in to change notification settings - Fork 146
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
The carry flag implementation is not correct for subtract instructions #139
Comments
I can't test this right now, so I'm just guessing, but it seems the problem might be operator precedence in this line: mor1kx/rtl/verilog/mor1kx_execute_alu.v Line 205 in 95eee05
Besides, shouldn't the statement be using logical operators instead of bitwise? |
I can't test this right now, so I'm just guessing, but it seems the
problem might be operator precedence in this line:
https://github.com/openrisc/mor1kx/blob/95eee0596a160ffdfd8ee6bc8b88268b2e49ec5e/rtl/verilog/mor1kx_execute_alu.v#L205
No, the precedence is correct, for subtraction you want to do the (2
complement) calculation:
a - b => a + ~b + 1
carry_in is used as the '1', thus it always need to be set for subtraction.
Besides, shouldn't the statement be using logical operators instead of
bitwise?
They are all 1-bit signals, so bitwise and logical obtain the same result.
…On Mon, Sep 6, 2021 at 12:40 PM Rok Krajnc ***@***.***> wrote:
I can't test this right now, so I'm just guessing, but it seems the
problem might be operator precedence in this line:
https://github.com/openrisc/mor1kx/blob/95eee0596a160ffdfd8ee6bc8b88268b2e49ec5e/rtl/verilog/mor1kx_execute_alu.v#L205
Besides, shouldn't the statement be using logical operators instead of
bitwise?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#139 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAH3FMB7MWLJZCPURMQXVTLUASEABANCNFSM5DLSM7CA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The carry flag value is not as expected for some cases. For instance, with the following trigger input, since r1 > r3, carry flag should be reset, but it is actually being set.
Issue location: rtl/verilog/mor1kx_execute_alu.v
Triggering input:
//set r1=00020000 and r3=00002000
l.sub r4,r1,r3
Expected output:
Carry flag = 0
mor1kx output:
Carry flag = 1
Please check this bug.
The text was updated successfully, but these errors were encountered: