Presentation is loading. Please wait.

Presentation is loading. Please wait.

Processor Design Computer Architecture CS 215 Updated 10/21/14.

Similar presentations


Presentation on theme: "Processor Design Computer Architecture CS 215 Updated 10/21/14."— Presentation transcript:

1 Processor Design Computer Architecture CS 215 Updated 10/21/14

2 Registers  Special purpose registers  Accumulators (arithmetic registers)  Status register

3 Machine Types  Accumulator machines Limited number of data accumulators 1-address machines  Stack machines No register names Registers organized as a stack 0-address machine  General register machines Most often used today Registers used for almost any purpose

4 Instruction Sets  Each family of CPUs has its own instruction set  Instruction codes are mapped to instructions Data movement Arithmetic Logic Control

5 Instructions  Must contain … Which operation to perform Where to find the operand(s), if any Where to put the result, if any Where to find the next instruction

6 Memory Access  Each register has a unique address  Two operations Read Write

7 Memory Access: Read  CPU places an address on the address bus, and a read request on the control bus  Memory unit receives request, decodes address, and locate data at address  Memory unit places data on data bus  Memory unit places a complete message on control bus

8 Memory Access: Write  CPU places an address on the address bus, value to be written on data bus, and a write request on the control bus  Memory unit receives request, decodes address  Memory unit stores data at address  Memory unit places a complete message on control bus

9 Addressing Modes  Immediate i  Direct M[i]  Indirect M[M[i]]  Register direct R[i]  Register indirect M[R[i]]  Displacement M[R[i]+c]]  Relative M[PC+c]

10 SRC Instructions  Load instructions ld, ldr, la, lar  Store instructions st, str  Arithmetic add, addi, sub, neg  Logic and, andi, or, ori, not shr, sha, shl, shc  Branching br, brl  Miscellaneous nop, stop

11 Instruction Formats 312726222117161211420 Oprarbc2 ld, st, la, addi, andi, ori 312726222117161211420 Oprac1 ldr, str, lar

12 Instruction Formats 312726222117161211420 Opraunused neg, not 312726222117161211420 Opunused(c3) unused br rc rbrcCond

13 Instruction Formats 312726222117161211420 Opraunused add, sub, and, or rbrc 312726222117161211420 Opra(c3) unused brl rbrcCond

14 Instruction Formats 312726222117161211420 Opunused nop, stop 312726222117161211420 Opra(c2) unused shr, shra, shl, shc rbCount 312726222117161211420 Opra(c3) unusedrbrc00000

15 Example: cnt:.equ 8.org0 seq:.dc1 next:.dc1 ans:.dwcnt.org0x1000 larr31,loop lar0,cnt lar1,seq loop:ldr2,seq(r1) ldr3,next(r1) addr2,r2,r3 str2,ans(r1) addir1,r1,4 addir0,r0-1 brnzr31,r0 stop

16 Try this!  Develop instruction formats for a 16-bit CPU, which has 16, 16-bit general purpose registers.

17 CPU Design  Control Unit Generates the control signals in the correct order to effect the correct data path activity  Data Path Set of interconnections and auxiliary registers Needed to accomplish overall changes an instruction makes CPU Control Unit Data Path Control signals out Control unit inputs

18 Register Transfer Notation  Provides a formal means of describing machine structure and function  Is at the “just right” level for machine descriptions  Does not replace hardware description languages.  Can be used to describe what a machine does (an Abstract RTN) without describing how the machine does it.  Can also be used to describe a particular hardware implementation (A Concrete RTN)

19 RTN (Cont’d.)  At first you may find this “meta description” confusing, because it is a language that is used to describe a language.  You will find that developing a familiarity with RTN will aid greatly in your understanding of new machine design concepts.  We will describe RTN by using it to describe SRC.

20 Static Properties  Specifying registers IR  31..0  specifies a register named “IR” having 32 bits numbered 31 to 0  “Naming” using the := naming operator: op  4..0  := IR  31..27  specifies that the 5 msbs of IR be called op, with bits 4..0. Notice that this does not create a new register, it just generates another name, or “alias” for an already existing register or part of a register.

21 Dynamic Properties Conditional expressions: (op=12)  R[ra]  R[rb] + R[rc]: ; defines the add instruction “if” condition “then” RTN Assignment Operator This fragment of RTN describes the SRC add instruction. It says, “when the op field of IR = 12, then store in the register specified by the ra field, the result of adding the register specified by the rb field to the register specified by the rc field.”

22 Register Declarations  General register specifications shows some features of the notation  Describes a set of 32 32-bit registers with names R[0] to R[31] R[0..31]  31..0  : Name of registers Register # in square brackets.. specifies a range of indices msb # lsb# Bit # in angle brackets Colon separates statements with no ordering

23 Naming Operator  Defining names with formal parameters is a powerful formatting tool  Used here to define word memory (big endian) M[x]  31..0  := Mem[x]#Mem[x+1]#Mem[x+2]#Mem[x+3]: Dummy parameter Naming operator Concatenation operator All bits in register if no bit index given

24 Memory  Processor State PC :  32-bit register Program Counter IR :  32-bit register Instruction Register Run:  1-bit run/halt indicator Strt:  Start signal R[0..31] :  32, 32-bit general purpose registers

25 Main Memory Mem[0..2 32 -1] : 2 32 addressable bytes of memory M[x] : = Mem[x]#Mem[x+1]#Mem[x+2]#Mem[x+3]:

26 Instruction Formats op : = IR Operation code field ra : = IR Target register field rb : = IR Operand, address index, or branch target register rc : = IR Second operand, conditional test, or shift count register

27 Instruction Formats c1 : = IR Long displacement field c2 : = IR Short displacement or immediate field c3 : = IR Count or modifier field

28 Effective Address Calculations  Displacement disp :=((rb=0)  c2 {sign extend}: (rb  0)  R[rb]+c2 {sign extend, 2’s compliment}):  Relative rel :=PC +c1 {sign extend, 2’s comp}:

29 Instruction Interpretation & Execution instruction_interpretation:=(  Run  Strt  (Run  1: instruction_intepretation): Run  (IR  M[PC]:PC  PC+4: instruction_execution): ):

30 Load & Store Instructions instruction_execution:=( ld(:=op=1)  R[ra]  M[disp]: load register ldr(:=op=2)  R[ra]  M[rel]: load register relative st(:=op=3)  M[disp]  R[ra]: store register str(:=op=4)  M[rel]  R[ra]: store register relative la(:=op=5)  R[ra]  disp: load displacement address lar(:=op=6)  R[ra]  rel: load relative address

31 Branch Instruction cond:=(c3 =0  0:Never c3 =1  1:Always c3 =2  R[rc]=0:Register=0 c3 =3  R[rc]  0 :Register  0 c3 =4  R[rc] =0:>= 0 c3 =5  R[rc] =1):< 0 br(:=op=8)  (cond  PC  R[rb]):Cond branch brl(:=op=9)  (R[ra]  PC:Branch & link cond  (PC  R[rb])):

32 ALU Instructions  Arithmetic Instructions add(:=op=12)  R[ra]  R[rb]+R[rc]: addi(:=op=13)  R[ra]  R[rb]+c2 : sub(:=op=14)  R[ra]  R[rb]-R[rc]: neg(:=op=15)  R[ra]  -R[rc]:

33 ALU Instructions  Logical Operations and(:=op=20)  R[ra]  R[rb]  R[rc]: andi(:=op=21)  R[ra]  R[rb]  c2 : or(:=op=22)  R[ra]  R[rb]  R[rc]: ori(:=op=23)  R[ra]  R[rb]  c2 : not(:=op=24)  R[ra]  R[rc]:

34 ALU Instructions  Shift Operations n:=((c3 =0)  R[rc] : (c3  0)  c3 ): shr(:=op=26)  R[ra]  (n@0)#R[rb] : shra(:=op=27)  R[ra]  (n@R[rb] )#R[rb] : shl(:=op=28)  R[ra]  R[rb] #(n@0): shc(:=op=29)  R[ra]  R[rb] #R[rb]

35 Miscellaneous Instructions nop(:=op=0)  :No operation stop(:=op=31)  run  0):Stop instruction instruction_interpretation:End of instr_execution; invoke instr_interpretation

36 Abstract vs. Concrete RTN  Abstract: What occurs R[3]  R[1] + R[2];  Concrete: How it occurs Y  R[2]; Z  R[1] + Y; R[3]  Z;  Control Sequence R[2] out, Y in ; R[1] out, Z in ; Z out, R[3] in ;

37 Bus Transfers The Rules of Buses 1. Only one item can be on the bus during a given clock cycle. 2. The contents of the bus disappear at the end of the clock cycle. No information is “stored” on the bus from cycle to cycle; any value to be saved must be stored into a register at the end of the clock cycle.

38 Clock Cycle

39 1-Bus Microarchitecture  Only one value can be placed on the bus at any time

40 Abstract Vs. Concrete RTN  How would you accomplish the following instruction using this architecture? add(:=op=12)  R[ra]  R[rb]+R[rc]:

41 Abstract Vs. Concrete RTN add(:=op=12)  R[ra]  R[rb]+ R[rc]: StepRTN

42 Abstract Vs. Concrete RTN: addi StepRTN T0.MA  PC: C  PC + 4; T1.MD  M[MA]; PC  C; T2.IR  MD; T3.A  R[rb]; T4.C  A + c2 {sign ext.}; T5.R[ra]  C;

43 Abstract Vs. Concrete RTN: ld StepRTN T0-T2 Instruction fetch T3.A  (rb=0  0: rb  0  R[rb]); T4.C  A + (16@IR #IR ); T5.MA  C; T6.MD  M[MA]; T7.R[ra]  MD;

44 Abstract Vs. Concrete RTN: st StepRTN T0-T2 Instruction fetch T3.A  (rb=0  0: rb  0  R[rb]); T4.C  A + (16@IR #IR ); T5.MA  C; T6.MD  R[ra]; T7.M[MA]  MD;

45 Abstract Vs. Concrete RTN: br StepRTN T0-T2 Instruction fetch T3.CON  cond(R[rc]); T4.CON  PC  R[rb];

46 Abstract Vs. Concrete RTN: shr StepConcrete RTN T0-T2 Instruction fetch T3.n  IR ; T4.(n=0)  (n  R[rc] ; T5.C  R[rb]; T6.Shr (:= (n≠0)  (C  0#C : n  n-1; Shr) ); T7.R[ra]  C;

47 More Detail …

48 ra, rb, rc fields General purpose registers Control signals 5x32 decoder

49 Try this!  Problem Extend the SRC instruction set by adding the XOR command (op=19), similar to the AND command Note: The ALU cannot be altered by adding XOR Develop both an abstract and concrete RTN for the instruction

50 Try this!

51 Instruction Register Sign extension

52 Memory Interface From bus From memory To memory To bus

53 ALU

54

55 Control sequences: Instruction Fetch StepConcrete RTNControl Sequence T0.MA  PC: C  PC+4;PC out, MA in, Inc4, C in T1.MD  M[MA]: PC  C;Read, C out, PC in, Wait T2.IR  MD;MD out, IR in T3.Instruction_execution

56 Control sequences: add StepConcrete RTNControl Sequence T0.MA  PC: C  PC+4;PC out, MA in, Inc4, C in, Read T1.MD  M[MA]: PC  C;C out, PC in, Wait T2.IR  MD;MD out, IR in T3.A  R[rb];Grb, R out, A in T4.C  A + R[rc];Grc, R out, ADD, C in T5.R[ra]  C;C out, Gra, R in, End

57 Control sequences: addi StepConcrete RTNControl Sequence T0.MA  PC: C  PC + 4; PC out, MA in, Inc4, C in T1.MD  M[MA]; PC  C;C out, PC in, Wait, Read T2.IR  MD;MD out, IR in T3.A  R[rb];Grb, R out, A in T4.C  A + c2  16..0  {sign ext.};c2 out, ADD, C in T5.R[ra]  C;C out, Gra, R in, End

58 Control sequences: st StepConcrete RTNControl Sequence T0-T2Instruction fetch Instruction fetch T3.A  (rb=0)  0: rb  0  R[rb];Grb, BA out, A in T4.C  A + c2  16..0  {sign ext.};c2 out, ADD, C in T5.MA  C;C out, MA in T6.MD  R[ra];Gra, R out, MD in, Write T7.M[MA]  MD;Wait, End } address arithmetic

59 Control sequences: shr StepConcrete RTNControl Sequence T0-T2Instruction fetchInstruction fetch T3.n  IR  4..0  ;c1 out, Ld T4.(n=0)  (n  R[rc]  4..0  );n=0  (Grc, R out, Ld) T5.C  R[rb];Grb, R out, C=B, C in T6.Shr (:=(n≠0)  n  0  (C out, SHR, C in, (C  31..0   0#C  31..1  :Decr, Goto6) n  n-1; Shr) ); T7.R[ra]  C;C out, Gra, R in, End

60 Control sequences: br StepConcrete RTNControl Sequence T0-T2Instruction fetchInstruction fetch T3.CON  cond(R[rc]);Grc, R out, CON in T4.CON  PC  R[rb];Grb, R out, CON  PC in, End

61 Clocking & Timing

62 Control Unit

63 2-Bus SRC

64 3-Bus SRC

65 Machine Reset  From a need to initialize processor to a known, defined state Control Step Counter  0 PC  Known Value  RTN instruction_interpretation := (  Run  Strt  (Run  1: PC, R[0..31]  0); Run  Rst (IR  M[PC]: PC  PC + 4; instruction_execution): Run  Rst  ( Rst  0: PC  0); instruction_interpretation):

66 Exceptions  Different from branches and jumps  Resolved in the writeback stage

67 Exceptions  When detected … Following instructions (earlier in the pipeline) are marked as invalid As they flow to the end of the pipe their results are discarded Program counter is set to the address of a special exception handler Special registers are written with the exception location and cause

68 Exceptions  Types: System Reset Machine Check Exceptions  Memory error checking Data Access Exceptions Instruction Access Exceptions Alignment Exceptions

69 Program Exceptions  Illegal instruction  Unimplemented instruction  Privileged instruction  Arithmetic errors (sometimes)

70 Other Exceptions  Miscellaneous Hardware Exceptions Countdown to zero  Trace & Debugging Exceptions  Nonmaskable Exceptions Cannot be ignored Power outage  Interrupts (External)

71 Exception Process  Interrupt signal asserted  Determine if interrupt should be serviced; Finish current instruction, if possible

72 Exception Process instruction_interpretation := (  Run  Strt  Run  1: Run  (ireq  IE)  (IR  M[PC]: PC  PC + 4; instruction_execution): Run  (ireq  IE)  (IPC  PC  31..0  : II  15..0   Isrc_info  15..0  : iack  1: IE  0: PC  Ivect  31..0  ; iack  0); instruction_interpretation);


Download ppt "Processor Design Computer Architecture CS 215 Updated 10/21/14."

Similar presentations


Ads by Google