mortbopet / Ripes

A graphical processor simulator and assembly editor for the RISC-V ISA
https://ripes.me/
MIT License
2.49k stars 270 forks source link

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

Open raccog opened 7 months ago

raccog commented 7 months ago

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

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.