Exaud Blog
Blog
CPUs for Dummies: Part 1
Junior Software Developer Carlos Pinto CPUs in the nicest and smoothest possible way. After all, this is CPUs for Dummies. Posted onby ExaudThis week, Junior Software Developer extraordinaire Carlos Pinto introduces Central Computing Units in the nicest and smoothest possible way. Yes, you’ll get the hang of it, it’s a promise. After all, this is CPUs for Dummies.
Introduction
The Marvel of CPU Technology
It’s easy for both software developers and everyday digital users alike to take for granted the masterpiece that is the hardware behind a computer. Imagine a hand-sized disk spinning at 7000 RPM, with a small needle that is just short of touching it, detecting ever so slight magnetic variations on that same disk that represent more words than you’ll ever be able to remember in your lifetime. Now imagine a chip receiving a numeric representation of a three dimensional world, reasoning as to how that three dimensional world behaves, and displaying that on your screen as a combination of lights colored red green and blue, and then doing that all over again tens of times per second. And all of this is happening as you browse memes and play video games.
Central Computing Unit
Role and Evolution of the CPU
One such formidable piece is the Central Processing Unit (CPU). The name says it all, you just can’t have a computer compute (i.e. process) things without a processor. Over the years, with transistors getting smaller, CPU’s were able to have much more processing power while keeping the same sizes and prices. But there’s actually a lot more ingenuity to these fine pieces of hardware than a higher transistor count, and, in fact, transistors are reaching their size limit. I’ll be going over some of those techniques in Part 2, but before we get to that, let’s get the gist of how a CPU operates.
How the CPU Thinks
The Instruction Cycle: Fetch, Decode, Execute
In short, all a CPU does is take instructions and provide an output. Simple. The basic scheme of how this happens is the same for any CPU, and goes along the typical pipeline: fetch, decode, execute. This is known as the instruction cycle. The CPU fetches instructions from memory and stores a small batch in a localized CPU-specific memory. You can think of this as the task of having to go over many huge piles of papers, and grab smaller, more manageable piles over to your desk, gradually, rather than going through the entire pile at once. These instructions are just “words” so to speak, and don’t do anything by themselves, so the CPU looks at them and decodes them by deciding what each word is telling it to do, a bit like checking a dictionary from a foreign language you don’t understand, but where this hypothetical dictionary, rather than explaining the word, directly translates to what you should do. This dictionary, by the way, would be your CPU’s Instruction Set Architecture (ISA), which is what prevents you from executing ARM binary in an x86 processor: the words just don’t translate. Finally, the CPU executes the decoded instruction by assigning it a resource (more on that later), which will take different amounts of time (or clock cycles, in hardware lingo) depending on what the instruction was. When it’s ready, it does something with the output, like writing it back to memory, or using it in the following operation. And then, rinse and repeat: this is the instruction cycle.
What’s the CPU Made Of?
I mentioned the CPU assigns resources to tasks, but what exactly is a resource in this context? As you can imagine, adding two numbers up is a very different task than grabbing a number from memory. Because of this, a CPU has components that carry on different tasks, with components varying from manufacturer to manufacturer. A CPU’s Control Unit (CU) is responsible for orchestrating how instructions are distributed, turning components on and off, and sending data the correct path, as if ordering around the CPU’s resources. A big majority of instructions will use the Arithmetic Logic Unit (ALU), which does addition and subtraction, among other things. A Load-Store Unit (LSU) mediates data coming from memory to registers and from registers to memory. Oh, and a register is the internal memory units that the CPU has, but unlike your typical RAM or hard-drive memory that serves a big, contiguous block of memory, CPU’s registers are usually very limited in size, but blazingly fast in comparison, also being very specific, e.g., a register for the current instruction, a register for whether the last operation resulted in a negative number or not… There’s many more components that a CPU has, or may have, but going over is enough material for writing entire books!
Conclusion
So that’s the gist of it, you are told words, you look up the dictionary to know what to do, and you use the tools at your disposal to do what you’re told. This all happens in the order of a million times per second. Hold on for Part 2 to check some neat design tricks used to optimize the CPU for performance. If you need a software solution that harnesses the power of advanced CPU architecture, Exaud is here to help. We specialize in creating efficient software applications that make the most of your hardware capabilities. See our Case Studies for more information.
Working at Exaud is more than just a job. Want to come along for the ride? We’re always looking for great people to join us. Check our current openings on our Careers Page.