[HN Gopher] How a CPU works: Bare metal C on my RISC-V toy CPU
___________________________________________________________________
How a CPU works: Bare metal C on my RISC-V toy CPU
Author : codepoet
Score : 159 points
Date : 2023-01-26 16:21 UTC (6 hours ago)
(HTM) web link (florian.noeding.com)
(TXT) w3m dump (florian.noeding.com)
| robinsonb5 wrote:
| Nice article!
|
| [I think there's a minor typo in the Combinational Logic section
| - should it read "(sometimes also called combinatorial logic)"?]
| apples_oranges wrote:
| I love computers
| sylware wrote:
| Wait we get 64bits risc-v on par with x86_64 on the desktop and
| arm64 on the mobile...
|
| Oh, and what was done, it would be illegal with x86_64 and arm64
| as you would have to pay a license in some countries... once you
| want to make money out of it.
| imadr wrote:
| The article looks really interesting, can't wait to dig in!
|
| Side note: the articles on compilation also seem to be good and
| simple to understand, especially the one about code generation
| (which is a topic that other articles somehow always skip)
| codepoet wrote:
| 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.
| HappyJoy wrote:
| Check out some videos by Ben Eater on Youtube
| rickstanley wrote:
| +1 to Ben Eater! His videos helped me so much during
| university, it was like finding real gold between fool's
| gold.
| jchw wrote:
| Ben Eater routinely makes me feel ashamed of how awful my
| breadboard wiring looks. Fantastic videos.
| moffkalast wrote:
| Unless your name is Ben, in which case I'd advise caution.
| erichocean wrote:
| This is written for young people, but still accurate: _Code:
| The Hidden Language of Computer Hardware and Software_ by
| Charles Petzold
|
| 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.
| orangesite wrote:
| Lovely write-up, thank you for sharing your process!
| orangesite wrote:
| Awesome bread recipe too!
| PossiblyKyle wrote:
| This 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
| Waterluvian wrote:
| 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.
| rowanG077 wrote:
| Yeah. There this book which uses Haskell based Clash to build
| up a simple CPU, a VGA controller and other peripherals.
|
| hardcover:
|
| https://www.lulu.com/shop/gerg%C5%91-%C3%A9rdi/retrocomputin.
| ..
|
| or digital:
|
| https://leanpub.com/retroclash/
| Waterluvian wrote:
| Oh that's exactly what I was hoping for! Thank you!
| m3affan wrote:
| Mvp, thanks for sharing
| bogomipz wrote:
| This is a really fantastic read! I wonder if the author might
| consider including links to the git source for the entire
| project?
| carry_bit wrote:
| Nice that you support multi-cycle memory instead of essentially
| using a big register file like https://nandgame.com/ uses.
|
| I recently came across https://makerchip.com/, and the TL-Verilog
| language it supports looks useful for when you want to make a
| pipelined design later.
___________________________________________________________________
(page generated 2023-01-26 23:00 UTC)