how does a computer program arrange transistors to run a program? In other words, if transistors are so small, how can a computer ever know how to create the circuit required to run a program?



how does a computer program arrange transistors to run a program? In other words, if transistors are so small, how can a computer ever know how to create the circuit required to run a program?

In: Technology

A computer does not “arrange transistors”. They aren’t moved around to form circuits to run programs, they already are in the required configuration within the CPU. The CPU is manufactured that way with everything already in place as needed.

Computer programs simply interact with the CPU as it is designed to perform their tasks. It is a matter of writing the program in such a way as to interact with the CPU in a desired way, and for that the size of the transistors is irrelevant.

Computer programs do not arrange transistors. They are fixed in place. Computer programs are simply a list of instructions which the cpu knows how to interpret and sends current down the correct transistors. Think of it as dominos lined in complicated patterns. You don’t need to rearrange the dominos for each pattern, all you need is to be told which domino to push.

The transistors are hardware. That means they don’t change. They are hard wired, permanently. At it’s core, all a CPU can do is read data from memory, perform basic functions, and write to memory. Basic functions include Add, Subtract, Two’s compliment, increment, decrement, And, OR, XOR, one’s compliment, Arithmetic shift and logical shift.

When you write your code, that’s the human understandable code. Each command you run is broken down into multiple combinations of the basic functions listed above. Compiling a language means changing it into machine code – hard for a human to read, but required for the CPU to process.

That’s all a computer can do. Really, that’s it. It does not know how to draw an icon. It knows how to read an icon from a memory location and write it to another memory location that contains the contents of the screen. You type an “A”. that sends a code to a particular register (memory location), the CPU reads that code, and based on the machine code being run, either places a code representing an “A” at the current cursor position in memory, or moves your character one pixel to the left, or whatever.

It’s all stored in binary… ones and zeros. All math is done in binary. All graphics are stored in binary codes that indicate the color a particular pixel should show. All words, numbers, ideas, etc are stored in binary code. It’s all ones and zeros.

A computer has 5 major units.

1) Arithmetic and Logic Unit
2) Control Unit
3) Memory
4) Input
5) Output

1) Arithmetic and Logic Unit
This unit performs all the computations in a computer. It consists of various circuits such as adder, subtractor, divisor, multiplier and various other circuits that perform various computation tasks.
These circuits are made up of logic gates. These logic gates are made up of *transistors*.

2) Memory
Memory consists of a storage unit called a cell. A cell can store 1 bit of data. There are various ways a cell can store data depending upon the components. 8 cells are grouped together to form a byte. Each byte is assigned an address. In order to access a memory byte, you need a memory request which consists 2 things, address and control signal. The address activates a byte cell in the memory and the control signal tells whether to write the byte or read the byte.
This memory unit is connected to the Arithmetic and Logic Unit. When you read a byte the byte goes from memory to the Arithmetic and Logic Unit. When to write a byte the Arithmetic and Logic Unit sends data to memory which then places the data in the activated cell

3) Control Unit
Control unit is the brain of the computer. It contains micro instructions which are designed by the designer of the processor. The control unit sends control signals to various components like Arithmetic and Logic Unit, memory, input and output.
When you give and addition instructions it involves various smaller instructions to be performed like reading the data then activating the adder circuit in the Arithmetic and Logic Unit these signals are send by the control unit.

You’re kind of putting the cart before the horse… The transistors are arranged in a way that the programs can interact with them.

To put it simply, the program says.

1. Add memory block 1A to memory block 2A
2. If the result is greater than 42, then add result to memory block 1B.
3. If 1B divided by two has no remainder, then go to step 5, else go to step 4.
4. *Some other instructions that do stuff.*
5. *Some other instructions that do things.*

All of that is done by the programs instructions triggering a chain reaction in the CPU. Sort of like a Rube Goldberg machine, except the outcomes can be different based on the instructions given to the CPU.

Another way to think of it is that the CPU is just a really advanced calculator. Programs punch in numbers and the CPU gives the programs results; Except the CPU does way more than just basic math.