Presentation is loading. Please wait.

Presentation is loading. Please wait.

Following Instructions: Principles of Computer Operation

Similar presentations


Presentation on theme: "Following Instructions: Principles of Computer Operation"— Presentation transcript:

1 Following Instructions: Principles of Computer Operation
Chapter 3 Following Instructions: Principles of Computer Operation Learning Objectives: Describe how the Fetch/Execute Cycle works, listing the five steps Explain the function of the memory, control unit, ALU, input unit and output unit, and program counter Explain why integration and photolithography are important in integrated circuits Discuss the purpose of an operating system Explain the purpose of a compiler Describe how large tasks are performed with simple instructions

2 Instruction Execution Engines
What computers can do Deterministically perform or execute instructions to process information. Methodical, no choice. Rerun a program w/same data  should get same result The computer must have instructions to follow What computers can't do (?) Have no imagination or creativity Have no intuition Have no sense of irony, subtlety, proportion, decorum, or humor Are not vindictive or cruel Are not purposeful Have no free will At least not as we currently define these!

3 The Fetch/Execute Cycle
Used to execute all programs A five-step, hardwired, repeating, never-ending sequence: Instruction Fetch (IF) Instruction Decode (ID) Data (Operand) Fetch (DF) Instruction Execution (EX) Result Return (Store) (RR) “Instruction Execution Engine”…a machine that cycles through a series of operations Get the next instruction Figure out what to do Gathering the data needed to do it Do it Save the result, and Repeat (billions of times/second)!

4 Anatomy of a Computer Computers have five basic parts or subsystems
Memory, control unit, arithmetic/logic unit (ALU), input unit, output unit

5 Memory Memory stores both the program running and the data on which the program operates Properties of memory: Discrete locations. Each location typically consists of 1 byte (8 bits). Addresses. Every memory location has an address (whole numbers starting with zero) Values. Memory locations record or store values Finite capacity. Limited size—programmers must remember that the data may not "fit" in the memory location

6 Byte-Size Memory Location
A commonly used diagram of computer memory represents the discrete locations as (1-byte) boxes. Address of location is displayed above the box. Value or contents of location is shown in the box.

7 Memory (cont'd) 1-byte memory locations can store one ASCII character, or a number 0 – 255 8 bits can store 256 different patterns Programmers often use a sequence of memory locations together, ignoring the fact that they all have different addresses Blocks of four bytes are frequently used as a unit. Called memory "words“ ( words can also be 16,32,64,128 bits, etc.)

8 Random Access Memory (RAM)
"Random access" means the computer can refer to the memory locations in any order Memory capacity is often measured in megabytes (MB) or gigabytes (GB) Large memory is preferable because there is more space for programs and data

9 Control Unit Hardware implementation of the Fetch/Execute Cycle
Its circuitry fetches an instruction from memory and performs the other operations of the cycle on it A typical instruction might have the form: ADD 4000, 2000, (op dest, src1, src2) This instruction asks that the numbers stored in locations 2000 and 2080 be added together, and the result stored in location 4000 Data Fetch step must get these two values and after they are added, Result Return step will store the answer in location 4000

10 Arithmetic/Logic Unit
Performs the math using logic gates (AND, OR, etc.) Generally does the work during the Instruction Execute step of the Cycle A circuit in the ALU can add two numbers There are also circuits for multiplying, comparing, etc. Instructions to just transfer data usually don't use ALU Data Fetch step of the Fetch-Execute Cycle gets the values that the ALU needs to work on (operands) When the ALU completes the operation, Return Result step moves the answer from the ALU to the memory address specified in the instruction The ALU carries out each machine instruction with a separate circuit (all designs? )

11 Input Unit and Output Units (I/O)
The wires and circuits through which information moves into and out of a computer Not all I/O is for people! The peripherals: Connect to the computer input/output ports. They are not considered part of the computer, but specialized gadgets that encode or decode information between the computer and the physical world.

12 Some Peripherals Keyboard encodes keystrokes we type into binary form for the computer Monitor decodes information from the computer's memory and displays it on a lighted, colored screen Disks and drives are used for both input and output — storage devices where the computer puts away information when it is not needed, and can retrieve from when it is needed again Others? Hard disk is essential Programs and their data must reside in the computer’s memory when programs run The hard disk can be seen as an extension of the computer’s memory Typically it is a hundred times larger and several thousand times slower

13 A Device Driver for Every Peripheral
"Dumb" devices provide basic physical translation to or from binary signals. Additional information from the computer is needed to make it operate intelligently. For example the computer receives information that user typed shift and w at the same time. It converts to a capital W. The software that converts (processes keystrokes) is called the device driver.

14 The Program Counter: The PC's PC
How does the computer determine which step to execute next? Address of the next instruction is stored in the control part of the computer. It is called the program counter (PC) If instructions use 4 bytes of memory, the next instruction must be at PC + 4, 4 bytes further along in the sequence Computer adds four to the PC, so when the F/E Cycle gets back to Instruction Fetch step, the PC is "pointing at" the next instruction Example: Bootloader start address loaded into Program Counter at Boot

15 Branch and Jump Instructions
An instruction may include a memory location (address) to go to next. Like the “goto” instruction in some programming languages This changes the PC, so instead of going to PC + 4 automatically, the computer "jumps" or "branches" to the specified location. Like Conditional (IF) statements or Function Calls in Python Example: Choice in a game program

16 Instruction Interpretation
Process of executing a program Computer is interpreting our commands, but in its own language ADD the values found in memory locations 428 and 884 and store the result in location 800

17 Execution (Cycle) begins by moving the instruction at the address given by the PC from memory to the control unit The Fetch/Execute Cycle A five-step cycle: Instruction Fetch (IF) Instruction Decode (ID) Data Fetch (DF) / Operand Fetch (OF) Instruction Execution (EX) Result Return (RR) / Store (ST)

18 Instruction Fetch (cont.)
Bits of the instruction are placed into the decoder circuit of the CU Once an instruction is fetched, the Program Counter (PC) can be readied for fetching the next instruction The PC is “incremented” (or updated by a jump instruction.)

19

20 Instruction Decode (ID)
In the Instruction Decode step, the ALU is set up for the indicated operation The Decoder will find the memory address of the instruction's data (source operands) Most instructions operate on 2 data values stored in memory (like ADD instruction), so most instructions have addresses for two source operands These addresses are passed to the circuit that fetches the values from memory during the next step, Data Fetch The Decoder finds destination address for the Result Return step, and places it in RR circuit Decoder determines what operation the ALU will perform, and sets it up appropriately

21

22 Bits are copied, values remain in memory
Data Fetch: The data values to be operated on are retrieved from memory Bits at specified memory locations are copied into locations in the ALU circuitry Data values remain in memory (they are not destroyed) Bits are copied, values remain in memory

23 Instruction Execution (EX)
Instruction Execution: The actual computation is performed in the ALU Example: for the ADD instruction, the addition circuit adds the two source operands together to produce their sum Sum is held in the ALU circuitry This is the actual computation

24

25 Return Result (RR) Result Return: result of execution is returned to the memory location specified by the destination address. Bits for the data value are moved from ALU circuitry to memory circuitry Once the result is returned, the cycle begins again (This is a Loop).

26

27

28

29 Many, Many Simple Operations
Most computers can only perform about 100 different instructions About 20 different kinds of operations (different instructions are needed for adding bytes, words, decimal numbers, etc.) Everything computers do must be reduced to some combination of these primitive, hardwired instructions

30 Examples of Some Other Instructions
Besides ADD, MULT (multiply) and DIV (divide), other instructions include: Shift the bits of a word to the left or right, filling the emptied places with zeros and throwing away bits that fall off the end Compute logical AND (test if pairs of bits are both true, and logical OR (test if at least one is true) Test if a bit is zero or non-zero, and jump to new set of instructions based on outcome Move information around in memory Sense signals from input/output devices

31 Cycling the F/E Cycle Computers get their impressive capabilities by executing many, many of these simple instructions per second Computer Clock: Determines rate of F/E Cycle Historically measured in megahertz (millions of cycles per second.) Now gigahertz! Integrated Circuits and Miniaturization: Clock speeds can be so high because processor chips are so tiny (electrical signals can travel about 1 foot in a nanosecond)

32 How Important is Clock Speed?
Modern computers try to start an instruction on each clock tick Pass off finishing instruction to other circuitry (pipelining) Up to Five instructions can be in process at the same time Does a 1 GHz clock really execute a billion instructions per second? Not a precise measurement. Computer may not be able to start an instruction on each tick, but may sometimes be able to start more than one instruction at a time A computer with a 1 GHz clock has one billionth of a second—one nanosecond—between clock ticks to run the Fetch/Execute Cycle. In that amount of time, light travels about one foot (~30 cm).

33

34 A computer's view of software:
Sees binary object file, a long sequence of 0’s and 1’s (typically 4-byte or 8-byte words) aka Machine Language Assembly language Alternative form of machine language using letters and normal numbers so people can understand it Computer scans assembly code, as it encounters words it looks them up in a table to convert to binary, converts numbers to binary, then assembles the binary pieces into an instruction Once installed, the computer runs the software by: copying the binary instructions into the RAM interpreting them using the Fetch/Execute Cycle. It does whatever the instructions tell it to do Assembly language is an alternative form of machine language that uses letters and normal numbers so people can understand it Computer scans assembly code As it encounters words it looks them up in a table to convert to binary Converts numbers to binary, then assembles the binary pieces into an instruction

35 Software and Programming Languages
High-level programming languages Most modern software is written in high-level notation, which is then compiled (translated) into assembly language, which is then assembled into binary. (Some HLL are interpreted, like Python) Have special statement forms to help programmers give complicated instructions Example: Three-part if statement Yes/no question to test Instructions to operate if test is true Instructions to operate if test is false HL languages are preferred because they have special statement forms that help programmers describe the complicated tasks they want done

36

37 Operating Systems Basic operations that are necessary for the effective use of computer, but are not built into the hardware. (Example: saving files) Three most widely used Operating Systems: Microsoft Windows Apple's MacOSX Unix (Linux) OS performs booting, memory management, device management, User Interface, Internet connection, file management, etc. Connects the user/programmer to the computer OS fills the gap between the limited capabilities of the hardware and the needs of a useful working environment User applications draw on OS facilities (Example, when you save your work, the software asking for file name/location is provided by the OS)

38 Programming Programmers often build new functionality on previously developed software to make their jobs easier Simple operations combined into more complex systems Recall: Software Stack (Ch.1) Example: GUI Software Frame around window, slider bars, buttons, pointers, etc. are packaged for programmers and given with OS to be reused Software stack: layers of software of increasing complexity It is the result of programmers building on the work of other programmers All of the software for a user interface (window frame, slider bars, buttons, menus, etc.) are packaged for programmers and provided with the operating system The ability to create software by combining other software is known as functional composition

39 How Semi-conductor Technology Works
Integrated Circuits (ICs): Active components and the wires that connect them are all made together of similar materials in a single process Saves space and produces a monolithic part (chip) for the whole system, which is more reliable (once tested/burned in) Silicon is a semi-conductor—sometimes it conducts electricity, sometimes not Ability to control when semi-conductor conducts is the main tool in computer construction The basis of all the operations of a computer Miniaturization Computer clocks run at GHz rates because their processor chips are so tiny Electrical signals can travel one foot (30 cm) in a nanosecond Early computers (the size of whole rooms) could never have run as fast because their components were farther apart than one foot Making everything smaller has made computers faster Early computers were made from separate parts (discrete components) wired together by hand There were three wires coming out of each transistor, the two wires from each resistor, the two wires from each capacitor, and so on Each had to be connected to the wires of another transistor, resistor, or capacitor Active components and the wires that connect them are manufactured from similar materials by a single (multistep) process IC technology places two transistors side by side in the silicon, and a wire connecting the two is placed in position

40 The On-Again, Off-Again Behavior of Silicon
A circuit is set to compute x and y for any logical values x and y If x is true, the x circuit conducts electricity and a signal passes to the other end of the wire; if x is false, no signal passes Same process for y In the ALU hardware, the circuit computes x AND y for any logical values x and y Such a circuit is part of the ALU, performing the Instruction Execute step of the AND instructions

41 Logical From Physical: Transistors
If both circuits conduct, x and y are true — logical AND has been computed Transistor: A connector between two wires that can be controlled to allow charge to flow between the two wires, or not

42 Conductivity of a semiconductor is controlled using the field effect
Objects can be charged positively or negatively The effect that charged objects have on each other without actually touching is called the field effect The field effect controls a semiconductor The ends of the two wires are specially treated (doped) to improve their conducting/nonconducting properties The part between the ends is called a channel, because it creates a path for electricity to travel on An insulator covers the channel Passing over the insulator is a third wire called the gate The silicon in the channel can conduct electricity when it is in a charged field Charging the gate positively creates a field over the channel Electrons are then attracted from the silicon into the channel, causing it to conduct If the field is removed, the electrons disperse into the silicon, the channel doesn’t conduct A transistor is a connector between two wires that can be controlled to allow a charge to flow between the wires (conduct) or not The transistor is a MOS (Metal Oxide Semiconductor) transistor Modern computers are developed with CMOS technology (“complementary MOS”)

43 Combining the Ideas = Computation
Start with an information processing task Task is performed by application, implemented as part of a large program in a high-level language like C or Python Program performs specific operations; standard operations like print or save are done by OS Program's commands compiled into assembly language Assembly instructions are translated into binary code (ML) Binary instructions are stored on hard disk Application instructions move into RAM Fetch/Execute Cycle executes the instructions All the computer's instructions are performed by the ALU circuits, using the transistor model, controlled by CU You learned the following: The repeating process fetches each instruction (indicated by the PC), decodes the operation, retrieves the data, performs the operation, and stores the result back into the memory. This process is hardwired into the control subsystem, one of the five components of a processor. The memory, a very long sequence of bytes, each with an address, stores the program and data while the program is running. The ALU does the actual computing. The input and output units are the interfaces for the peripheral devices connected to the computer. Machine instructions do not refer to the data (operands) directly, but rather indirectly. Thus, different computations can be done with an instruction, just by changing the data in the referenced memory locations each time the instruction is executed. Programmers must create complex computations by software layers, building up simple operations from the base instructions, more complex operations from the simple ones, and so forth. Programmers use sophisticated programming languages to create operating systems as well as complex applications software. The basic ideas of integrated circuits are integrating active and connective components, fabrication by photolithography, and controlling conductivity through the field effect.


Download ppt "Following Instructions: Principles of Computer Operation"

Similar presentations


Ads by Google