| | What is a Computer? | March 29th, 2020 | Have you ever thought about what a computer actually is? I like to think about computers as a set of very complex circuits with a bunch of switches up front. We control which circuits are run and what output is important by turning some switches off and on. Imagine our computer has a row of 16 switches. Maybe setting the first 3 switches to on-on-off tells the computer we're going to add two numbers. A different arrangement like off-on-off might tell the computer we want to load a number into memory, or jump to a new location in the program. +---------------------------------------------------------------+ + 1| 2| 3| 4| 5| 6| 7| 8| 9| 10| 11| 12| 13| 14| 15| 16| +---------------------------------------------------------------+ | X | X | - | - | X | - | - | X | - | - | - | - | - | - | - | - | +---------------------------------------------------------------+ A bank of 16 switches Where X is "on" and - is "off" The computer also has a set of lights that can be on or off. When toggle the switches some lights go on or off depending on a specific arrangement of the switches. For example, our computer has 4 banks of lights, each with 16 bulbs. Let's say I set the switches to load a pattern of lights that represent the number 3 into the 2nd bank of lights. Then, I set the switches to load a 4 in the 3rd bank of lights. If I look at the lights, I see the pattern for 3 and the pattern for 4 in banks 2 and 3. +------------------------------------------------------------------+ + | 1| 2| 3| 4| 5| 6| 7| 8| 9| 10| 11| 12| 13| 14| 15| 16| +------------------------------------------------------------------+ | 1| . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +------------------------------------------------------------------+ | 2| O | O | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +------------------------------------------------------------------+ | 3| . | . | O | . | . | . | . | . | . | . | . | . | . | . | . | . | +------------------------------------------------------------------+ | 4| O | O | O | . | . | . | . | . | . | . | . | . | . | . | . | . | +------------------------------------------------------------------+ Lights with 3 in bank 2, 4 in bank 3 Now, when I flip the switches I can enable the add circuit, setting its inputs to the contents of the lights in banks 2 and 3 and to set the result into the bank number 4. Now, I expect the fourth bank of lights to hold the pattern for a 7. If I use a different arrangement of switches I might subtract the numbers or jump to a location in memory. +---------------------------------------------------------------+ + 1| 2| 3| 4| 5| 6| 7| 8| 9| 10| 11| 12| 13| 14| 15| 16| +---------------------------------------------------------------+ | X | X | - | - | X | - | - | X | - | - | - | - | - | - | - | - | +---------------------------------------------------------------+ +------------------------------------------------------------------+ + | 1| 2| 3| 4| 5| 6| 7| 8| 9| 10| 11| 12| 13| 14| 15| 16| +------------------------------------------------------------------+ | 1| . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +------------------------------------------------------------------+ | 2| O | O | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +------------------------------------------------------------------+ | 3| . | . | O | . | . | . | . | . | . | . | . | . | . | . | . | . | +------------------------------------------------------------------+ | 4| . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | +------------------------------------------------------------------+ Toggle in the add instruction to get the result in bank 4 We call an arrangement of the switches an instruction. Instead of physical switches we have digital 'bits' which are either on or off. Instead of lights we have 'registers' which store the values on which the computer instructions operate. A specific set of instructions for a particular model of processor are the instruction set for that processor. A sixteen switch computer is a sixteen bit computer which were popular in the 70's for mini-computers and in the mid to late 80's for micro computers. There are still 16 bit processors but they mostly are used for things like the computer in your car's brakes. These ubiquitous but invisible processor are called embedded processors. Most computers that you buy at the store and use at work are 64 bit computers. But where do we hold these instructions? I used to have a computer that I had to program every time I used it because I couldn't afford the cassette recorder that was a popular way of storing data for home computers. Now we store instructions on the large disks that come with our computers. Or maybe we just download the instructions from the internet when we need them. But loading one insruction at a time from disks or the interenet much slower than the processor can execute instructions. We store the working data and the instructions we are currently executing in the computer's memory. The processor has some special high-speed memory that it uses to temporarily hold the instructions it will immediately process, while the main memory holds the instructions that are part of the program we're executing. So we have the processor that is executing instructions and moving them in and out of memory and on or off the disk or the internet. There are other devices like video cards, network cards, sound cards, etc. The processor has special instructions to move instructions and data to those devices to enable sound, graphis, and other services. But at its heart, with all that complexity, is basically a box that executes whatever circuit we tell it to execute. Nothing more and nothing less.