How a CPU Works

In One Lesson
15 Mar 201320:00

Summary

TLDRThis script delves into the CPU's role as the computer's brain, using the 6502 model to illustrate its inner workings. It explains the clock's role in synchronization, contrasting it with modern CPUs' gigahertz speeds. The Scott CPU, a theoretical design, is explored for educational purposes, highlighting components like the ALU and control unit. The script further describes RAM's function, CPU-RAM interactions, and the CPU's instruction set, culminating in a simple guessing game program. It concludes with an exploration of the CPU's internal components, emphasizing the modern CPU's complexity and high-speed capabilities.

Takeaways

  • 🧠 The CPU, or Central Processing Unit, acts as the brain of the computer, handling all the processing and information flow.
  • 🔍 The 6502 CPU, used in classic computers like the Apple II and Commodore 64, is highlighted as an example to understand the inner workings of a CPU.
  • 🔗 The clock within a CPU is crucial for synchronization, with modern CPUs operating at gigahertz speeds, enabling them to perform complex tasks quickly.
  • 📚 The Scott CPU is a theoretical design from a book, used in this video with permission, to illustrate the fundamental components and operations of a CPU.
  • 🔌 The CPU connects to the motherboard via pins, which allow for the transfer of information to and from other components.
  • 💾 RAM, or Random Access Memory, is where the data being processed by the CPU is stored, and it can be accessed in a non-linear manner, hence 'random access'.
  • 🔢 Data within RAM consists of instructions, numbers, addresses, and characters, all represented in binary form.
  • 🛠️ The CPU's instruction set includes various operations like load, add, store, compare, jump, and I/O instructions, which dictate how the CPU processes data.
  • 🔄 Inside the CPU, the Control Unit manages operations, the ALU performs mathematical and logical operations, and registers store and transfer data.
  • 🏷 Flags within the CPU indicate the results of operations, such as comparison, and influence the flow of execution through instructions like 'jump if'.
  • 🔗 The data bus and address bus facilitate the movement of data and instructions between the CPU, RAM, and other components.

Q & A

  • What is the role of the CPU in a computer?

    -The CPU, or Central Processing Unit, is often referred to as the brain of the computer. It is responsible for processing instructions and managing the flow of data within the computer.

  • What is the significance of the clock in a CPU?

    -The clock in a CPU turns on and off at a steady rate to keep everything in sync. Modern CPUs have clocks measured in gigahertz (GHz), meaning they turn on billions of times per second. This speed allows CPUs to perform complex tasks rapidly.

  • What is RAM and how does it interact with the CPU?

    -RAM, or Random Access Memory, stores data that is currently being processed by the CPU. The CPU sends an address to RAM to retrieve or store data. The data in RAM includes instructions, numbers, addresses, and letters, all of which are used by the CPU to perform tasks.

  • What is the 'Scott CPU' mentioned in the script?

    -The 'Scott CPU' is a fictional CPU design created by John Scott and described in his book 'But How Do It Know?'. It serves as an educational tool to explain how CPUs function without the complexity of modern processors.

  • How does the CPU use the instruction set to execute commands?

    -The CPU uses an instruction set to perform tasks. Common instructions include 'load' (to load data from RAM), 'add' (to add numbers), 'store' (to save results), and 'compare' (to compare numbers). The CPU processes these instructions sequentially or jumps to different addresses based on the instructions.

  • What is the role of the Arithmetic Logic Unit (ALU) in the CPU?

    -The Arithmetic Logic Unit (ALU) performs mathematical operations within the CPU, such as addition, subtraction, and comparison. The control unit directs the ALU to carry out these operations based on the instructions received from RAM.

  • What are flags in a CPU and how are they used?

    -Flags are indicators used by the CPU to determine the result of operations, such as comparisons. For example, a flag might indicate whether one number is larger than another or if two numbers are equal. These flags help the CPU decide the next action, such as whether to jump to a different instruction.

  • How does the CPU store and retrieve data temporarily during operations?

    -The CPU uses registers to store data temporarily during operations. Registers are faster than RAM and are used to hold data that is actively being processed by the CPU. The control unit manages data movement between registers and other components.

  • What happens to the data in RAM when the computer is turned off?

    -When the computer is turned off, all data in RAM is lost. To store data permanently, it must be saved to a storage device like a hard drive, which uses magnetic disks to store data even when the power is off.

  • How do modern CPUs differ from the Scott CPU in terms of performance?

    -Modern CPUs are much more complex than the Scott CPU and can process multiple instructions per clock tick. This allows them to execute tens or even hundreds of billions of instructions per second, enabling the rapid performance required by modern applications.

Outlines

00:00

🧠 CPU Basics and Its Role in Computing

This paragraph introduces the CPU (Central Processing Unit) as the brain of the computer, essential for understanding computer operations. It explains the CPU's internal structure, highlighting the 6502 CPU used in historic computers like the Apple II and the Commodore 64. The script mentions the clock as the timing mechanism of the CPU and contrasts its speed with modern CPUs measured in gigahertz. The Scott CPU, a theoretical design from 'But How Do It Know' by J. Scott, is introduced as an educational tool to understand CPU components. The paragraph also explains the CPU's interaction with RAM (Random Access Memory), the data it processes, and how instructions, numbers, and addresses within RAM guide the CPU's operations.

05:06

📝 Understanding CPU Instruction Set and Data Flow

The second paragraph delves into the CPU's instruction set, which defines the basic operations a CPU can perform, such as loading, adding, storing, comparing, and jumping between memory addresses. It describes how the CPU uses instructions in RAM for tasks like playing a guessing game, emphasizing the role of the 'jump if' instruction in altering the flow of execution based on conditions. The paragraph also provides an overview of the CPU's internal components, including the control unit, the arithmetic logic unit (ALU), and registers, explaining how they work together to process instructions and perform operations.

10:08

🔍 Inside the CPU: Control Unit and ALU Operations

This paragraph provides an in-depth look at the CPU's control unit and ALU, describing their functions within the CPU. The control unit is likened to a commander, translating instructions from RAM into operational commands for other components. The ALU is responsible for mathematical operations and comparisons, using inputs from registers and the bus. The explanation includes how the ALU uses flags to communicate comparison results to the control unit, which in turn affects the flow of execution through jump instructions. The paragraph also details the process of moving data between registers and the significance of the set and enable wires in this process.

15:12

🔄 CPU Data Processing and Instruction Execution

The fourth paragraph focuses on the CPU's data processing and instruction execution cycle. It explains how the CPU uses the instruction address register and the memory address register to fetch instructions from RAM. The paragraph clarifies the role of the instruction register in holding the current instruction and the use of flags and gates in conditional branching. It also touches on how the CPU interacts with external devices through input/output instructions, emphasizing the bus system's role in data movement within the CPU and the computer system as a whole.

20:13

💾 Completing the Picture: CPU, RAM, and Storage

The final paragraph wraps up the overview of the CPU's operation by discussing the computer's storage component, the hard drive. It contrasts the hard drive's slower speed with the CPU's rapid data processing capabilities and explains the necessity of moving data from the hard drive to RAM for processing. The paragraph also describes the physical connections between the CPU, RAM, and peripheral devices like monitors and keyboards through the motherboard. It concludes with a reference to the book 'But How Do It Know' for further information and acknowledges the differences between the book's content and the video presentation.

🙏 Closing Thoughts and Biblical Reference

In the closing paragraph, the script shifts from technical discussion to a philosophical and spiritual note. It includes a quote from the Bible, Colossians 3:23, encouraging viewers to work with dedication as if serving the Lord, rather than people. This paragraph serves as a reminder of the video's educational purpose and imparts a moral message to the audience.

Mindmap

Keywords

💡CPU (Central Processing Unit)

The CPU is the primary component of a computer that performs most of the processing. It is often referred to as the 'brain' of the computer. In the video's context, the CPU's function is to execute instructions that are stored in RAM, interact with other components like the ALU, and manage data flow. The script uses the 6502 CPU as an example, highlighting its historical significance in classic computers and gaming consoles.

💡Clock

The clock in a CPU refers to the internal timing mechanism that regulates the rate at which the processor performs operations. It operates at a steady rate, with the speed measured in hertz (or cycles per second). Modern CPUs operate in the gigahertz range, as mentioned in the script, which significantly contributes to their high processing speeds. The clock's role is crucial for synchronization and determining the pace of data processing within the CPU.

💡6502

The 6502 is a specific type of CPU that was historically used in various computers and gaming systems, such as the Apple II and the Commodore 64, as well as the original Nintendo Entertainment System. The script uses the 6502 as an example to illustrate the inner workings of a CPU, emphasizing its role in early computing and gaming history.

💡Motherboard

The motherboard is the central printed circuit board in computers and serves as the backbone that connects all other components, including the CPU, RAM, and other peripherals. In the script, the motherboard is depicted as the physical interface that allows the CPU to interact with RAM and other system components, facilitating data transfer and communication between them.

💡RAM (Random Access Memory)

RAM is a form of computer memory that is used to store data that is being processed by the CPU. It is called 'random access' because the CPU can access any location in RAM directly and immediately, without having to follow a sequence. The script explains how RAM works in conjunction with the CPU, using addresses to retrieve and store data, which is essential for the computer's operation.

💡Instruction Set

An instruction set is the collection of basic commands that a CPU can execute. Each CPU has its own unique set of instructions that it understands and processes. The script discusses the instruction set in the context of the Scott CPU, a theoretical CPU design, and explains how different types of instructions, such as load, add, store, compare, and jump, are used to perform various operations within a computer program.

💡ALU (Arithmetic Logic Unit)

The ALU is a component within the CPU that performs all arithmetic and logical operations, such as addition, subtraction, and comparison. The script describes the ALU as being under the control of the CPU's control unit, which receives instructions from RAM and directs the ALU to perform specific operations, highlighting its importance in the computational process.

💡Flags

In the context of a CPU, flags are used to represent the status of an operation performed by the ALU. For example, a flag might indicate whether one value is greater than, less than, or equal to another. The script explains how flags are used in conjunction with instructions like 'compare' to determine the flow of a program, particularly in decision-making processes involving conditional jumps.

💡Register

A register is a small storage location within the CPU that holds data temporarily. The script mentions various types of registers, such as the instruction register, flags register, and general-purpose registers, which are used to store and manage data during processing. Registers are crucial for the quick access and manipulation of data within the CPU.

💡Bus

A bus in computer architecture refers to a subsystem that transfers data between components. The script describes the CPU bus as a group of wires that connect multiple components, allowing for the movement of data between the CPU, RAM, and other system components. The bus is essential for facilitating communication and data transfer within a computer system.

💡Hard Drive

A hard drive is a type of non-volatile storage used in computers to store data permanently. The script explains that the hard drive retains data even when the computer is powered off, unlike RAM, which loses its data when power is cut. The hard drive's role is to provide long-term data storage, with the data being transferred to RAM for processing by the CPU.

Highlights

The CPU, as the brain of the computer, is fundamental to understanding computer operations.

6502 CPU was used in iconic computers like the Apple II and Commodore 64, as well as the original Nintendo Entertainment System.

The clock wire in a CPU is pivotal for synchronization, with modern CPUs operating in gigahertz.

The Scott CPU, a theoretical design from a book, serves as an educational tool for understanding CPU components.

The motherboard facilitates communication between the CPU and other components in a computer.

RAM is essential for holding data being processed by the CPU and operates on a random access basis.

The interaction between CPU and RAM involves addresses and data retrieval, controlled by set and enable wires.

Instructions, numbers, addresses, and letters are the primary data types stored in RAM.

The CPU's instruction set defines the operations it can perform, such as load, add, store, and compare.

Jump if and jump instructions allow for non-linear execution paths in a program.

The ALU within the CPU performs all mathematical operations and comparisons.

Flags within the CPU indicate the results of operations, influencing control unit decisions.

Registers within the CPU temporarily store numbers, managed by set and enable control wires.

The CPU bus facilitates the movement of data between CPU components, but only allows one number at a time.

The instruction address register and memory address register work in tandem to fetch instructions from RAM.

Modern CPUs process multiple instructions per clock tick, showcasing their incredible computational speed.

The hard drive serves as permanent storage, but data must be transferred to RAM for CPU processing.

The video provides a comprehensive overview of the CPU's role in data processing within a computer.

Transcripts

play00:00

The CPU short for central processing unit is like the brain of the computer and once you understand how it works

play00:05

You'll understand the computer as well. Let's remove the cover of the CPU and zoom in to see what happens inside

play00:12

there are lots of different wires carrying information around the CPU this particular CPU is called the

play00:19

6502 and was used in computers like the Apple 2 and the Commodore 64 as well as in the original Nintendo Entertainment System

play00:26

This simulation of the 6502 can be found online at visual 6502 org in

play00:33

Every CPU there is a particular wire that turns on and off at a steady rate to help keep everything in sync

play00:40

That wire is called the clock and the clock in this simulation is turning on about twice a second

play00:46

Modern CPUs are measured in gigahertz

play00:48

giga meaning billion in hertz meaning times per second so the clock in modern cpus turns on several billion times per second

play00:57

That speed is what allows cpus to do very complicated things very quickly

play01:02

However, what the CPU does during each clock tick is actually very simple and something. We'll look at more in this video

play01:09

For now we'll zoom back out and put the cover back on

play01:12

The CPU and your computer might be manufactured by a company like Intel or AMD

play01:18

But the type of CPU we're going to look at today is called the Scott CPU

play01:23

The Scott CPU doesn't actually exist except as a design in a book called

play01:27

But how do it know by john scott the design of the scott cpu is copyrighted

play01:32

And it's being used in this video with john's permission

play01:35

The book is available at but how do it no com?

play01:39

This is a great book that goes through each of the components in the CPU very slowly without using a lot of overly technical

play01:46

Jargon, if you've been looking for a book that explains how a computer works. I would highly recommend this one

play01:52

So let's flip the CPU over and look underneath

play01:55

You'll see a lot of pins sticking out that allow the CPU to take in information and send it back out

play02:01

The CPU fits into what's known as the motherboard the motherboard allows all the components in the pewter to connect to each other

play02:08

So we'll flip the CPU back over and plug it into the motherboard on

play02:12

The right of the motherboard is a place for something called RAM RAM is short for random access memory

play02:19

And it just contains all the data that is being processed by the CPU

play02:23

Let's learn a little bit more about RAM by looking at how the CPU and RAM interact

play02:28

For now well remove the wires on the left and move the motherboard over to make room for the RAM chip

play02:34

Ram consists of a list of addresses and at each of those addresses is a piece of data

play02:40

the CPU normally requests and processes each piece of data from RAM in order one after the other

play02:46

However, if the CPU is instructed to pull data out of order it can do so that is why it's called random access memory

play02:54

The data can be accessed randomly if it needs to be although normally. It's accessed in order

play02:59

When the computer first starts running a program it sends an address to RAM to begin retrieving that program

play03:06

The RAM address just consists of a series of ones and zeros representing on and off wires

play03:12

Ram doesn't do anything with that address though until the CPU also turns on the set or the enable wire

play03:18

If the enable wire is turned on Ram automatically sends whatever piece of data is at that address back to the CPU

play03:26

That data is then processed by the CPU accordingly

play03:30

Once the CPU is finished processing that piece of data it then sends another address to Ram

play03:36

Turns on the enable wire and gets the next piece of data from Ram this process happens over and over again inside the computer

play03:43

If the CPU needs to save data to Ram it outputs an address

play03:48

Output some data, and then turns on the set wire

play03:51

The RAM will then overwrite the data at that address with the new data

play03:56

But what is that data inside Ram because it just looks like a bunch of ones and zeros

play04:01

Well, it's made up of different things some of the most important pieces of data in RAM are the instructions

play04:08

Instructions just tell the CPU to do different things

play04:11

There are also numbers inside that data. These are numbers that you might want to add together compare or simply process in some way

play04:20

Another thing and this is kind of weird that is in the data is addresses at

play04:24

Particular memory addresses in RAM the data itself is also an address

play04:29

These addresses can be used for various things

play04:32

For instance if you want to output a number to an external device you have to know the address of that particular device

play04:38

Do you want to send data to the printer, or do you want to send it to the monitor for instance?

play04:43

There are also letters stored in RAM if you want to show some text on the screen

play04:47

You would actually store it as a bunch of ones and zeros and RAM

play04:51

Each letter is stored as a particular combination of ones and zeros according to a character code these character codes are arbitrary

play04:59

Someone just decided that this is a lowercase a and this is an uppercase G for instance

play05:05

So that's what's actually in the data inside Ram now

play05:09

Let's go back to seeing the data is just a bunch of ones and zeros and we'll now move the RAM chip

play05:14

into the RAM socket on the motherboard

play05:16

We'll then group the RAM addresses and data together

play05:19

Pull the CPU out of the motherboard and look at what's called the instruction set of the CPU

play05:25

As we saw earlier some of the pieces of data in RAM are instructions and each CPU has its own set of instructions that it

play05:33

Understands so there might be a load instruction which loads a number from RAM into the CPU

play05:40

After a couple of these load instructions there might be an add instruction that adds these two numbers together

play05:46

After an add instruction might be a store instruction, which saves the result of that addition back out to RAM to be used later on

play05:53

There might also be a compare instruction after some load instructions, which compares two numbers together to see which one is larger

play06:01

or if they are the same

play06:03

the compare instruction can be very useful when used in conjunction with what's called a jump if

play06:08

Instruction as we saw earlier the CPU generally requests each piece of data from RAM in order one after the other

play06:17

Sometimes though the programmer wants to jump to an out of order ram address to process some other instructions and memory

play06:23

The jump if instruction checks to see if a certain condition is true before it jumps

play06:29

It uses the results of the compare instruction to make this decision

play06:33

There is also a regular job instruction that jumps no matter what?

play06:38

finally there is an out instruction and an in instruction these will output data to an external device like a monitor or

play06:46

Input data from an external device like a keyboard

play06:50

These two instructions are often used in conjunction with an address like we talked about earlier

play06:55

There are some other instructions in the CPUs instruction set that these are some of the more commonly seen ones

play07:02

So as we saw the data in RAM consists of things like instructions

play07:07

numbers addresses and letters

play07:10

So let's go through a program. That would use this instruction set to play a guessing game

play07:15

So it would load a number like nine into the CPU

play07:19

Let's say that the programmer decided that that was the right answer

play07:22

So he went ahead and put that number into RAM and then comes an end instruction to retrieve the user's guess after

play07:29

The in instruction is the address of the keyboard so we can know where we're getting the data from

play07:34

Next comes a compare

play07:36

Instruction that checks to see if those two numbers the one saved by the programmer and the one entered by the user are the same

play07:44

Following the compare instruction is a jump if equal instruction which will jump to another address in RAM if those two numbers

play07:51

We just talked about are the same

play07:53

the jump if equal instruction is immediately followed by a new RAM address if

play07:58

The two numbers are the same

play08:00

The CPU jumps to that new address to begin processing its next set of instructions from there if the two numbers are not the same

play08:07

Then the computer ignores the jump if equal instruction and the corresponding address and just keeps going

play08:14

Following the jump to address comes an out instruction with the address for the monitor, then the letter capital G

play08:21

And then below that would be the letters U e

play08:25

SS. Space again, so guess again

play08:29

So if the user guesses the wrong number the program would tell him to guess again

play08:33

And then jump back up to the in instruction to retrieve that new guess and then process these instructions all over again

play08:41

By the way the in and instructions used here have been simplified somewhat, but you'll find them covered in more detail in the book

play08:49

So now let's briefly take a look inside the CPU itself to see how it would process an instruction

play08:56

as we saw earlier

play08:57

This is the inside of the 6502 CPU

play09:01

Let's take away the 6502 wiring and see what's inside the Scot CPU

play09:06

The first component is the control unit which is kind of like a captain in the army

play09:11

it receives its orders from RAM in the form of an

play09:14

instruction and then breaks that instruction down into specific commands for the other components

play09:20

One of the most important components under the command of the control unit is the arithmetic logic unit or ALU for short?

play09:27

The ALU is what performs all the mathematical operations inside the CPU such as addition subtraction

play09:34

Or even comparison like we saw earlier

play09:37

The arithmetic logic unit has two inputs will label them input a and input B and assume

play09:43

They are two numbers from some previous load instructions

play09:47

Now we might want to add those two numbers together

play09:50

The control unit receives that instruction from RAM and then tells the ALU what type of operation to perform

play09:57

The ALU performs the operation and then outputs the answer

play10:01

Sometimes though depending upon the type of instruction the output from the ALU can actually be ignored

play10:07

For instance if you have a compare instruction the ALU doesn't need to output an answer instead

play10:14

It just needs to tell the control unit how the two numbers compare to each other

play10:18

for this the ALU uses

play10:20

What are called flags and they help the control unit decide what to do when it receives the next?

play10:26

Instruction like jump if which we'll see later

play10:29

For now though. Let's say that we are working with an instruction that does produce an output. Where does that output actually go?

play10:36

well the eight wires coming out of the ALU would actually run to what is called a register a

play10:42

Register is a very simple component whose only job is to store a number temporarily

play10:47

registers act just like RAM except

play10:50

They are inside the CPU making them faster and more useful for storing a number temporarily Wow instructions being processed

play10:58

When the ALU sends the output to the register it won't actually be saved until

play11:03

the control unit turns on the registers set wire

play11:06

The set wire is just like the one we saw earlier for RAM

play11:10

When the set wire is turned on the register saves whatever number is on its input wires

play11:16

Once we have the output saved in the register though. How do we get it back out?

play11:21

Well when we are ready to move a number out of the register we need another control wire called the enable wire

play11:27

That also runs from the control unit to the register as soon as the control unit turns the enable wire on

play11:34

The register will output whatever number is saved inside

play11:37

the output wires of the register then connect to what is called the CPU bus a

play11:42

Bus as we saw earlier on the motherboard is simply a group of wires that connect multiple components inside a computer on

play11:50

The bus are some other registers with their own set and enable wires

play11:55

These may have numbers from previous instructions already saved inside

play11:59

so the control unit will then turn on the set wire of the

play12:02

Particular register that it wants to save that number to and that number will be saved in that register

play12:08

Afterward the control unit will then turn off the enable wire from the first register and clear the bus

play12:14

The four registers at the top are just used for storing numbers between operations

play12:19

So they have output wires that go directly back onto the bus

play12:24

So now we have moved a number from one register to another just by turning some wires on and off

play12:29

That's the advantage of the bus easily moving numbers between components

play12:34

The disadvantage of the bus is that you can only have one number on it at a time

play12:39

Because of this limitation the arithmetic logic unit uses a temporary register for input B

play12:45

When the control unit is processing an instruction involving the ALU it will move one of the inputs to the temporary register

play12:52

The temporary register has no need for an enable wire since it only outputs to the ALU and doesn't conflict with any other registers

play13:01

The other input to the ALU comes directly from the bus

play13:04

The control unit will enable another register and that number will become input a to the ALU that

play13:11

number stays on the bus until the ALU is finished processing the instruction and

play13:16

So now there are two inputs to the ALU and we're ready for the ALU to perform an operation

play13:22

As we saw earlier the control unit knows what operation to tell the ALU to perform

play13:28

Because of the instruction it receives from rim

play13:31

The instruction itself is an another register called the instruction register

play13:36

By the way the input wires from the bus won't affect this register since the instruction was already saved in a previous step

play13:43

This register like the temporary register, also has no need for an enable wire since it just outputs to the control unit

play13:51

Based upon this instruction the control unit then tells the ALU what type of operation to perform

play13:58

So let's say the instruction. We're processing is a compare instruction with the compare instruction

play14:03

We're not interested in the number that is output by the ALU

play14:07

We only want to know how the two inputs compare to each other

play14:11

For that we use the flags that we talked about earlier

play14:14

Each flag is just a wire that turns on or off depending upon whether or not a certain condition is true

play14:21

Inside the Scott CPU there are four flags, and we'll look at two of them now

play14:26

The a is larger flag will turn on if input a is larger than input B

play14:31

if the inputs are the same

play14:33

Then the equal flag turns on and if both of these flags are off that means input B is larger

play14:40

But in this case the equal flag is on so that means both inputs are the same

play14:46

Once the compare instruction is over. We still need to use the flags for the next instruction

play14:51

So we'll save them to a register that only has 4 inputs and four outputs one for each flag

play14:57

Once the flags are set into the flags register the CPU is finished with the compare instruction and it can then request the next

play15:05

instruction from REM

play15:07

generally the next instruction after a compare instruction is a jump if

play15:11

instruction this combination of a compare and a jump if instruction by the way is very common in

play15:17

programming

play15:19

Anytime there is more than one possible path through a program the computer is using these instructions to tell it which way to go

play15:26

So now that we're finished with the compare instruction and our flags are saved in the flags register

play15:31

We need to tell RAM that we're ready for the next piece of data in this case the next instruction

play15:36

So inside the CPU another register that is very important is what's called the instruction address register

play15:44

The CPU uses this register to know where the next instruction should come from in RAM

play15:49

When the CPU is ready for the next instruction it enables the instruction address register onto the bus

play15:56

eventually the instruction address will flow to RAM

play15:58

But it doesn't get there directly there is an intermediary register called the memory address register

play16:05

Whose only job is to tell Ram what memory address the CPU wants next since it won't always be an instruction

play16:13

Once the instruction address is set into the memory address register it has automatically sent to RAM since the memory address register

play16:20

Doesn't have an enable wire the control unit then turns on the enable Ram wire and RAM

play16:27

Automatically sends back the data at that address which in this case is an instruction

play16:32

That instruction is then saved in the instruction register, and the control unit begins processing it in

play16:38

This case it's a jump if equal instruction, which checks to see if the equal flag is on

play16:44

It does that by running one of its wires and the equal flag wire into a NAND gate

play16:50

If both inputs to the and gate or on then the output wire turns on as well

play16:56

This output wire will then trigger the jump that

play16:59

jump eventually retrieves the next piece of data from RAM

play17:03

Which happens to be an address and move it into the instruction address register

play17:08

when the jump if equal instruction is over the CPU then processes the instruction at that new address at

play17:15

That new address, maybe some instructions that output the text you guessed correctly onto the screen because now we know that the user guessed correctly

play17:23

So we'll add the final four wires to our CPU which are used to control the external devices like the monitor and keyboard

play17:30

We now have a nearly complete picture of what the Scotts CPU looks like

play17:35

Data moves around inside the CPU using the bus and is stored in each register according to how that data is going to be used

play17:43

Each instruction that we have seen can be processed by the Scott CPU in about 6 clock ticks

play17:49

Modern CPUs can process multiple instructions per clock tick meaning that the computer you're using to watch this video is likely

play17:57

processing tens or even hundreds of billions of instructions per second

play18:02

that phenomenal speed is accomplished by using more than one of each component and

play18:07

Making sure that all the components are active as much as possible

play18:10

This makes modern CPUs much more complicated than the Scott CPU

play18:14

But they are still fundamentally doing the same things as the Scott CPU

play18:19

So now let's zoom back out and we can see all the wires that run back out to the pins on the chip on

play18:25

The right are the set RAM and enable RAM wires on

play18:28

The top are the RAM address wires on the bottom are the data wires that run to both RAM and the external devices

play18:36

And on the left are the input/output control wires

play18:40

So let's zoom back out to see the rest of the chip

play18:42

And we'll put the cover back on the CPU and put it back in the motherboard

play18:48

Using the ports on the Left we can now plug in the cables that connect our monitor and our keyboard

play18:53

Each of these ports has an address and that port address is what the CPU uses with an in or an out instruction

play19:00

That port address by the way is sent using the data bus since the address bus in this computer is only used for RAM

play19:07

So we'll zoom out to see how the motherboard fits inside the computer case in the computer case is the last component

play19:14

we'll look at which is the hard drive as

play19:17

Soon as the power to the computer is turned off all the data and RAM is lost so you have to have a way to

play19:23

Store it more permanently for that we use a hard drive

play19:27

Inside the hard drive is a spinning disk covered in tiny magnets with a small metal arm floating above it

play19:34

The arm moves around to the different parts of the disk where a different data can be stored and retrieved

play19:39

The disk and the arm generally move very very quickly, but nowhere near as fast as the CPU can process data

play19:47

For this reason all the data from the hard drive must first be moved to RAM before it can be processed

play19:53

So we'll put the hard drive back inside the computer and zoom out here. We can see the program

play19:58

We just ran and the message telling the user that he guessed correctly

play20:02

So now you've seen the very basics of how a computer processes information

play20:06

You'll find much more about the Scot CPU in the book at the website, but how do it know comm?

play20:13

Also, there are a few small differences between the book and the video

play20:16

But those shouldn't detract from your understanding of either you can find a list of these differences in the video description. Thanks for watching.

play20:20

Whatever you do, work at it with all your heart, as working for the Lord, not for human masters -Colossians 3:23

Rate This

5.0 / 5 (0 votes)

相关标签
CPU FunctionsComputer Science6502 SimulationTech EducationData ProcessingALU OperationsControl UnitMemory AccessInstruction SetHardware BasicsComputer ArchitectureTech TutorialMicroprocessorDigital LogicComputer ComponentsEducational ContentTech Simulation
您是否需要英文摘要?