10/1/15 A ¡tiny ¡ISA ¡and ¡data ¡path Instruction ¡Set ¡Architecture ¡(HW/SW ¡ Interface ) Instructions processor memory Names • Encodings • Instruction Encoded Effects 4 • Logic Instructions Arguments • 2 1 3 Results • Registers Data Local ¡storage Instruction ¡ • Names Large ¡storage ALU Registers Fetch and ¡ Memory • Sizes Addresses, ¡Locations • Decode • How ¡many Computer A ¡tiny ¡ISA ¡and ¡data ¡path Instruction ¡ Fetch • Word ¡size ¡= ¡16 ¡bits, ¡data ¡ bus ¡= ¡16 ¡bits. Fetch instruction ¡from ¡memory. • Register ¡size ¡= ¡16 ¡bits. • ALU ¡and ¡memory ¡handle ¡16-‑bit ¡values. Increment program ¡ counter ¡(PC) to ¡ point ¡to ¡the ¡next ¡instruction. • Memory ¡is ¡byte-‑addressable. Add • 16 ¡registers: ¡R0 ¡-‑ R15 2 • R0 ¡always ¡holds ¡hardcoded ¡0 Address Contents • R1 ¡always ¡holds ¡hardcoded ¡1 0 First ¡instruction, ¡ Instruction • R2 ¡– R15: ¡general ¡purpose low-‑order byte Memory • Instructions ¡are ¡1 ¡word ¡in ¡size. 1 First ¡instruction, ¡ high-‑order ¡byte Read • Separate ¡ instruction ¡memory . PC Address 2 Second instruction, ¡ Instruction • Each ¡instruction ¡executes ¡ in low-‑order ¡byte a ¡single ¡clock ¡cycle. ... ... • Special ¡ Program ¡ Counter ¡(PC) ¡register 256 th instruction, ¡ 255 high-‑order ¡byte • holds ¡address ¡of ¡next ¡instruction ¡to ¡execute. 3 4 1
10/1/15 Arithmetic ¡Instructions ¡and ¡Encodings Instruction ¡ Decode, ¡ Register ¡Access, ¡ALU Op Rs Rt Rd ADD ¡R3, ¡R6, ¡R8 0010 0011 0110 1000 16-‑bit ¡Encoding Control 4 Unit Instruction Meaning Opcode Rs Rt Rd Write ¡Enable ADD ¡ Rs, Rt, ¡Rd Rd ¡:= ¡Rs + ¡Rt 0010 0-‑15 0-‑15 0-‑15 ALU ¡control SUB ¡ Rs, Rt, ¡Rd Rd ¡:= ¡Rs -‑ Rt 0011 0-‑15 0-‑15 0-‑15 4 Read ¡Addr 1 16 Read AND ¡ Rs, Rt, ¡Rd Rd ¡:= ¡Rs & ¡Rt 0100 0-‑15 0-‑15 0-‑15 16 4 Data ¡1 Read ¡Addr 2 overflow Instruction Register ¡File OR ¡ Rs, Rt, ¡Rd Rd ¡:= ¡Rs | ¡Rt 0101 0-‑15 0-‑15 0-‑15 ALU zero 4 Write ¡Addr Read 16 ALU ¡result ... 16 Data ¡2 Write ¡Data 5 6 How ¡can ¡we ¡support ¡arithmetic Memory ¡Instructions ¡and ¡Encodings and memory ¡instructions? What's shared? Memory ¡ access Op Rs Rt Rd SW ¡R6, ¡8(R3) 0001 0011 0110 1000 16-‑bit ¡Encoding Control 4 Unit Instruction Meaning Opcode Rs Rt Rd Write ¡Enable ALU ¡control LW ¡ Rt, ¡offset(Rs) Rt := ¡Memory[Rs + ¡offset] 0000 0-‑15 0-‑15 offset SW ¡ Rt, ¡offset(Rs) Memory[Rs + ¡offset] ¡:= ¡Rt 0001 0-‑15 0-‑15 offset 4 MemWrite Read ¡Addr 1 16 Read ... 8 16 4 Data ¡1 Address Read ¡Addr 2 16 ALU Register ¡File Inst 32 Data ¡Memory 8 Write ¡Addr 16 Read Data ¡2 Read Write 16 Data Write ¡Data Data 4 4 16 Sign ¡ extend 7 8 2
10/1/15 More ¡questions: MUXes to ¡the ¡rescue! Next ¡time: Mem ¡Op What's ¡inside ¡the ¡Control ¡Unit? How ¡do ¡we ¡support ¡programs ¡ with ¡ conditionals and ¡ loops ? Control 4 Unit Next ¡few ¡weeks: Write ¡Enable ALU ¡control How ¡do ¡these ¡instructions ¡relate ¡to ¡the ¡programs ¡ I ¡write? 4 MemWrite Read ¡Addr 1 16 Read 8 16 4 Data ¡1 Address Read ¡Addr 2 16 ALU Register ¡File Inst 32 Data ¡Memory 16 MUX 4 Write ¡Addr 16 Read MUX Data ¡2 Read Write 16 Data Write ¡Data Data 4 16 Sign ¡ extend MUX 9 10 Control ¡Instructions ¡and ¡Encodings Compute ¡ branch ¡ target Op Rs Rt Rd BEQ ¡R1, ¡R2, ¡28 + 0111 0001 0010 1110 Shift ¡left ¡ by ¡1 16-‑bit ¡Encoding Instruction Meaning Opcode Rs Rt Rd If ¡Rs == ¡Rt then Control 4 ALU ¡control PC ¡:= ¡PC ¡+ ¡2 ¡+ ¡offset*2 Unit BEQ ¡ Rs, ¡Rt, ¡offset 0111 0-‑15 0-‑15 offset Else Write ¡ Enable + PC ¡:= ¡PC ¡+ ¡2 ¡(normal) 2 JMP ¡ offset PC ¡:= ¡offset*2 1000 O ¡ ¡ ¡ ¡f f ¡ ¡ ¡ ¡ ¡s e ¡ ¡ ¡ ¡ ¡t 4 Read ¡Addr 1 Instruction Read 16 Memory 16 4 Data ¡1 Read ¡Addr 2 ... 16 Read PC Register ¡File ALU Address Inst 32 4 MUX Write ¡ Addr 16 Read Data ¡2 MUX Write ¡ Data 4 Sign ¡ 16 Use ¡these ¡ to ¡implement: ¡if-‑else, ¡loops, ¡etc. extend 11 12 3
10/1/15 Make ¡branch ¡ decision All ¡together ¡ now... MUX MUX + + Shift ¡left ¡ Shift ¡left ¡ by ¡1 by ¡1 Branch? Branch? Control Control 4 4 ALU ¡control ALU ¡control Unit Unit Write ¡ Enable Write ¡ Enable + + 2 2 4 4 MemWrite Read ¡Addr 1 Read ¡Addr 1 Instruction Read 16 Instruction Read 16 Memory Memory 8 16 4 Data ¡1 16 4 Data ¡1 Read ¡Addr 2 Read ¡Addr 2 Address 16 16 Read Read PC PC Register ¡File ALU Register ¡File ALU Address Inst Address Inst 32 32 Data ¡ Memory 16 4 MUX 4 MUX Write ¡ Addr 16 Write ¡ Addr 16 Read Read Read Data ¡2 MUX Data ¡2 MUX Write 16 Write ¡ Data Write ¡ Data Data Data 4 4 Sign ¡ 16 Sign ¡ 16 extend extend MUX 13 14 4
Recommend
More recommend