Download and unzip Ripes simulator for your operating systems. For Linux and Windows right click on the Ripes application and open, run or execute.
Shows a simulator of a 5-Stage RISC-V processor. There are several other models. The popular CH32V003 chip is like this, think of it like an Arduino.
The layout or "architecture" of RISC cores is a pipeline of circuits moving data fetched from memory through writing back results. It executes parts of more than one command at one time.
Configure IOClick on the LED icons on the left of your screen. Click on LED Matrix to bring up the display and parameter. When you get the matrix picture added then our simulator will use this data in the program.
This panel sets up whether your simulator behaves like it has a matrix of LEDs, on-off toggle switches or a joystick interface. WIDTH and HEIGHT are obvious, BASE is the starting memory address for the device.
EditorClick on the editor icon. On first run we will see blank fields. Menu File->Load Example->Assembly->leds.s to load our program.
Assembly language is not easy to read. This sketch reads the dimensions we put in for our LED matrix and runs two loops to toggle the LEDs we saw. One loop steps the program through the rows and the other loop steps through the columns.
Source code is our input program, we can edit it, save. We are writing mnemonics for the RISC-V machine language that include pseudo-instructions.
Middle panel shows hexadecimal version of the 32bit machine code. Disassembled column is re-converting from the actual machine instructions into readable assembly commands.
Bottom right corner of screen says we are working with ISA RV32IM instruction set programming language. Ripes lets us also work with 64bit RISC-V and extensions.
Select binary and we see a column with the same 32bit numbers already displayed in hexadecimal.
PlayClick the green play button at the top of the screen. The program will begin running. Middle panel shows machine level instructions being executed. Final column is the 32 registers used in this processor design.
This is a debugging tool. We can set breakpoints and single step forwards and backwards through our code. The red highlight lines are being executed by the stages of the processor.
Because of the RISC pipeline we see up to five commands executed at once. The black letters on the red highlighted lines are the stage names.
ProcessorClick the processor icon. See how the machine level commands run through a 5 stage processor. These are the same commands we saw in the editor screen. The same single step menu commands work.
Click on the Play/Pause and cycle through the options. Many parameters can only be changed while the simulator is paused or stopped. The swirly icon resets the program to the start.
The red nop means no operation, the circuit pauses while the rest of the calculation catches up. We call this "stalling" and is normal.
Display options allow register values, console output, stack values. You can display binary or hex. Click, right-click and look at extra menus.
Check the IO ScreenClick on IOs and we can watch the pixels turn on and off. It's like a two dimensional blinky program.
Nope, not yet. Ripes comes with example C programs but will not run them until a RISC-V compiler toolchain is installed in the computer. You'll see this screen, a lot.
Menu Edit->Settings->Compiler brings you to a panel that allows you to navigate to any toolchain installation you may have on your computer. We'll show you in another project.
Installing the complete RISC-V C/C++ compiler toolchain may take a GigaByte of storage in your computer. You can install one toolchain with MounRiver or Embeetle IDEs and use it here. When the program sees a good toolchain it shows green.
Now we can open and edit C/C++ programs and the included examples. Click the hammer icon to build and run the code. We can also load elf files from other programs.
RISC-V doesn't require you to use any of their models but they are designed to work with the ISA. You may have to recompile your programs as you change. Click the box icon next to the swirly while the simulator is stopped.
Notice that Bottom right corner of screen says we are working with ISA RV64IM instruction set programming language. This is a 64bit machine code and it supports extensions to add mathematical instructions.
Imagine your electronic product needs programmability but not much. This computer core is so simple you could build it with relays or compressed air.
Go back to the I/O panel and look at Switches and D-Pad. Like the LED matrix they have parameters that can be entered into your program including a memory address.
Comments
Please log in or sign up to comment.