News for hackers. Stuff that matters.
Re:How many billions of transistors in your iPhone processor? by grishka on Monday October 30, 2023 @07:57AM (#38068297)
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.

Re:How many billions of transistors in your iPhone processor? by lynguist on Monday October 30, 2023 @08:09AM (#38068382)
> 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.

Re:How many billions of transistors in your iPhone processor? by grishka on Monday October 30, 2023 @08:20AM (#38068491)
The 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.
Re:How many billions of transistors in your iPhone processor? by John23832 on Monday October 30, 2023 @11:11AM (#38070435)
I 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.

Re:How many billions of transistors in your iPhone processor? by Koshkin on Monday October 30, 2023 @11:27AM (#38070651)
> 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.

Re:How many billions of transistors in your iPhone processor? by dmd on Monday October 30, 2023 @09:11AM (#38069058)
"just" and "executes" are doing a hell of a lot of heavy lifting here
Re:How many billions of transistors in your iPhone processor? by grishka on Monday October 30, 2023 @09:45AM (#38069387)
Some 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.
Re:How many billions of transistors in your iPhone processor? by vulcan01 on Monday October 30, 2023 @09:23AM (#38069160)
> there was a web-based game where you did exactly that

This is the one I played some time ago: https://nandgame.com/