I always wanted to understand how a CPU works, how it transitions from one instruction to the next and makes a computer work. So I thought: let's implement one and run a C program on it.
How a CPU works: Bare metal C on my RISC-V toy CPU
21–30 of 39 posts
Re: How a CPU works: Bare metal C on my RISC-V toy CPU
#22I always wanted to understand how a CPU works, how it transitions from one instruction to the next and makes a computer work. So I thought: let's implement one and run a C program on it.
Re: How a CPU works: Bare metal C on my RISC-V toy CPU
#23This gets brought up every time the topic shows up but https://www.nand2tetris.org is a course that abstracts how a computer works, and is worth checking out
Is there a version of something like this that’s purely software? Like, emulate gates and keep building bigger pieces until you have a function that’s a CPU. Etc. I guess I’m thinking a bit more lower level than an emulator where you implement an opcode using normal capabilities of your language of choice. I guess TFA is pretty close to this in ways, too.
Much faster than Logisim, UI a little clunky, but my CPU runs around 0.5Mhz and it has very nice peripherals like Telnet, graphics ram, VGA etc
Terrible name that is hard to google, but great tool.
Re: How a CPU works: Bare metal C on my RISC-V toy CPU
#24This is a really fantastic read! I wonder if the author might consider including links to the git source for the entire project?
I'll think about sharing the code. Large code parts - while working - did not pass my quality bar, since I did not have enough time to clean and refactor while learning. But maybe that's fine. Hmm.
Re: How a CPU works: Bare metal C on my RISC-V toy CPU
#25Re: How a CPU works: Bare metal C on my RISC-V toy CPU
#26Nice article! [I think there's a minor typo in the Combinational Logic section - should it read "(sometimes also called combinatorial logic)"?]
Re: How a CPU works: Bare metal C on my RISC-V toy CPU
#27Earlier quoted context omitted.
Check out some videos by Ben Eater on Youtube
Ben Eater routinely makes me feel ashamed of how awful my breadboard wiring looks. Fantastic videos.
Re: How a CPU works: Bare metal C on my RISC-V toy CPU
#28This is a really fantastic read! I wonder if the author might consider including links to the git source for the entire project?
Thank you! I'll think about sharing the code. Large code parts - while working - did not pass my quality bar, since I did not have enough time to clean and refactor while learning. But maybe that's fine. Hmm.
Oh I think it's more than fine :)
Your goal wasn't to write a C++ or Python app it's was to create almost everything from first principles. I also don't think anyone would doubt your abilities after reading this post. You could link to the article in the repo. I think it's speaks for itself. My first thought when I read the article was "Wow, this is great." I've read it twice now. Thank you for sharing.
Re: How a CPU works: Bare metal C on my RISC-V toy CPU
#29This gets brought up every time the topic shows up but https://www.nand2tetris.org is a course that abstracts how a computer works, and is worth checking out
Is there a version of something like this that’s purely software? Like, emulate gates and keep building bigger pieces until you have a function that’s a CPU. Etc. I guess I’m thinking a bit more lower level than an emulator where you implement an opcode using normal capabilities of your language of choice. I guess TFA is pretty close to this in ways, too.
Re: How a CPU works: Bare metal C on my RISC-V toy CPU
#30This gets brought up every time the topic shows up but https://www.nand2tetris.org is a course that abstracts how a computer works, and is worth checking out
Is there a version of something like this that’s purely software? Like, emulate gates and keep building bigger pieces until you have a function that’s a CPU. Etc. I guess I’m thinking a bit more lower level than an emulator where you implement an opcode using normal capabilities of your language of choice. I guess TFA is pretty close to this in ways, too.