420 likes | 476 Views
Chapter 6 CPU Design. 6.1 Specifying a CPU. A CPU performs the following sequences of operations (Figure 6.1) Fetch cycle Decode cycle Execute cycle. Figure 6.1 Generic CPU state diagram. 6.2 Design and Implementation of a very simple CPU. 1 word : 1bytes(8bit data bus)
E N D
6.1 Specifying a CPU • A CPU performs the following sequences of operations (Figure 6.1) • Fetch cycle • Decode cycle • Execute cycle
6.2 Design and Implementation of a very simple CPU • 1 word : 1bytes(8bit data bus) • Address space: 64 bytes(6bit address bus) • Instruction set: 4 (Table 6.1) • Register: Accumulator(8-bit), AR(6-bit), PC(6-bit), IR(2-bit)
6.2 Design and Implementation of a very simple CPU (continued) • Fetch1: AR PC • Fetch2: DR M, PCPC+1 • Fetch3: IR DR[7..6], AR DR[5..0]
Decoding Instructions • Figure 6.3
Executing Instructions • ADD • ADD1: DRM • ADD2: AC AC+DR • AND • AND1: DRM • AND2: AC AC^DR • JUMP • JUMP1: PC DR[5..0] • INC • INC1: AC AC+1
Regrouping the operations by each components • AR: ARPC; ARDR[5..0] PC: PC PC+1; PC DR[5..0] DR: DR M IR: IR DR[7..6] AC: AC AC+DR; AC AC^DR; AC AC+1
Establishing required data paths • Figure 6.5
Reviewing the list of operations • AR only supplies its data to memory • IR does not supply data to any components. • AC does not supply its data to any components • The bus is 8-bits wide, but not all data transfers are not 8 bits • AC must be able to load the sum of AC and DR and the logical AND of AC and DR. The modified version of Figure 6.5 is Figure 6.6
Design of a very simple ALU • Figure 6.7
Designing the control unit using hardwired control • Figure 6.8
Control Signals • PCLOAD = JUMP • PCINC = FETCH2 • DRLOAD = FETCH1 ADD1 AND1 • ACLOAD = ADD2 AND2 • IRLOAD = FETCH3 • MEMBUS = FETCH2 ADD1 AND1 • PCBUS = FETCH1 • READ = FETCH2 ADD1 AND1 • Refer to Figure 6.10
Design verification • Consider the code segment, containing each instruction once 0: ADD 4 1: AND 5 2: INC 3: JUMP 0 4: 27H 5: 39H The execution trace is shown in Table 6.4.
6.3 Design and Implementation of A Relatively Simple CPU • Specifications for a relatively simple CPU • Memory: 64Kbytes • Data width: 8-bit • Registers: AC[7..0], R[7..0], AR[15..0], PC[15..0], DR[7..0],IR[7..0],TR[7..0] • Zero flag • Instruction set: Table 6.5
Fetching and decoding • FETCH1: AR PC • FETCH2: DR M, PC PC +1 • FETCH3: IR DR, AR PC
Executing instructions • NOP • NOP1: (no operation) • LDAC; multiword instruction – opcode::lower-order half of the address:: higher-order half of the address • LDAC1: DR M, PC PC+1, AR AR+1 • LDAC2: TR DR, DR M, PC PC +1 • LDAC3: AR DR,TR • LDAC4: DR M • LDAC5: AC DR
Executing instructions(continued) • STAC; multiword instruction – opcode::lower-order half of the address:: higher-order half of the address • STAC1: DR M, PC PC+1, AR AR+1 • STAC2: TR DR, DR M, PC PC +1 • STAC3: AR DR,TR • STAC4: DR AC • STAC5: M DR • MVAC • MVAC1: R AC • MOVR • MOVR1: AC R
Executing instructions(continued) • JUMP • JUMP1: DR M, AR AR+1 • JUMP2: TR DR, DR M • JUMP3: PC DR,TR • JMPZ • JMPZY1: DR M, AR AR+1 • JMPZY2: TR DR, DR M • JMPZY3: PC DR,TR • JMPZN1: PC PC +1 • JMPZN2: PC PC + 1
Executing instructions(continued) • JPNZ • JPNZY1: DR M, AR AR+1 • JPNZY2: TR DR, DR M • JPNZY3: PC DR,TR • JPNZN1: PC PC +1 • JPNZN2: PC PC + 1
Executing instructions(continued) • OTHERS • ADD1: AC AC+R, IF(AC+R=0)THEN Z1 ELSE Z0 • SUB1: AC AC-R, IF(AC-R=0)THEN Z1 ELSE Z0 • INAC1: AC AC+1,IF(AC+1=0)THEN Z1 ELSE Z0 • CLAC1: AC0, Z1 • AND1: AC AC R, IF(AC R=0)THEN Z1 ELSE Z0 • OR1: AC ACR, IF(AC R=0)THEN Z1 ELSE Z0 • XOR1: AC ACR, IF(AC R=0)THEN Z1 ELSE Z0 • NOT1: AC AC’ IF(AC’=0)THEN Z1 ELSE Z0
Regrouping the data transfers • AR: AR PC; ARAR+1;ARAR,TR • PC: PCPC+1;PCAR,TR • DR: DRM, DRAC • IR: IRDR • R:RAC • TR: TRDR • AC: ACDR; ACR,ACAC+R; ACAC-R; ACAC+1; AC0; ACAC^R; AC ACR; AC ACR; ACAC’ • Z: Z1; Z0
Design of a relatively simple ALU • All transfers that modify the contents of AC LDAC5: ACDR MOVR1: ACR ADD1: ACAC+R SUB1: ACAC-R INAC1: ACAC+1 CLAC1: AC0 AND1:ACAC^R OR1: AC ACR XOR1: AC ACR NOT1: ACAC’
Design of a relatively simple ALU(continued) • Rewriting the arithmetic operations to indicate the source of their operands LDAC5: ACBUS MOVR1: ACBUS ADD1: ACAC+BUS SUB1: ACAC-BUS INAC1: ACAC+1 CLAC1: AC0
Design of a relatively simple ALU(continued) • Rewriting each operation as sum of two values and a carry LDAC5: AC0+BUS+0 MOVR1: AC0+BUS+0 ADD1: ACAC+BUS+0 SUB1: ACAC+BUS’+1 INAC1: ACAC+0+1 CLAC1: AC0+0+0
6.4 Shortcomings of the simple CPUs • More internal registers and cache • Multiple buses within CPU (Figure 6.18) • Pipelined instruction processing (Chapter 11) • Larger instruction sets • Subroutines and interrupts(Chapter 10)