-
Notifications
You must be signed in to change notification settings - Fork 543
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
Unaligned instruction fetch and data addresses #75
Comments
Ibex is a 32 bit core, you need to use a RV32IMC toolchain to compile software for it. (riscv32-unknown-elf-gcc) |
Hi Phillip, |
Hi Phillip,
|
Hi @AntonBabushkin , |
If you use a multlib GCC toolchain you can set both the -march and -mabi
option to the correct values, and then it should work.
For instance, try: -march=rv32imc -mabi=ilp32
…On Wed, Jun 12, 2019 at 12:20 PM Anton Babushkin ***@***.***> wrote:
Hi Phillip,
Sure, the binary was compiled in 32-bit mode (32-bit ABI: option
-mabi=ilp32 used).
I'll attach here a test case for issue reproducing.
Thanks.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#75?email_source=notifications&email_token=AABJ6JDXG7RZ72PFDCVLM6LP2DEXPA5CNFSM4HXC3EJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXP6GCI#issuecomment-501211913>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABJ6JFNYJX2HRNLV4KQHZTP2DEXPANCNFSM4HXC3EJQ>
.
|
Hi Pirmin, |
Thanks @AntonBabushkin for the update and the useful information! |
Hi guys,
Simulation message:
Thanks. |
Hi. Is there a chance that you use the core with Best, |
@AntonBabushkin , I would like to look at the wave forms you have provided. But we don't have ncsim at hand (is this the tool that you used?). Would you mind to generate and share a |
Hi Pirmin, |
Hi Anton, I am pretty sure I was able to track down the bug: The illegal instruction exception is triggered because the decoder gets indeed an illegal instruction from the IF stage. The actual problem is in the instruction fetch FIFO The same should also happen when doing unaligned loads and stores as the load-store unit The reason why no one ever ran into this problem so far is as follows: Most memories only support word-aligned accesses, the 2 LSBs of the address are simply ignored. Thus, the first access effectively returns the data at We need to create a fix for this. But since this will take a while, I suggest to do the following for now. In
by
Similarly, on Line 82, replace
by
Please let me know, if this solves your problem or not. |
Hi Pirmin, I've tried to implement a workaround on my end by:
So that produced binary will have only 32-bit instruction aligned on 32-bit address. But still I have faced 2 issues that I'd like to report back to you:
I can't tell whether #1 and #2 are linked or not, so I thought that might be appropriate to report both. An updates test case can be found here. Thank you in advance for your help in issue resolution. Best regards, |
Hi Pirmin, Surprisingly Verilator exhibits different behavior. The core reports:
From listing file (sw_tests/firmware_rv32im.lss):
Also by observing the testbench signals I can tell that my SW Tests are not executed properly. |
@AntonBabushkin please open a new issue for non-related issues to keep the discussion focused and actionable. Could you do that? |
Hi Philipp, |
Hi @AntonBabushkin , thanks a lot for reporting these issues in the first place, for providing additional information, and also for generating a Verilator environment! This eases our work a lot! I was traveling but will now look into your latest reports. Once I get a better understanding, I let you know if it is related to the original issue or not. If it is not related, we better create a new issue and continue the discussion there as suggested by @imphil . Best, |
Hi Pirmin, Best regards, |
I had a look at both simulations. The first two observations are definitely related to this issue here. As you noted, your workaround for unaligned accesses in the LSU is not a good one. Together with @luismarques , I had a look at the disassembly of your binary. There are are still unaligned loads and stores. Maybe you linked in some other code that is not under full control of yours? Looking at the waves, one can see that there are still many unaligned loads and stores happening. One of them also leads to an unknown branch decision. This happens as due to the a previous load to an unaligned address, the memory returns only a partially initialized value. This is exactly what I meant by
But luckily there is the assertion failing. The only reliable fix seems to be what I suggested. Please use it while I am working on a proper fix. Regarding the second issue ( |
As for the illegal instruction exception occurring in the Verilator simulation, I am not 100% sure what the issue is. It is still there if I enable my fix. And the reason it is there is that the software at some point overwrites the instruction memory with something that is not a valid instruction (instruction @AntonBabushkin Could you please:
Best regards, |
Hi Pirmin, Also I'd like to report that when I removed all 16-bit variables from my code my SW test passes and no warnings or errors are reported by the ibex core.
Please feel free to rename the caption of this issue accordingly, or let me know if you want me to do it. I'd be also quite interested to know when one can expect those issues to be resolved. Again, thank you so much for your help in supporting me with that. Best regards, |
Hi Anton, I renamed this issue and created the fix. It is in PR #82 and waiting to get reviewed. |
Hi Pirmin, |
Hi Anton, |
Hi Pirmin,
Please find the VCD file attached. Yes, the same binary works just fine with picoRV32 and RI5CY cores. I also would like to comment on the
statement to avoid any misunderstanding.
Thanks. Best regards, |
Hi Pirmin, Best regards, |
Hi Anton, As a side note: I knew that the fix in PR #82 does not solve the problem completely. But it at least solves the first part of this issue. So it is needed. Anyway, I let you know when I find out more. |
Hi @AntonBabushkin , To get around the bug, please use the flip-flop based register file for now ( As said, I do not yet fully understand the bug. I am not sure if we messed up something here when cleaning up the code, or if it is a simulation bug we are facing. But I know that the latch-based register file has been used successfully for many tapeouts. Thus, I don't think the original latch-based register file is fundamentally wrong. I will report back once I know more. Please let me know, if you can run the simulation with the flip-flop-based regsiter file ( Best regards, |
Hi Pirmin, Best regards, |
Thanks for reporting back @AntonBabushkin . Together with @luismarques and @gautschimi , I could nail down the bug. The latch-based register file itself is fine but the implementation of the clock gate in For SimVision, you can try to use Verilator does not support this as it is not an event-based but cycle-accurate simulator. We have to adapt our documentation and possibly the file names to make sure no one is running into this problem again. I will now create a new issue to track this work. One more times, thank you for reporting the bug and for your valuable input! |
I think the flags -delay_mode_zero and -delay_trigger do not help. the register_file really expects a proper clock gate with a latch |
Hi,
I've got an issue while trying to execute a code compiled by riscv64-unknown-elf-gcc-8.2.0-2019.02.0-x86_64-linux-centos6 (from https://www.sifive.com/boards/) on the ibex core.
Listing:
Message:
Could you please suggest what might be wrong here.
Thanks.
The text was updated successfully, but these errors were encountered: