mortbopet / ripes Goto Github PK
View Code? Open in Web Editor NEWA graphical processor simulator and assembly editor for the RISC-V ISA
Home Page: https://ripes.me/
License: MIT License
A graphical processor simulator and assembly editor for the RISC-V ISA
Home Page: https://ripes.me/
License: MIT License
Ripes can read binary files, but save would also be nice. That could help students to use Ripes as the golden model for their own ISA simulation implementation.
Problem arises in the following test file
lui s0 239437
addi s0 s0 -467
sw s0 100(x0)
lb t0 100(x0)
lb t1 101(x0)
lb t2 102(x0)
lb t3 103(x0)
lh t4 100(x0)
lh t5 102(x0)
lh t6 101(x0)
lui s2 2
addi s2 s2 2040
addi s1 x0 50
sw s2 -23(s1)
lw s3 -23(s1)
addi a0 x0 10
ecall
error in:
.data
str: .string "841"
a0: .word 0 #Contador
.text
addi t5,zero,48
addi t6,zero,57
addi t3,zero,0
la t1,str
length:
lb t2,0(t1)
blt t2,t5,fimContagem # se t2<48,(48 representa 0, em decimal, ASCII) vá para fimContagem
blt t6,t2,fimContagem # se 57<t2 , vá para fimContagem (57 representa 9 em decimal, tabela ASCII)
addi t3,t3,1 #incrementando o contador do tamanho da palavra
addi t1,t1,1
beq x0,x0,length
fimContagem:
but, if change to this new code, it's okay:
.data
str: .string "841"
a0: .word 0 #Contador
.text
la t1,str
addi t5,zero,48
addi t6,zero,57
addi t3,zero,0
length:
lb t2,0(t1)
blt t2,t5,fimContagem # se t2<48,(48 representa 0, em decimal, ASCII) vá para fimContagem
blt t6,t2,fimContagem # se 57<t2 , vá para fimContagem (57 representa 9 em decimal, tabela ASCII)
addi t3,t3,1 #incrementando o contador do tamanho da palavra
addi t1,t1,1
beq x0,x0,length
fimContagem:
Currently, it can be quite hard to navigate between the assembly view and the disassembly view.
Options to improve readability could be:
For both cases, it should be made sure that the solution does not break Ripes when loading a flat binary file
How do I make an array? In MIPS, I put this in the data area:
.date
myArray: .space 400
In this example, I create an array with 100 integers of 4 bytes. How do I do in the Ripes assembly?
Providing an AppImage would have, among others, these advantages:
appimaged
--appimage-extract
parameterHere is an overview of projects that are already distributing upstream-provided, official AppImages.
If you have questions, AppImage developers are on #AppImage on irc.freenode.net.
I'm trying to use the instruction mul (mul x10, x11, x12) but it won't assemble.
I don’t know which widget restricts the minimum size, the width of the entire window exceeds the screen width and cannot be reduced.
The laptop I used is a bit old, the resolution is 1366*768, which was popular in a few years ago.
Currently, programs with long simulation times as well as infinite loops can hang the program, since the Pipeline object lives in the GUI thread.
It should be fairly simple to create the Pipeline in a separate thread and create a message box for when "run" is selected, which monitors the execution and gives the user the ability to stop the program, as well as notifying them that there may be an infinite loop in the program.
When I try to compile on Ubuntu 18.04 I get the error that QRegularExpression is not found. I have both qt 5.11 and 5.13 installed.
I run qtchooser with qmake -qt to set the version of qt to one that contains QRegularExpression but still QT tries to use qt4 and thus fails to find the QRegularExpression.
Allowing for this would make us not have to remove the function argument type when inserting RISC-V compiled code from compiler explorer.
The issue lies with the default splitter regex that is used in syntaxhighlighter.cpp in checkSyntax()
Please simply try this code
.text
auipc a0 10 // auipc a0 0x10
lui t0 10 // lui t0 0x10
auipc a0 0x10 // auipc a0 0x16
lui t0 0x10 // lui t0 0x32
The comments is what displayed in the 'Executable Code' window.
The issue is not true for some other instructions such as addi.
Is there a way to run it from the command line for batch processing?
Is there a way to dump the stage view to a file?
Since the requirements for having a correct binary file is quite strict, documentation of this must be provided.
Must contain:
ecall 10
operation before entering the data segment. This prevents the simulator from running the data as instructions.These wires are shown due to some ports not being set as hidden. This can be fixed by editing the layouts of the processors.
li x5,0x44332211
sw x5,0x12(x0)
it seems that sw instruction can not use Hexadecimal offset
hi, congrats cause you developed the only visual simulation for riscv. i'm trying to create a riscv simulator for teaching purposes and i find this very promising. would you be interesting to communicate with me to see if there is a way to help each other improve ripes so it can be used as a tool in advanced architecture classes?
Currently for li a0, 0xff000000
assembler will generate two instructions lui x10 1044480; addi x10 x10 0
. The second instruction is practically a nop.
A simple check in assembling immediate instructions with the same register and value of zero (for addi, ori, xori, slli, srli, srai) should be enough for starters.
Hi,
I think there is an issue with either the code that replaces the li pseudo instruction with lui and addi or one of this instructions is buggy.
To reproduce, enter this source code:
li x1, 1193046
The assembled output is:
lui x1 292
addi x1 x1 1110
Executing this code, I don't see the expected value of 1193046 in x1 but 1197142.
But, if I execute the following code, the result in x2 is correct.
lui x2, 292
addi x2, x2, 1110
Regards
Joachim
I try run this instructions, but the program crash and close:
jal zero, f
g: jalr zero, ra, 0
f: jal ra, g
Hi,
the AppImage does not work in CentOS7.
How do I compile the source code?
There semms to be no configure.
Best Regards,
Elmar
I tried to build the application and deply it but I'm getting error 0xc000007b.
Could you provide a new release with recent comits?
For instance, if a user tries to write jalr x0 0(x1)
the tooltip should also state that jalr
has the format
jalr [rd] [rs] [imm]
.
for easy of use, we can bundle the gcc toolchain into release(only for Linux?),
then add a c language code input area above assembly code, and provide some buttons like 'compie' , then automatically process the compiled code to meet the required format.
This is very convenient for learning and teaching Computer Architecture Course.
How to replicate.
On catalina
mkdir -p Qt/5.13.0
tar -xJ -C Qt/5.13.0 -f Qt-5.13.0-mac.tar.xz
export QT_ROOT/Qt/5.13.0/clang_64
export PATH=$QT_ROOT/bin:$PATH
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
mkdir build
cd build
cmake -GNinja ../
open Ripes.app
I am currently using Ripes version v2.0.1-1-g9578aef on an x64-based PC running Microsoft Windows 10 Home Single Language version 10.0.18363 Build 18363. I am using it to teach a Computer Architecture course and I am very grateful that you have made the software freely available.
I cannot see the full entries for the Address column in the Memory tab. I've tried changing the display type and right-clicking and double-left-clicking on the cells. I cannot change the width of the column using my mouse.
Is there a way to see the full entries for the Address column in the Memory tab?
Thank you very much for your time.
Compiler detection, either autodetection with a should-be-valid compiler in %PATH%, or a specified path to a compiler (via using the Browse button in the Editor Settings dialog), doesn't seem to work on Windows with the 2.1.0 binary release.
I can confirm I'm using the compiler binaries from https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-w64-mingw32.zip via https://github.com/sifive/freedom-tools/releases. Looking at the test program embedded in ccmanager.cpp ("int main() { return 0; }
"), I can successfully compile this with the following command line ("risc-foo.c" contains only the string above as the entire program):
riscv64-unknown-elf-gcc -march=rv32im -mabi=ilp32 -O0 -x c risc-foo.c -o risc-foo -static-libgcc -lm
I can also load the resulting (ELF) binary into Ripes (via Ctrl+O or "Load Program" under the File menu) and run it in the simulator.
Similarly, I tried a more complex sample, as shown at https://github.com/mortbopet/Ripes/wiki/Building-and-Executing-C-programs-with-Ripes:
#include <stdio.h>
int main() {
char buffer[128];
printf("Type something to be echoed:\n");
fflush(stdout);
fgets(buffer, sizeof(buffer), stdin);
printf("\nYou typed: %s", buffer);
return 0;
}
This also compiles fine with the following command line, and likewise the binary loads fine in Ripes ("risc-foo2.c" is only the program source shown above):
riscv64-unknown-elf-gcc -march=rv32im -mabi=ilp32 -O0 -x c risc-foo2.c -o risc-foo2 -static-libgcc -lm
I'm uncertain what exactly is failing (or seems to be failing) on Windows with the 2.1.0 release binary WRT compiler detection.
There's a rather critical bug in the simulator related to recursive function calls. I haven't been able to pinpoint exactly where the problem lies, but I'd guess it's got something to do with instructions that manipulate the return address register (jal
, jalr
, ...).
The following code implements a function for recursive factorial calculation. It's almost verbatim to an example shown in the Computer Organization and Design: RISC-V Edition book:
main:
addi a0, zero, 7 # function argument (7)
jal ra, fact
jalr x0, x1, 0
fact:
addi sp, sp, -16
sw ra, 8(sp)
sw a0, 0(sp)
addi t0, a0, -1
bge t0, zero, nfact
addi a0, zero, 1
addi sp, sp, 16
jalr x0, x1, 0
nfact:
addi a0, a0, -1
jal ra, fact
addi t1, a0, 0
lw a0, 0(sp)
lw ra, 8(sp)
addi sp, sp, 16
mul a0, a0, t1
jalr x0, x1, 0
The register a0
is the function argument and the return register. It starts out as 7, so at the end of the program it should read 5040, which is 7 factorial.
If you run it in the RIPES simulator, it'll end as soon as a0
equals 0. The program will step through the final lines before the return, add 1 to a0
, 16 to sp
, and end. The final value of a0
will always be 1, regardless of the input. What should happen is that the program should return to the last return address (which would be the part in nfact
right after the jal
instruction) and continue on through the call stack.
However, if you compile the same code using the official RISC-V compiler toolchain, simulate it with the ISA simulator and step through it with the included GDB toolkit, the program works just fine, and outputs 5040 on a0
when it ends, as shown by the register dump below:
zero: 0x0000000000000000 ra : 0x0000000000010080 sp : 0x000000007f7e9b50 gp : 0x0000000000000000
tp : 0x0000000000000000 t0 : 0xffffffffffffffff t1 : 0x00000000000002d0 t2 : 0x0000000000000000
s0 : 0x0000000000000000 s1 : 0x0000000000000000 a0 : 0x00000000000013b0 a1 : 0x0000000000000000
a2 : 0x0000000000000000 a3 : 0x0000000000000000 a4 : 0x0000000000000000 a5 : 0x0000000000000000
If it helps, I also used a C compiler to compile a simple recursive factorial function into RISC-V ASM, and it had the exact same issue.
I tested the changes in 396831b and it works, but I noticed that the highlighting of x30
in the mulh
instructions was only realizing the first number was part of the instruction. This is probably because referencing registers by x is uncommon, and it is the only way to get a double digit number afterwards so it has yet to be noticed.
This probably is a very low priority issue, but I thought it would be good to share.
Hi, Ripes is really good and thank you so much for open sourcing it to the community. I noticed that it has a save function but every time you save, you need to pick the file again, it would be nice to be able to select only once and it will keep overwriting that file and reselect again when needed. Also, it would be nice to have a similar option for the output of the assembled code where every time a new code(in Disassembled or Binary) is generated it saves to a file. I'm asking for these features since I'm taking a class where we design our processors and I have to change the assembly and grab the binary to test the processor relatively frequently. I have worked with Qt before, not specifically with Widget but I would be down to help implement this feature.
The .word-declaration is defined as .word expression [, expression]* 32-bit comma separated words.
The simulator Ripes don't support this?
because this code give-me a error:
> .data
>
> **a: .word -7,8,107,11,13 #vector**
>
> .text
The following, albeit strange code, hangs the simulator:
jal end
.data
end:
Hello,
The following assembly pseudo-instruction
li a0,0x1000
is translated into
lui x10 2
instead of
lui x10 1
diff --git a/src/parser.cpp b/src/parser.cpp
index 3343cb8..db7acab 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -1,6 +1,8 @@
#include "parser.h"
#include "defines.h"
#include "pipeline.h"
+#include <QFile>
+#include <QDataStream>
#include <cassert>
#include <iostream>
For use in academic teaching, it would be interesting a way where it was possible to control the conflict(hazards) resolutions active or not in the pipeline.
Infinite Loop when run in the application
Whenever, there is an instruction that starts the loop to run infinitely many times, the program does not provide any function to stop it.
We have to close the application using task manager.
I hope, that it gets fixed very soon.
As a user, a message specifically informing them of that Ripes does not support library calls could be helpful.
I tried to build on Linux and it seems the git submodules need to be pulled in.
git clone https://github.com/mortbopet/Ripes.git
git submodule init
git submodule update
cd external/VSRTL
git submodule init
git submodule update
cmake .
make
When the instruction steps to EX the program crashes if I try to divide something by 0.
I was looking through documentation on Ripes and noticed that a0
was used for designating which system call is used. This struct me as odd because the proxy kernal and gnu tool chain uses a7
. When I made RARS I made it to followed that convention and used a7
. I decided to check out what venus does and it also uses a0
.
Is Ripes trying to match what venus does in this regard?
Additionally, does Ripes have any command line interface or way to automate testing? I would like to run it through RARS's test suite to see what other incompatibilities between RARS and Ripes there might be.
I would like to, if possible, make RARS, Ripes and Venus compatible so that they can share documentation and tutorials because educational material for teaching RISC-V is really lacking.
Does not run on Ubuntu 14.04:
AppRun: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /run/firejail/appimage/.appimage-10255/AppRun)
Reference:
AppImage/appimage.github.io#831
This is due to the fact that the synchronous elements of the circuit (namely the registers) are not saved once an ecall has finished and placed its return values into the registers.
Should be able to be fixed by adding some additional logic of overriding the top of the undo stack for a synchronous component, whenever the synchronous component has been externally modified.
Note, that this is also an issue when manually setting register values through the UI.
The result is incorrect compared to results from http://www.kvakil.me/venus/
Hello,
I try writing an "li" pseudo-instruction in Ripes and got an issue, for example :
li t2, 0x76543210
is expend in Ripes to (wrong)
lui x7 484676 # 0x7644
addi x7 x7 528 # 0x210
and in gcc to (right)
lui t2, 484675 # 0x76543
addi t2, t2, 528 # 0x210
It seems coming from https://github.com/mortbopet/Ripes/blob/master/src/assembler.cpp#L436:L454 and the + posOffset
... (and i don't understand why this is done...)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.