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.
Check out some videos by Ben Eater on Youtube
How a CPU works: Bare metal C on my RISC-V toy CPU
11–20 of 39 posts
Re: How a CPU works: Bare metal C on my RISC-V toy CPU
#12Re: How a CPU works: Bare metal C on my RISC-V toy CPU
#13Lovely write-up, thank you for sharing your process!
Re: How a CPU works: Bare metal C on my RISC-V toy CPU
#14I 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.
Check out some videos by Ben Eater on Youtube
Re: How a CPU works: Bare metal C on my RISC-V toy CPU
#15This 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
Re: How a CPU works: Bare metal C on my RISC-V toy CPU
#16[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
#17This 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
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
#18I 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.
Link: https://www.amazon.com/Code-Language-Computer-Hardware-Softw...
It's got a very slow, methodical onramp with a lot of diagrams and a light, breezy style. You end up building a (very simple) computer in the end, including instruction processing.
Re: How a CPU works: Bare metal C on my RISC-V toy CPU
#19This 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.
hardcover:
https://www.lulu.com/shop/gerg%C5%91-%C3%A9rdi/retrocomputin...
or digital:
Re: How a CPU works: Bare metal C on my RISC-V toy CPU
#20Earlier quoted context omitted.
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.
Yeah. There this book which uses Haskell based Clash to build up simple CPUs, a VGA controller and other peripherals. hardcover: https://www.lulu.com/shop/gerg%C5%91-%C3%A9rdi/retrocomputin... or digital: https://leanpub.com/retroclash/