Understanding Computer Architecture

I was reading old blog posts and realized I didn't touch on a CRITICAL piece of the puzzle to understanding computing... How your device actually works. This post aims to remediate this and provide a “one-stop” guide from understanding the low-level circuitry to how that allows people to program on their devices.

No computers were harmed in the making of this post. No, seriously.

The Electronics

Everything in a computer is a 1 or a 0. Many people call this true or false, or even on or off. Whatever you may call it, it's the basis for boolean (digital) logic. When you use a series of true or false statements, you are making use of the binary number system. Instead of having a 10's, 100's, 1000's etc place there's powers of 2. so 11111111 would equal 255, because 1+2+4+8+16+32+64+128=255. This is similar to how we would calculate what 255 equals- 200 + 50 + 5 = 255.

Now, we can use logic gates to perform mathematical operations on binary numbers. AND ('+' sign), OR ('–' sign), XOR ('+' sign with a circle around it), NOT ('!' mark), and NAND are the building blocks. Each one have unique properties, some are self-explanatory. If you feed 2 binary digits as input to each logic gate, it will spit out an output. 1 AND 0 will produce 1, but so will 1 OR 0... Huh? This is because you can have more than 2 inputs. Digital logic aside, we can pair these together to design different electronic components.

For our sample computer architecture, we will use a modified Von Neumann architecture, adapted so it's more in line with modern computers.

Memory

Every computer has multiple different kinds of memory, EEPROM, PROM, EPROM, DRAM, SRAM, NAND Flash and so on. What the heck is all this stuff?

Let's start by explaining that ever computer needs various types of storage. First off, we need Random-Access Memory (RAM) to temporarily hold results of various calculations to allow for calculations to run smoothly. The two main types of these are DRAM (Dynamic RAM) and SRAM (Static RAM). DRAM loses it's contents upon loss of power, while SRAM retains it until it regains power.

DRAM An actual 16 bit DRAM chip sample pinout.

RAM sticks are EXTREMELY fast but aren't good for extreme long-term storage, like our computer's BIOS and bootloader (the little screen that pops up when you press the power button). To achieve this, various ROM (Read-Only Memory) chips are available. Electrically Erasable Programmable ROM (EEPROM) chips, Programmmable ROM (PROM), and so forth are available for this purpose.

But what about user files? Enter NAND Flash and Spinning Disk Drives. NAND Flash (guess what it's made of?) is the new kid on the block, with it's own unique technologies that make it extremely fast and useful for storing user data, generally functioning like SRAM but not deleting data after power cycles. Spinning Disk Drives are still commonly found in enterprise areas and surveillance due to cheap pricing, and they use mechanical disks with magnetic “tracks” in concentric rings to store data, with a read/write head to manipulate the info.

The Processing Units

Every Computer has a CPU, though ones with graphical displays also have a GPU (which can be treated as a task-specific CPU for intents and purposes). In the old days, the CPU only consisted of one component: the processor. It left out other critical components like the system clock as it was often soldered onto the mainboard (motherboard).

The CPU (Central Processing Unit) is another chip, designed out of a series of logic gates, that takes a series of inputs (by giving power to various combinations of pins on the CPU) and spits out calculations based on them, effectively allowing it to perform multiplication, addition, addition, and so forth. When paired with a real-time system clock, the CPU becomes able to execute operations in sequence- forming machine code as we know it. Now, some modern CPU designs opt to include the system clock into the CPU itself and some don't nowadays, it's just an important thing to understand how it works.

CPU A CPU and it's pins.

A CPU contains it's own “memory”, called registers, that allow for the temporary storage of small amounts of data for faster processing, as registers are the fastest places to store data on any system.

The Graphics Processing Unit, or GPU, functions just like a CPU. Modern graphics cards have their own special RAM connected to the GPU, while some other pins are connected to various chips that control different devices such as an HDMI slot for a monitor, with a ROM chip connected to the GPU that has firmware to power the device.

All of these things get connected together and powered to produce a fully working computer architecture.

The Code

The Assembler

If you asked someone to write a large program in machine code, they'd most likely either run away, laugh at you or ask you if you are crazy. This is simply due to the fact that Machine Code is ENTIRELY in Binary (although it can be expressed as hexadecimal). As a workaround, developers create Assembler Languages, which are effectively a simple translation of the arcane machine language operations from binary to things humans recognize. For example,

10001111 10001111 10011110

might look like this in an Assembly language:

MOV REG1 REG2;

According to our sample machine language and Assembly instruction, we'd be moving the value at register 1 to register 2.

Compilers

As one might imagine, Assembly language is still tedious and it would be tough to implement an Operating System like the ones that exist today. In order to be able to achieve feats like this, it must be possible to write code in a much more human-readable language and let the computer translate it into Machine Code.

Enter Compilers. They basically analyze text through a set of rules and then based on these rules output and optimize machine code for a given architecture. This allows the implementation of various programming languages like C, C++, and Java to exist.

To implement an Operating System, a developer would need to flash the ROM with a Basic Input/Output System (BIOS), and then write code for a bootloader to boot the system. The developer may then produce a kernel to load the firmware for all connected devices and operate the low-level parts of the system that the user doesn't see. Lastly, the developer is able to create various bits of software to run on this machination, eventually resulting in a full-fledged Operating System.

Hopefully this guide proves to be handy and provides a useful resource for any budding developer interested in electronics or computing.

Liked This Content? Check Out Our Discord Community and Become an email subscriber!