Grade 9 Ch1 PDF
Document Details
Tags
Summary
This document is a chapter from a Grade 9 textbook on computer science. It explains computer systems, processors, and how the central processing unit (CPU) works. It covers topics such as what computers are, the components of a computer system (including input, output, and storage), and in detail about the processor.
Full Transcript
# 1.1 Central Processing Unit ## In this lesson You will learn: - what happens inside a processor - about the parts of a computer's central processing unit (CPU). ## Computer systems You have gained a lot of experience of using computers on this course and have learned many new and useful skills....
# 1.1 Central Processing Unit ## In this lesson You will learn: - what happens inside a processor - about the parts of a computer's central processing unit (CPU). ## Computer systems You have gained a lot of experience of using computers on this course and have learned many new and useful skills. Whenever you use a computer you are using a system. A computer system is a set of equipment that works together to help you do useful work. A computer system can be drawn as a simple diagram. A computer system must always have input devices. Input devices allow you to put data into your computer. A keyboard is an input device. A computer system has output devices. Output devices let you see the results of your work on the computer. A computer screen is an output device. A computer system has storage devices. You use storage devices to save your work. ## The processor At the centre of your computer system is a processor. A processor is small enough to fit on your fingertip. Modern processors are so small they are called microprocessors. ## Spiral Back In Student Book 7 you learned that every file you store and use on a computer is made up of digital data. You learned that the brain of a computer is a microprocessor. Inside the processor are millions of tiny electronic switches. In this unit you will learn more about how the processor carries out its work. ## The central processing unit (CPU) The central processing unit (CPU) is another name for the microprocessor at the centre of your computer system. It is the name to use when you study the computer processor in detail. The CPU has three important parts: the control unit, the arithmetic and logic unit, and the clock. ### The control unit The control unit manages the work done by the CPU. - When an instruction arrives at the CPU, it goes to the control unit. - The control unit works out what the instruction means. - The control unit makes sure that the other parts of the CPU do the work needed to carry out the instruction. ### The arithmetic and logic unit (ALU) The arithmetic and logic unit (ALU) does all the calculations in the CPU. If you are working on a maths problem, you might use a spreadsheet to do your calculation. The control unit uses the ALU in the same way. The control unit sends instructions to the ALU. The ALU carries out the instructions. ### The clock The clock sends out regular electrical pulses just like the tick of a clock. A clock in your home ticks every second. The clock in the CPU of your computer ticks around 3 billion times every second. Every time the CPU clock ticks, the control unit sends an instruction to the ALU. ## The CPU - Control unit - ALU - Clock ## Buses The three parts of a CPU are joined together by connections called buses. Buses are high speed connections that carry data around inside the CPU. They are like the buses you see travelling around towns and cities. Instead of carrying passengers, the buses in a CPU carry data at very high speed. ## How the CPU works Think about the last time you played a game or watched a video on a computer. The screen is full of colour. The images you see are lifelike. Objects move just like they do in the real world. Movement on-screen is smooth and fast. If you are playing a game, you can give instructions through a joystick or game controller. The action on-screen responds immediately to your command. High-quality audio is being played in the background while you play. When you experience a game being played on a computer it is easy to think that the CPU must be doing very complicated things. In fact, the CPU can perform only very simple instructions. For example, a CPU might be asked to add two numbers together with an instruction like 'ADD 2, 3'. Even this simple task has to be broken down into several smaller tasks before the CPU can complete it. So a CPU can only do very simple tasks. What makes it seem so powerful is that it can do a task every time its clock ticks. The clock in a CPU clicks 3 billion times every second. A computer can appear to do amazing things by doing a lot of very simple tasks, very quickly. # 1.2 The Fetch-Execute cycle ## In this lesson You will learn: - what computer memory is - what happens when a computer carries out an instruction. ## Memory and the CPU The CPU is the part of the computer that carries out instructions. You learned in the last lesson that it is made of a control unit, the ALU and a clock, all connected by buses. The computer’s memory is very close to the CPU. It is joined to the CPU by buses. Some people use the word ‘processor’ to mean the CPU and the memory. The computer’s memory is sometimes called: - The memory unit - IAS (Immediate Access Store) - RAM (Random Access Memory). ## What is in memory? Memory holds: - The instructions that tell the computer what to do - The data values that the computer needs. In a modern computer the instructions and data are held in the same memory. But they go down two different buses to the CPU. The memory holds one more thing: the results of the CPU’s work. When the CPU has completed an instruction, it sends the results back to memory. ## How does memory work? Memory is made of microscopic electrical circuits. The circuits can be on or off. Everything inside the memory is stored using these on/off signals. If you completed Unit 1 of Student Book 7, you learned how data is stored inside the memory using on/off signals. ## Memory and storage Data is stored in memory as electrical signals. But if the electricity is turned off, all the data will be lost. This is why you must always save your work before you turn the computer off. When you save your work, it is copied from memory to storage. Here are some examples of storage: - The hard disk of your computer - A flash memory drive - The storage on your school network - Cloud storage on the internet. The important thing about storage is that it stores the data even when the computer is turned off. That means that your work is not lost. Storage is also called secondary storage. ## Advantages and disadvantages Both RAM (electronic memory) and storage have advantages and disadvantages. ### RAM RAM is very close to the CPU. The CPU can get data and instructions from RAM easily and quickly. The disadvantage of RAM is that its contents are lost when the computer is switched off. ### Secondary storage Secondary storage is further away from the CPU. It takes longer for the CPU to get data and instructions from secondary storage than from RAM. But secondary storage has a big advantage – it can keep data and instructions safe when they are not needed, or when the computer is turned off. # 1.3 The CPU and Logic ## In this lesson You will learn: - how the ALU processes logical problems - how to write a logical argument - how to draw a truth table. ## Arithmetic and logic You have learned that the CPU contains an arithmetic and logic unit. In the activity in Lesson 1.2 you learned how the ALU can do arithmetic. If you are playing a game on your computer, you can see the result of the ALU performing arithmetic. For example, the strength of your character increases when you pick up energy during a game. A value is added to your existing strength total. A game would not be interesting if it only used arithmetic. A game must also include challenges. For example: - Does the treasure chest contain gold coins? - Does the key open the treasure chest? Challenges like these cannot be solved using arithmetic. They need logic. In this lesson you will learn what logic is and how it is used by the ALU. ## What is logic? Think about the statement ‘the treasure chest contains gold’. There are two possible conditions. The statement can be true or false. ‘The key opens the treasure chest’ is a logical statement. A logical statement can be used to say if something is true or false. ## Logic and the ALU The computer is a digital device. A computer processor is made up of electrical switches. The electrical switches in a computer can be on or off. A computer is called a two-state device. Logic also has two states. The two states are true and false. A logical statement can be true or it can be false. A computer’s ALU can process logical statements. It can do so because both logic and the computer use two states. ## Linking logical statements Logic is not just about saying whether statements are true or false. Logical statements can also be used to draw conclusions from data and make decisions. To use logic to draw conclusions you must be able to combine logical statements. The word ‘then’ is used to combine logical statements. Here are two logical statements about a computer game: - Player has no lives. - Game is over. Each of the two statements can either be true or false. You can link the two logical statements using the word THEN: - Player has no lives THEN Game is over. When two statements are linked, they can be used to draw conclusions. We can say: - ‘Player has no lives’ is true THEN ‘Game is over’ is also true. - ‘Player has no lives’ is false THEN ‘Game is over’ is also false. ## Parts of a logical statement To make it easier to talk about logic, the two parts of a linked statement have names. In a logical statement, everything to the left of THEN is called the **proposition**. Everything to the right of THEN is called the **conclusion**. The whole statement is called a **logical argument**. | Proposition | Then | Conclusion | |---|---|---| | Player has no lives | | Game is over | ## Truth tables A truth table is a way of laying out a logical statement in table form. It is easier to understand the logic when it is laid out in a table. A written description can be confusing, especially for complex logical statements. There are four steps in creating a truth table. 1. Write out the argument. Always write THEN in upper-case letters to show that it links the statements: Player has no lives THEN Game is over 2. Create the column headings. Your table needs a column for each statement in your argument. There are only two statements in this example but there can be more.. Always write the conclusion in the last column on the right. There is no need to use #THEN in your table. Player has no lives Game is over 3. Add a row for every possible response to the proposition. In this example, the proposition is ‘Player has no lives’. There can only be two responses: false or true. Player has no lives Game is over FALSE FALSE TRUE TRUE 4. Complete the conclusion column. Fill in the correct value for each possible response to the proposition. Player has no lives Game is over FALSE FALSE TRUE TRUE In this simple example we have used logic to show that when a player has no lives in a game, then the game is over. Logic also shows that when the statement ‘Player has no lives’ is false, then ‘Game is over’ is also false. While you have lives, you can keep playing. # 1.4 Complex logical statements ## In this lesson You will learn: - how to link logical statements using AND/OR - how to write complex logical arguments that include more than two statements. ## Increasing complexity In the last lesson you learned that computers can handle logic problems as well as arithmetic. You saw how a simple problem can be written as a logical statement like this one: Player has no lives THEN Game is over All the examples in the previous lesson had just two parts linked by a THEN statement. ## Using AND to link logical statements The team manager decides to write the problem as a logical statement. He will hand the team owner a truth table to make sure the right player is found. He will use the four stages described in Lesson 1.3. 1. **Write out the argument.** The first step is to identify the conclusion. There is only ever one conclusion to a logical argument. The conclusion is a desired outcome. In this case the conclusion is ‘Club signs player’. Once you have identified the conclusion, any other statements are part of the proposition. In this case there are two statements: ‘Player is left-footed’, ‘Player scored 30 goals’. The two statements must be joined together. Statements in the proposition can be joined using AND or OR. In this case, the manager wants both statements to be true. If both statements must be true, join them with AND. Player is left-footed AND Player scored 30 goals THEN Club signs player. 2. **Create the column headings.** In this example the table must have three columns. The conclusion must always go in the column on the far right of the table. | Player is left-footed | Player scored 30 goals | Club signs player | |---|---|---| 3. **Add a row for every possible response to the proposition.** A two-part statement always needs the four responses in the table below. Read them carefully. Make sure you understand that no combination of true/false is missed out. | Player is left-footed | Player scored 30 goals | Club signs player | |---|---|---| | FALSE | FALSE | | | TRUE | FALSE | | | FALSE | TRUE | | | TRUE | TRUE | | 4. **Complete the conclusion column.** The two parts of the proposition are joined by AND. This means that the conclusion will be true only if both parts of the proposition are true. | Player is left-footed | Player scored 30 goals | Club signs player | |---|---|---| | FALSE | FALSE | FALSE | | TRUE | FALSE | FALSE | | FALSE | TRUE | FALSE | | TRUE | TRUE | TRUE | The final table tells us that ‘Club signs player’ is true only when both ‘Player is left-footed’ AND ‘Player scored 30 goals’ are true. If either of the statements is false, then ‘Club signs player’ is also false. ## Using OR to link logical statements Here is a different kind of problem. An extra life is awarded in a computer game if the player reaches 10,000 points or collects five stars during a game. In this example, use the word OR to join the statements together. It will look like this: 10,000 points reached OR five stars collected THEN extra life awarded A truth table will help to make sense of this statement. This time we will jump straight to step 3: Add a row for every possible response to the proposition. | 10,000 points | Five stars | Extra life | |---|---|---| | FALSE | FALSE | | | FALSE | TRUE | | | TRUE | FALSE | | | TRUE | TRUE | | Notice that the true and false entries are the same as in the previous example. If you replace false with a 0 and true with a 1 you will have the binary numbers 00, 01, 10, 11. In decimal that is 0, 1, 2 and 3. That may help you remember how to write the true and false entries into the table. Step 4 is to complete the conclusion column. Extra life is true if either 10,000 points reached OR five stars collected is true. The completed table looks like this: | 10,000 points | Five stars | Extra life | |---|---|---| | FALSE | FALSE | FALSE | | FALSE | TRUE | TRUE | | TRUE | FALSE | TRUE | | TRUE | TRUE | TRUE | The table can be used to draw conclusions. The table tells you that if a player reaches 10,000 points or gathers five stars, they get an extra life in the game. Also, the player gets an extra life if both 10,000 points are reached and five stars are collected. # 1.5 Logic gates ## In this lesson You will learn: - how to describe the AND, OR and NOT logic gates used in a computer - how to draw truth tables for AND, OR and NOT gates - how computer logic gates compare to logic in the real world. A computer can carry out complicated tasks such as creating realistic game worlds. It can navigate spacecraft through space. How is this possible when a computer is only made up of switches that can be turned on or off? Those switches can be combined together into larger units. The larger units can perform more complicated tasks. Those units are called gates. In this lesson you will learn about three types of gate that are used in a computer: - the AND gate - the OR gate - the NOT gate. You have learned that logical statements using AND and OR can be used to describe situations we come across in everyday life and in computer games. Now you will learn how the computer’s ALU uses logic gates to control programs such as games. ## The AND gate You have learned how using AND in logical statements can describe problems. For example, you drew a truth table for the logical argument: Player is left-footed AND Player scored 30 goals THEN Club signs player Imagine you are writing a football manager game. How will the computer running the game make sure the manager signs the right player? The CPU is made up of millions of on-off switches. Those switches are organised into larger units called gates. One of those gates is the AND gate. Each type of gate that a computer uses has its own symbol. The symbol for the AND gate is shown in the image. The AND gate has two inputs. They are called A and B. The gate is inside the CPU so it can only understand binary. The value of each input can be either 0 or 1. The output of an AND gate is 1 if both input A and input B are 1. Otherwise it is 0. You can draw a truth table for the AND gate in the same way that you drew truth tables for logical statements in Lessons 1.3 and 1.4. 1. Label the table: The AND gate. 2. Insert column headings for all inputs and outputs. The AND gate A B Output 3. Enter the possible values for the inputs. The AND gate A B Output 0 0 1 0 1 1 4. Complete the output column. The AND gate A B Output 0 0 0 0 1 0 1 0 0 1 1 1 Check that you understand why the pattern of zeros and ones is as it appears in the table. This is an AND gate. The output is only 1 when both input A AND input B are 1. The pattern of zeros and ones in the AND gate truth table is exactly the same as the pattern of true/false in the truth table for the AND logical statement. That is how the CPU is able to carry out logical operations. ## The OR gate Another type of gate the computer uses is an OR gate. The OR gate has its own symbol too. The OR gate has two inputs. They are labelled input A and input B. It has one output. The value of each input can be either 0 or 1. The output of an OR gate is 1 if either input A or Input B or both is 1. The truth table for the OR gate looks like this. It is exactly the same as the OR truth table you saw in the last lesson. Because of this the CPU is able to use the OR gate to perform logic. The OR gate A B Output 0 0 0 0 1 1 1 0 1 1 1 1 Check that you understand why the pattern of zeros and ones in the output column is as it appears in the table. ## The NOT gate Other gates are used in a computer. They help us get the answers we need. A NOT gate has only one input and one output. A NOT gate reverses the input. If the input is 1 the output is 0. If the input is 0 the output is 1. The truth table for a NOT gate looks like this: The NOT gate Input Output 0 1 1 0 Gates always have only one output. All gates except the NOT gate have two inputs. ## Circuits In this lesson you have learned about the AND and OR gate. You have seen that they can be used by the ALU to solve logic problems. That is because they act in the same way as logic statements in the real world. Gates become more powerful and more useful when they are joined together. When gates are joined together, they form a circuit. The image shows a simple example of a circuit. To create a truth table for a circuit, you must create a column for every input and output. You must include any connections that link two gates. In this example there are two inputs to the left of the circuit (A and B) and an output on the right (Z). You also need a column for the input to the NOT gate (C). Enter all the possible values for the inputs, A and B, first. Then enter the values for column C. This is the output of the AND gate. Finally, enter the values for column Z, using the values in column C as the input. | A | B | C | Z | |---|---|---|---| | 0 | 0 | 0 | 1 | | 0 | 1 | 0 | 1 | | 1 | 0 | 0 | 1 | | 1 | 1 | 1 | 0 | # 1.6 Robots and Robotics ## In this lesson You will learn: - what robots are used for and what they might be used for in the future - about the technology used in robots. ## What is a robot? A robot is a machine that is designed and programmed to carry out tasks at speed and with great accuracy. A robot is autonomous. This means it can work independently without constant human intervention. A robot senses and responds to its environment. ## The advantages of robots - Robots carry out repetitive work reliably. They don’t get bored or make mistakes. - Robots work quickly. They can work for 24 hours a day if needed. - Robots can work in dangerous environments that would be risky for humans. - Robots can work in restricted spaces where humans cannot reach. - Robots work with hazardous materials like chemicals and radioactive material. ## Digital citizen of the future Robotics is the science and technology of robots. It is a growing area of work for computer scientists and engineers. Do you think you will work with robots in the future? Research the internet to find information on careers in robotics. ## How are robots used? Robots have become vital tools in many industries. The car and electronics industries already depend on robots. The range of jobs that robots are used for is growing as robot design improves. ## Robots in manufacturing In manufacturing industries, robots do repetitive jobs such as soldering electrical components or making microchips. Accuracy is very important in the production of microprocessors. A tiny mistake can mean the processor does not work properly. Robots work quickly and do not make mistakes. In car factories, robots are used to paint cars. This is a hazardous job for humans. ## Robots in agriculture Agriculture is one of the fastest growing areas for robots. Robots can be used both in glasshouses and out in the fields. Crop spraying by plane is one of the most dangerous jobs humans do. **Drones** are now used to spray crops. Robots are being developed to harvest crops including soft fruits like berries. Some farmers use tractors and other farm equipment that uses satellite guidance to plough fields and do other jobs. Fully autonomous tractors will soon be a feature on farms. Fully autonomous equipment has been developed for jobs like removing weeds. ## Robots in medicine Robots have many applications in medicine. Surgeons work with robotic surgical instruments to perform surgery they could not do with their own hands. This means that surgery can take less time and patients recover faster. Robotic equipment is used to scan patients. It can create a detailed 3D image of internal organs. This helps doctors to make an early and accurate diagnosis of illness. Robots are also being used to help patients recover. A robot has been developed that lifts patients in and out of bed. It is more comfortable for the patient and saves nurses from injury. ## Robots in distribution Distribution centres store goods that are sent out to shops or to customers who have purchased them online. Robots are used to pick goods that are to be sent to shops and customers. Distribution centres might use drones and autonomous robot vehicles in the future to deliver goods. Drones can deliver vital goods to remote areas quickly. ## Disaster recovery Natural and man-made disasters create dangerous environments for humans to work in. Buildings might be damaged and unstable. Areas might be polluted with chemicals or radioactive material. Fires might break out. Robots are ideal for this situation. They have sensors to help assess dangers. Infrared sensors can help detect people that need to be rescued. Robots can be equipped with mechanical tools to solve problems or take samples from a disaster site. ## The technology of robots The growth of robots has depended on the advances in technology. Some key developments are listed here. ### Sensors To be autonomous and act independently, robots must be able to sense the world around them. - **Proximity sensors** use infrared light beams to detect the position of nearby objects. - **Bumper switches** tell a robot that it has hit something. - **Pressure pads** are used to control robot hands as they pick objects up. They stop the robot hand crushing objects. There have been important new developments in recent years. ### Vision guided robotics (VGR) Vision guided robotics (VGR) allows robots to use video cameras to see in 2D and 3D. Sophisticated software allows a robot to identify objects and interact with them. In older robot systems, items had to be in the right position for the robot to pick up and use. ### Voice recognition and natural language processing (NLP) Voice recognition and natural language processing (NLP) are giving robots a sense of hearing. In time we might be able to speak and give instructions to a robot as if we were talking to a human assistant. ### Microprocessor development Microprocessors have become smaller and more powerful. This has allowed powerful processors to be embedded into robots. Embedded processors are important. They allow the robot freedom of movement. Robots carry the processing power they need with them. ### Parallel processing Parallel processing uses several CPUs working together to create faster, more powerful processors. Two, four or even eight CPUs work together. This provides the processing power needed by sophisticated robots. ### Artificial intelligence Artificial intelligence (AI) is the use of computers to simulate intelligent behaviour. Robotics is a major area of research in AI. In the future, AI might allow robots to learn and improve the way they do jobs without human input. Robots might use the cloud to pass what they have learned onto other robots. You will learn more about artificial intelligence in Unit 3. ## Real time operating systems Robots operate in the real world. They must respond to events as they happen. This is called real time. **Real time operating systems (RTOS)** have been developed to allow robots to work in the real world. An RTOS runs several jobs at the same time. Each job is given an importance rating. If an important job starts, it is given all the processing power it needs. Safety processes have a high importance rating. If the RTOS detects a possible collision, the process that avoids collision is given all the processing it needs. Other jobs stop until the important job has finished.