16.1 Unit 16 Computer Organization Design of a Simple Processor
16.2 You Can Do That… Cloud & Distributed Computing Scripting & (CyberPhysical, Databases, Data Networked Interfaces Mining,etc.) Applications Applications SW (AI, Robotics, Graphics, Mobile) Applications C / C++ / Java Systems & Networking OS Libraries (Embedded Systems, Networks) Assembly / Machine Code Processor / Memory / I/O Architecture (Processor & Embedded HW) Functional Units (Registers, Adders, Muxes) Where we will head now… HW Logic Gates Devices & Integrated Circuits (Semiconductors & Fabrication) Transistors Voltage / Currents
16.3 Motivation • Now that you have some understanding… – Of how hardware is designed and works – Of how software can be used to control hardware • We will look at how to improve efficiency of computer systems and software so that… – …we can start to understand why HW companies create the structures they do (multicore processors) – …we can begin to intelligently take advantage of the capabilities the HW gives us – …we can start to understand why SW companies deal with some of the issues they do (efficiencies, etc.)
16.4 Computer Organization • Three primary sets of components – Processor – Memory – I/O (everything else) • Tell us where things live? – Running code – Compiled program (not running) – Circuitry to execute code – Source code file – Data variables – Data for the pixels being displayed on your screen
16.5 Input / Output • Processor performs reads and writes to communicate with I/O devices just as it does with memory – I/O devices have locations (i.e. registers ) that contain data that the processor can access – These registers are assigned unique addresses just like memory Processor Memory 0 … 3FF A D C Video Interface 800 FE may FE 800 FE signify a WRITE … white dot at 01 a particular location ‘a’ = 61 hex Keyboard in ASCII Interface This could just as easily be the command and data register from 400 61 the LCD shield… Or the PORT/DDR registers.
16.6 Processor • 3 Primary Components inside a processor – ALU – Registers – Control Circuitry • Connects to memory and I/O via address , data , and control buses ( bus = group of wires) Bus Processor Memory Addr 0 1 2 Data 3 4 5 Control 6
16.7 Arithmetic and Logic Unit (ALU) • Executes arithmetic operations like addition and subtraction along with logical operations (AND, OR, etc.) Processor Memory Addr 0 op. 1 ALU 2 ADD, out in1 SUB, Data 3 AND, 4 in2 OR 5 Control 6
16.8 Registers • Some are for general use by software – Registers provide fast, temporary storage locations within the processor (to avoid having to read/write slow memory) • Others are required for specific purposes to ensure proper operation of the hardware Processor Memory PC Addr 0 op. 1 ALU 2 ADD, out in1 SUB, Data 3 AND, 4 in2 OR 5 R0-R15 Control 6
16.9 General Purpose Registers • Registers available to software instructions for use by the programmer/compiler • Instructions use these registers as inputs (source locations) and outputs (destination locations) Processor Memory PC Addr 0 op. 1 ALU 2 ADD, out in1 SUB, Data 3 AND, 4 in2 OR 5 R0-R15 Control 6
16.10 What if we didn’t have registers? • Example w/o registers: F = (X+Y) – (X*Y) – Requires an ADD instruction, MULtiply instruction, and SUBtract Instruction – w/o registers • ADD: Load X and Y from memory, store result to memory • MUL: Load X and Y again from mem., store result to memory • SUB: Load results from ADD and MUL and store result to memory • 9 memory accesses Processor Memory PC Addr 0 X op. 1 Y ALU 2 ADD, out in1 SUB, Data 3 F AND, 4 in2 OR 5 R0-R15 Control 6
16.11 What if we have registers? • Example w/ registers: F = (X+Y) – (X*Y) – Load X and Y into registers – ADD: R0 + R1 and store result in R2 – MUL: R0 * R1 and store result in R3 – SUB: R2 – R3 and store result in R4 – Store R4 back to memory – 3 total memory access Processor Memory PC Addr 0 X op. 1 Y ALU 2 X ADD, out in1 SUB, Y Data 3 F AND, 4 in2 OR 5 R0-R15 Control 6
16.12 Other Registers • Some bookkeeping information is needed to make the processor operate correctly • Example: Program Counter (PC) – Recall that the processor must fetch instructions from memory before decoding and executing them – PC register holds the address of the next instruction to fetch Processor Memory PC Addr 0 op. 1 ALU 2 ADD, out in1 SUB, Data 3 AND, 4 in2 OR 5 R0-R15 Control 6
16.13 Fetching an Instruction • To fetch an instruction – PC contains the address of the instruction – The value in the PC is placed on the address bus and the memory is told to read – The PC is incremented, and the process is repeated for the next instruction Processor Memory PC = Addr = 0 0 PC Addr 0 inst. 1 op. 1 inst. 2 ALU Data = inst.1 machine code 2 inst. 3 ADD, out in1 SUB, Data 3 inst. 4 AND, 4 inst. 5 in2 OR Control = Read … R0-R15 Control FF
16.14 Fetching an Instruction • To fetch an instruction – PC contains the address of the instruction – The value in the PC is placed on the address bus and the memory is told to read – The PC is incremented, and the process is repeated for the next instruction Processor Memory PC = Addr = 1 1 PC Addr 0 inst. 1 op. 1 inst. 2 ALU Data = inst.2 machine code 2 inst. 3 ADD, out in1 SUB, Data 3 inst. 4 AND, 4 inst. 5 in2 OR Control = Read … R0-R15 Control FF
16.15 Control Circuitry • Control circuitry is used to decode the instruction and then generate the necessary signals to complete its execution • Controls the ALU • Selects registers to be used as source and destination locations (using muxes) Processor Memory 0 PC Addr Control 0 inst. 1 op. 1 inst. 2 ALU 2 inst. 3 ADD, out in1 SUB, Data 3 inst. 4 AND, 4 inst. 5 in2 OR … R0-R15 Control FF
16.16 Control Circuitry • Assume 0x0201 is machine code for an ADD instruction of R2 = R0 + R1 • Control Logic will… Opcode Dst. Reg. Src1 Reg. Src2 Reg. – select the registers (R0 and R1) (4-bits) (4-bits) (4-bits) (4-bits) – tell the ALU to add – select the destination register (R2) Processor Memory 0 0 PC Addr Control 0 0201 ADD 1 inst. 2 0201 2 inst. 3 out ALU in1 Data 3 inst. 4 ADD 4 inst. 5 in2 … R0-R15 Control FF
16.17 INSTRUCTION SET OVERVIEW
16.18 Instruction Set Overview • The instruction set defines the software interface to the processor and memory system • Most processors define their own unique instruction set unless they are trying to be compatible with some other vendor – Which means code compiled for one processor will not run on another • Instruction set is the vocabulary the HW processor can understand and the SW is composed with – Usually the compiler is the one that translates the high level software into the 1s and 0s (aka machine code) that control the processor
16.19 Components of the Instruction Set • Instruction sets specify… – Maximum bit widths for data and addresses • 8-, 16-, 32- or 64-bit – Which instructions are implemented • ADD, NEGate, SUB, MUL – How many registers the processor provides to instructions • Usually 16 to 64 – How each instruction is converted to binary (aka "machine code")
16.20 Instruction Set Architecture (ISA) • 2 instruction set approaches – CISC = Complex instruction set computer • Large, rich set of instructions (vocabulary) • Useful when programmers actually wrote assembly code • More work per instruction, slower clock cycle – RISC = Reduced instruction set computer • Small, basic, but sufficient instruction set (vocabulary) • With maturation of compilers programming at assembly level is more rare • Less work per instruction, faster clock cycle • Usually a simple and small set of instructions with regular format facilitates building faster processors
16.21 Kinds of Instructions • Most assembly/machine instructions fall into one of three categories • Arithmetic/Logic – Example: ADD r1, r2, r3 // r1 = r2 + r3 • Data Transfer (to and from memory) – Example: LOAD r1, addr // set register 1 to the value in mem. at addr • Control – Example: JUMP addr // Go to instruction in mem. at addr • Notice that each instruction has predefined interpretation of the operands – LOAD r1, addr // interprets 1 st operand as a register number and 2 nd as an address – The interpretation of the meaning of the operand is part of the instruction set and known as "addressing modes"
16.22 Operands ADD r1, r2, r3 • Addressing modes refers to how an Opcode Reg. # Reg. # Reg. # instruction specifies where the Proc. Mem. operands are Registers • Can be in a LOAD r5, 0x1ac8 – register , Opcode Reg. # Address – memory location , or a Proc. Mem. – constant that is part of the instruction itself ( aka. immediate value ) Registers • Most RISC processors: All data operands for arithmetic instructions ADD r5, r3, immediate Opcode Reg. Reg. must be in a register Immediate # # – This allows the hardware to be simpler Proc. Mem. and faster Registers
16.23 DESIGN OF A SIMPLE INSTRUCTIONS SET AND PROCESSOR
Recommend
More recommend