Re:How a CPU works: Bare metal C on my RISC-V toy CPU
by rowanG077 on Thursday January 26, 2023 @05:26PM
(#34539768)
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:
Re:How a CPU works: Bare metal C on my RISC-V toy CPU
by Waterluvian on Thursday January 26, 2023 @05:26PM
(#34539777)
Oh that’s exactly what I was hoping for! Thank you!
Re:How a CPU works: Bare metal C on my RISC-V toy CPU
by NathanWilliams on Thursday January 26, 2023 @07:27PM
(#34540883)
I have been building a CPU using: https://github.com/hneemann/Digital
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
by sgtnoodle on Thursday January 26, 2023 @10:47PM
(#34542213)
In college, we wrote a CPU simulation in C, for a simple architecture called "little computer". You could call it an emulator, but the whole idea was to faithfully implement all the pipelining and register renaming and stuff. A main loop iteration was equivalent to a clock cycle.
Re:How a CPU works: Bare metal C on my RISC-V toy CPU
by rramadass on Thursday January 26, 2023 @11:00PM
(#34542282)
The great Niklaus Wirth wrote a book which you might want to check out: Digital Circuit Design for Computer Science Students: An Introductory Textbook.
Re:How a CPU works: Bare metal C on my RISC-V toy CPU
by emoII on Friday January 27, 2023 @02:08AM
(#34543463)
Worth a mention: https://turingcomplete.game
I've played for a few hours, it's well made!
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.