mortbopet / Ripes

A graphical processor simulator and assembly editor for the RISC-V ISA

Home Page:https://ripes.me/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

raccog opened this issue · comments

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.