3 ms·
If you want to gain a deeper understanding of how computers work, write an emulator of something relatively simple — GameBoy for example. This is kinda disillus
by grishka 3y ago
If you want to gain a deeper understanding of how computers work, write an emulator of something relatively simple — GameBoy for example. This is kinda disillusioning. With the bugs you'll inevitably make, you'll understand how very, very, very dumb computers actually are. A CPU just fetches an instruction from memory, executes it, and updates the program counter. It does this indefinitely, for as long as power is applied. No magic whatsoever.
The GameBoy CPU is simple and easy to understand, sure, but modern ones are built upon the same basic principles, it's just that they run at much higher clock speeds and add lots and lots of parts (caches, pipelining, speculative execution, register renaming, multiple ALUs, SIMD ...) to execute as many instructions per clock cycle as possible. Also virtual memory support — MMU, TLB, all that stuff.
For the other side, if you want to build a CPU out of logic gates, there was a web-based game where you did exactly that. I don't remember the URL, sorry.
- lynguist 3y ago> you'll understand how very, very, very dumb computers actually are That’s not true for any post 1995 desktop CPU. They just adhere to that model and pretend that that’s all they’re doing but in reality there’s layers of supercomputers inside the CPU: micro-op cache, branch predictor, reorder buffer, rename buffer. They extract hidden parallelism out of the code, run it in blazing fast multiple instructions per clock cycle (!), and pretend that nothing out of the order happened. CPUs are extremely complex and extremely smart. They can have errors in their implementation where the unseen branches that it executed can be accessed by some processes, etc. But there’s nothing dumb about CPUs. They are made of a million man-hours of engineering.
- grishka 3y agoThe designs are smart. The CPUs themselves are still dumb, which is precisely the reason why speculative execution bugs exist. It's magic up until the point all the tricks spill out. In the end, it's always just logic gates wired together to do certain things — whether it's a Z80 or an M2 Max. All this layered complexity is simply the product of 50 years of iterative improvements.
- John23832 3y agoI think this is just doubling down and simplifying CPUs to the point of uselessness. What's the difference between a logic gate and when my index and thumb have a static charge jump between them? About a couple trillion dollars of research.
- Koshkin 3y ago> In the end, it's always just logic gates wired together to do certain things That seems to me a highly reductive point of view. The whole is always more than the sum of its parts.
- dmd 3y ago"just" and "executes" are doing a hell of a lot of heavy lifting here
- grishka 3y agoSome bits in the instruction activate some logic gates in the instruction decoder that, in turn, activate and deactivate other logic gates in the control logic, and eventually the appropriate functional unit inside the CPU is configured for the thing the instruction calls for and does it. Like the ALU adding two numbers together. If it's an architecture that uses microcode, like everything x86, I suppose the instruction decoder instead (or additionally?) outputs a microcode ROM address.
- vulcan01 3y ago> there was a web-based game where you did exactly that This is the one I played some time ago: https://nandgame.com/ https://nandgame.com/