Software
Analogy
What is the idea behind digital computers? What do we want to have?
An immediate use case for computers would be for helping with math-related problems.
For example, if we have a problem like determining how much power we need to throw a pumpkin (punkin chunkin) a certain distance, we can use some physics and math to determine the equation to use. Then we need to evaluate that equation with certain values for each distance we want.
Let’s say we wanted to determine the power we need for very many distances however we only have access to paper and pencil. It would take too long for us to do by ourselves.
We can get some help from others but they may not understand the equations and physics. However they can do some very basic arithmetic like multiply two numbers.
How could we get them to help?
We’ll need to write down some instructions in a format that they can understand.
For example, let’s say we have to solve for x in many quadratic equations ax^2 + bx + c = 0. For one, a = 1, b = 3, c = -4. The person helping us doesn’t know about quadratic equations, but we can still have them help us. First we must formulate a way so that it is easy enough for them.
We might be able to rearrange the equation to:
x = (-b +- sqrt(b^2 - 4ac))/2a.
This is closer but if they only know about arithmetic they will still have some trouble. How can we make it even easier?
If you’ve filed taxes by hand, you may already know where this is headed.
Let’s say we divide the piece of paper into two sections.
In the first section we’ll write down a procedure to follow.
In the second section we’ll label a few boxes, a, b, c, x. Then we’ll label a few more boxes, 0, 1, 2, 3, 4, 5.
Now we’ll fill in boxes a, b, c with 1, 3, and -4.
Here’s the procedure for them:
- Take the number in box b and multiply it by the number in box b and write down the result in box 0.
- Take the number in box a multiply by box c and multiply by 4, write down in box 1.
- Take box 0 and subtract box 1 from it. Write down in box 2. …
- Take .. and write down in box x
Each step is very easily for anyone to follow. All they need to know is how to multiply, subtract, etc. They do not need to know about equations or quadratics or anything else. We can now simply give them pages with a, b, c boxes filled in and they will give us back pages with box x filled in.
This is the model of software. There is some input, procedure, intermediate data, and output. If we have computers that can run the software they can help us with a large variety of tasks even if the computer wasn’t intended for that task in the same way that we were able to get other people to help us with the math problem even if they understood very little, and they can also help with many other things. A general purpose computer is able to help in many different areas and also new areas as they are created.
Now the problem is how to build a machine that could run this software.
In order to build this computer we’re going to need a few parts:
- Determining the step to run from the procedure
- Executing a single step
- Reading and storing results
Implementation
Digital computers are based on switches like a light switches
We can arrange the switches to form complex components
These switches are electronically controlled instead of by someone
So the output of one switch can be used to control another switch
Digital switches are considered to be either on or off, the in between values are ignored - so no dimmers
Having only two positions makes it easier to work with and can be used to form basic logic systems where things are TRUE or FALSE, and also store numbers in binary format which only requires two digits 0 and 1
Logic Gates
How do we build logic from these switches?
Logic is represented in switches by putting them together into what’s called logic gates
For example two switches in series form a logical AND gate. This is because both switches need to be set to the ON or TRUE position for the output to be considered TRUE.
In a similar way you can build other useful logic gates like OR, NOT, etc.
By arranging the switches you can encode some complex rules. Then all you need is to set the input switches and check the output values.
Memory
With switches you can also construct memory storage with some tricks. You can arrange them