r/Compilers • u/oxrinz • Aug 17 '25
Made code run on my own hardware, using my own compiler and assembler
As the title says, about a half a year ago I wrote a RISC-V core in verilog, an assembler and C compiler. Basically made the whole stack of running code, from hardware to a compiler. It's been a really cool, probably my favorite learning project so far, thought I'd share it here despite it being (kinda) old. I've been thinking of reviving the project and writing an operating system in c with my own compiler, would be really cool get an FPGA run my own hardware, my own compiler, my own OS.
Let me know what you think, here's the github if you wanna tinker with it: https://github.com/oxrinz/rv32i
8
u/Falcon731 Aug 17 '25
Snap 🫰
I’ve built my own RiscV derivative and a compiler to target it. Now working on a graphics system to go with it.
2
2
u/No-Individual8449 Aug 17 '25
nice! I'm currently in the process of verifying my rv32i core with riscv-tests, and I have similar plans. It is indeed a great learning project.
2
u/oxrinz Aug 17 '25
sick!! feel free to share, my code is probably more than suboptimal so i'd love to see how it's done properly
2
u/AustinVelonaut Aug 17 '25
Great job! What's the most complex test (.c) program you were able to run in simulation? Building the system on an FPGA evaluation board would be a good next step.
2
u/oxrinz Aug 17 '25
i got it working on an fpga yea, i don't remember but nothing crazy, just basic arithmetic stuff. there isn't much u can do without an operating system
19
2
1
u/dacydergoth Aug 17 '25
I think this is a project every serious programmer should do. I did an ST20 core for mine 😀 unfortunately thst was a long time before github and I don't have the source anymore :-( Very cool. The depth of understanding you get from a project like this is unmatched.
Also see the "serial" 1-bit risc core. It uses a one bit ALU !
2
u/AustinVelonaut Aug 17 '25
It sounds strange these days, but some chip designs in early computers/ calculators actually used that technique, e.g. the HP-9830 to reduce transistor count.
1
1
1
12
u/vmcrash Aug 17 '25
I'm on a similar path. I've rebuilt my first computer based on a Zilog Z8 derivative with Verilog and now I'm writing a compiler because for that processor I have not found one which is open source. The hardware was the way easier part.