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

Setting a register as the first instruction sometimes causes a runtime error in the single-cycle processors #338

Open
raccog opened this issue Dec 30, 2023 · 0 comments

Comments

@raccog
Copy link
Contributor

raccog commented Dec 30, 2023

Here is a bug report for a strange crash I encountered.

The following runtime error is thrown when this bug is activated:

terminate called after throwing an instance of 'std::runtime_error'
  what():  Multiple changes for port Single Cycle RISC-V Processor->registerFile->_rd2_mem->data_out during a single cycle

This bug has very specific conditions to activate it.

Note that if a program with the following conditions is loaded on Ripes' startup, then it will crash instantly. This can be fixed by going into the Ripes config file (~/.config/Ripes/Ripes.conf on Unix; unsure where it is on Windows) and setting the sourcecode= line to sourcecode="".

Conditions

  • Ensure that you have not switched processors, during this session of Ripes, before running the program.
  • Set a register (it can be any register; even read-only such as x0) in the first instruction of a program. This can be done with any instruction that sets a register (tested with addi, ori, and xori).
  • The instruction needs to be the first instruction ran in the program.
  • Set the register to a non-negative number (most significant bit set to 0).
  • Set the 5 least-significant bits of the register to either 2 (00010) or 3 (00011). All other bits do not seem to matter. It is possible that there are other undiscovered bit combinations that cause this bug, too.

Example

To reliably cause the crash to occur, open Ripes, clear the source code in the editor tab, switch to the RISC-V single-cycle processor (could be 32 or 64-bit), and then exit and re-open Ripes. Now you can type in the instruction to set a register according to the above conditions, and the program should crash when the instruction is run.

The following program causes the crash to occur with the above conditions:

addi a7, x0, 2

I haven't had the time to look into the Ripes/VSRTL code where the bug occurs, so this is the extent that I have discovered so far.

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

1 participant