The Hazard 3 RISC-V cores on the RP2350 were designed by Raspberry Piโs own Luke Wren in his spare time โ and as theyโre open source, you can download the design files yourself and start poking around in the very same chip that will eventually be in use on millions of units out in the wild. As Eben Upton puts it: โIn adding Hazard3 to RP2350, weโre aiming to give software developers a chance to experiment with the RISC-V architecture in a stable, well-supported environment, and to popularise Hazard3 as a clean, open core, suitable for verbatim use in other devices, or as a basis for further development.โ Lukeโs reflections first appeared in issue 145 of The MagPi.
Iโve been doing logic design in my spare time since I was a student. Itโs highly addictive, andย I think itโs more accurate to say Iโm a hobbyist who works in chip design than a chip designer with a hobby! Itโs an open-source processor design that anyone can put in their chip and use to run RISC-V code anywhere. You can also run it on an FPGA board, or run the simulator on your own machine. Itโs all built using open-source tools like yosys, nextpnr and gtkwave.
The best way to get started is to get an FPGA board and just get hacking. Writing RTL [register transfer level] is a bit mind-bending at first โ you can think of it like a C program where all of the statements execute at once, rather than sequentially โ but that kick of seeing your own hardware come to life keeps you going. Start by blinking an LED, and keep going.
Hazard3 is 100% my own design. Itโs a fork of Hazard5, the processor I designed for RISCBoy, my open-source competitor to the Game Boy Advance. Hazard5 is a five-stage pipeline โ therefore having many hazards: data flow, control flow and structural โ and a hazard is also a kind of โriskโ, like the instruction set.
Hazard5 was meant to run at the highest possible frequency on an iCE40 FPGA, so I could run the RISCBoy graphics core at a higher frequency too. Hazard3 on the other hand is a production-grade processor which delivers as much performance as possible in its small area envelope and within the range of frequencies I expect to see on microcontroller designs. Itโs a productionised version of Hazard5 with a shorter pipeline, hardware debug, and some security and memory protection features that people expect in real systems.
From forking Hazard5 to having Hazard3 running CoreMark took less than a week. From that point until the first RP2350 tapeoutย was around two years, working on itย on-and-off throughout. There is still ongoingย maintenance work, and plans forย future expansion โ it will never be โfinishedโ, just transition from development toย stable releases.
Before I started working on RISCBoy I had a project called Tarantula which was an eight-thread barrel processor implementing the Armv6-M instruction set, because that was the ISA I was most familiar with at the time, having written some Assembly during a summer internship. I abandoned the project because I realised I would never be able to share it with anybody, and I donโt think I even have that source code any more.ย
That experience changed how I looked at things from that point forward. When I decided I wanted to build a games console from scratch, including the processor, I looked around the instruction sets available at this point, this was around 2018, and there were a few interesting ones โ Hitachi SuperH had just become much less legally restrictive โ but RISC-V stood out as an instruction set where I could implement it fairly easily.ย
The base instruction set is quite clean and simple, and you can add more complexity from a menu of extensions. I could share that with other people, and they could actually use it, and I could program using a real production-grade compiler like GCC or LLVM.
That was a long time ago, and RISC-V hasย come a long way since, both technically and as a community. There are other instruction sets that have become more open in the wake of RISC-V but I think itโs clear where the momentum is. Itโs easy to criticise some of the technical decisions made in the base ISA โ did we really need 31 link registers? โ but the community is the most important thing in my eyes.
I am excited about RISC-V because it letsย you perform your mad-scientist architecture experiments on top of a clean and standard architecture. If you look at something like CHERI, which is a super-exciting development in the embedded security space, those folks have just gone and written a spec, and you can just go and implement it โ no need to wait for it to be served on a plate.
The post RISC-V on Raspberry Pi Pico 2 appeared first on Raspberry Pi.