4 Logic Instructions Arguments 2 1 3 Results Registers - - PowerPoint PPT Presentation

4
SMART_READER_LITE
LIVE PREVIEW

4 Logic Instructions Arguments 2 1 3 Results Registers - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

10/1/15 1

A ¡tiny ¡ISA ¡and ¡data ¡path

ALU

Registers Memory

Instruction ¡ Fetch and ¡ Decode

1 2 3

4

Computer

Instruction ¡Set ¡Architecture ¡(HW/SW ¡Interface)

memory

Instruction Logic Registers

processor

Encoded Instructions Data Instructions

  • Names
  • Encodings
  • Effects
  • Arguments
  • Results

Local ¡storage

  • Names
  • Sizes
  • How ¡many

Large ¡storage

  • Addresses, ¡Locations

A ¡tiny ¡ISA ¡and ¡data ¡path

  • Word ¡size ¡= ¡16 ¡bits, ¡data ¡ bus ¡= ¡16 ¡bits.
  • Register ¡size ¡= ¡16 ¡bits.
  • ALU ¡and ¡memory ¡handle ¡16-­‑bit ¡values.
  • Memory ¡is ¡byte-­‑addressable.
  • 16 ¡registers: ¡R0 ¡-­‑ R15
  • R0 ¡always ¡holds ¡hardcoded ¡0
  • R1 ¡always ¡holds ¡hardcoded ¡1
  • R2 ¡– R15: ¡general ¡purpose
  • Instructions ¡are ¡1 ¡word ¡in ¡size.
  • Separate ¡ instruction ¡memory.
  • Each ¡instruction ¡executes ¡ in

a ¡single ¡clock ¡cycle.

  • Special ¡ Program ¡ Counter ¡(PC) ¡register
  • holds ¡address ¡of ¡next ¡instruction ¡to ¡execute.

3

Address Contents First ¡instruction, ¡ low-­‑order byte 1 First ¡instruction, ¡ high-­‑order ¡byte 2 Second instruction, ¡ low-­‑order ¡byte ... ... 255 256th instruction, ¡ high-­‑order ¡byte

Instruction ¡ Fetch

Fetch instruction ¡from ¡memory. Increment program ¡ counter ¡(PC) to ¡ point ¡to ¡the ¡next ¡instruction. Read Address Instruction Instruction Memory Add PC 2

4

slide-2
SLIDE 2

10/1/15 2

Arithmetic ¡Instructions ¡and ¡Encodings

5

Instruction Meaning Opcode Rs Rt Rd ADD ¡Rs, Rt, ¡Rd Rd ¡:= ¡Rs + ¡Rt 0010 0-­‑15 0-­‑15 0-­‑15 SUB ¡Rs, Rt, ¡Rd Rd ¡:= ¡Rs -­‑ Rt 0011 0-­‑15 0-­‑15 0-­‑15 AND ¡Rs, Rt, ¡Rd Rd ¡:= ¡Rs & ¡Rt 0100 0-­‑15 0-­‑15 0-­‑15 OR ¡Rs, Rt, ¡Rd Rd ¡:= ¡Rs | ¡Rt 0101 0-­‑15 0-­‑15 0-­‑15 ...

16-­‑bit ¡Encoding

Op Rs Rt Rd 0010 0011 0110 1000

ADD ¡R3, ¡R6, ¡R8

Instruction ¡ Decode, ¡ Register ¡Access, ¡ALU

6

Instruction

Write ¡Data Read ¡Addr 1 Read ¡Addr 2 Write ¡Addr Read Data ¡1 Read Data ¡2

ALU

  • verflow

ALU ¡control Write ¡Enable

zero

Control Unit

ALU ¡result

16 16 16

Register ¡File

16 4 4 4 4

Memory ¡Instructions ¡and ¡Encodings

7

Instruction Meaning Opcode Rs Rt Rd LW ¡Rt, ¡offset(Rs) Rt := ¡Memory[Rs + ¡offset] 0000 0-­‑15 0-­‑15

  • ffset

SW ¡Rt, ¡offset(Rs) Memory[Rs + ¡offset] ¡:= ¡Rt 0001 0-­‑15 0-­‑15

  • ffset

...

16-­‑bit ¡Encoding

Op Rs Rt Rd 0001 0011 0110 1000

SW ¡R6, ¡8(R3)

Memory ¡ access

8

Data ¡Memory

Address Write Data Read Data MemWrite 32 16

Inst

Write ¡Data Read ¡Addr 1 Read ¡Addr 2 Write ¡Addr Read Data ¡1 Read Data ¡2

ALU

ALU ¡control Write ¡Enable Control Unit

16 16 16

Register ¡File

16 4 4 4 4 Sign ¡ extend 16 4

How ¡can ¡we ¡support ¡arithmetic and memory ¡instructions? What's shared?

8 8

slide-3
SLIDE 3

10/1/15 3

MUXes to ¡the ¡rescue!

9

Data ¡Memory

Address Write Data Read Data MemWrite 32 16

Inst

Write ¡Data Read ¡Addr 1 Read ¡Addr 2 Write ¡Addr Read Data ¡1 Read Data ¡2

ALU

ALU ¡control Write ¡Enable Control Unit

16 16 16

Register ¡File

16 4 4 4 4 MUX

MUX MUX

Sign ¡ extend 16 4

Mem ¡Op

16 8

More ¡questions:

Next ¡time: What's ¡inside ¡the ¡Control ¡Unit? How ¡do ¡we ¡support ¡programs ¡ with ¡conditionals and ¡loops? Next ¡few ¡weeks: How ¡do ¡these ¡instructions ¡relate ¡to ¡the ¡programs ¡ I ¡write?

10

Control ¡Instructions ¡and ¡Encodings

11

Instruction Meaning Opcode Rs Rt Rd BEQ ¡Rs, ¡Rt, ¡offset If ¡Rs == ¡Rt then PC ¡:= ¡PC ¡+ ¡2 ¡+ ¡offset*2 Else PC ¡:= ¡PC ¡+ ¡2 ¡(normal) 0111 0-­‑15 0-­‑15

  • ffset

JMP ¡offset PC ¡:= ¡offset*2 1000 O ¡ ¡ ¡ ¡f f ¡ ¡ ¡ ¡ ¡s e ¡ ¡ ¡ ¡ ¡t ...

16-­‑bit ¡Encoding

Op Rs Rt Rd 0111 0001 0010 1110

BEQ ¡R1, ¡R2, ¡28

Use ¡these ¡ to ¡implement: ¡if-­‑else, ¡loops, ¡etc.

Compute ¡ branch ¡ target

12

Inst

32 16 Write ¡ Data Read ¡Addr 1 Read ¡Addr 2 Write ¡ Addr Read Data ¡1 Read Data ¡2

ALU

ALU ¡control

Write ¡ Enable

Control Unit

16

16

Register ¡File

16 4 4 4 4

MUX MUX

Sign ¡ extend 16 4

Read Address Instruction Memory

+

PC

2 Shift ¡left ¡ by ¡1

+

slide-4
SLIDE 4

10/1/15 4

Make ¡branch ¡ decision

13

Inst

32 16 Write ¡ Data Read ¡Addr 1 Read ¡Addr 2 Write ¡ Addr Read Data ¡1 Read Data ¡2

ALU

ALU ¡control

Write ¡ Enable

Control Unit

16

16

Register ¡File

16 4 4 4 4

MUX MUX

Sign ¡ extend 16 4

Read Address Instruction Memory

+

PC

2 Shift ¡left ¡ by ¡1

+

MUX

Branch?

All ¡together ¡ now...

14

Inst

Data ¡ Memory

Address Write Data Read Data MemWrite 32 16 Write ¡ Data Read ¡Addr 1 Read ¡Addr 2 Write ¡ Addr Read Data ¡1 Read Data ¡2

ALU

ALU ¡control

Write ¡ Enable

Control Unit

16 16

16

Register ¡File

16 4 4 4 4 MUX

MUX MUX

Sign ¡ extend 16 4 16 8

Read Address Instruction Memory

+

PC

2 Shift ¡left ¡ by ¡1

+

MUX

Branch?