SCRAM Instructions Philipp Koehn 16 September 2019 Philipp Koehn - - PowerPoint PPT Presentation

scram instructions
SMART_READER_LITE
LIVE PREVIEW

SCRAM Instructions Philipp Koehn 16 September 2019 Philipp Koehn - - PowerPoint PPT Presentation

SCRAM Instructions Philipp Koehn 16 September 2019 Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019 Reminder 1 Fully work through a computer circuit assembly code Simple but Complete Random


slide-1
SLIDE 1

SCRAM Instructions

Philipp Koehn 16 September 2019

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-2
SLIDE 2

1

Reminder

  • Fully work through a computer

– circuit – assembly code

  • Simple but Complete Random Access Machine (SCRAM)

– every instruction is 8 bit – 4 bit for op-code: 9 different operations (of 16 possible) – 4 bit for address: 16 bytes of memory

  • Background reading on web page

– The Random Access Machine – The SCRAM

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-3
SLIDE 3

2

Circuit (At This Point)

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-4
SLIDE 4

3

Instruction Fetch

  • Retrieve instruction from memory
  • Increase program counter

Time Command t0 MAR ← PC t1 MBR ← M, PC ← PC + 1 t2 IR ← MBR

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-5
SLIDE 5

4

lda

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-6
SLIDE 6

5

Micro Program

  • Load into accumulator

Op Code Time Command q1 t3 MAR ← IR(D) q1 t4 MBR ← M q1 t5 AC ← MBR

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-7
SLIDE 7

6

Accumulator

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-8
SLIDE 8

7

AC ← MBR

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Accumulator receives value from memory buffer (MBR)

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-9
SLIDE 9

8

MAR ← IR(D)

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Memory address comes from data field of instruction

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-10
SLIDE 10

9

MAR ← IR(D)

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Selector

S

Selector picks between inputs

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-11
SLIDE 11

10

let’s do this again but focus on flags

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-12
SLIDE 12

11

Micro Program

  • Load into accumulator

Op Code Time Command q1 t3 MAR ← IR(D) q1 t4 MBR ← M q1 t5 AC ← MBR

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-13
SLIDE 13

12

q1 t3: MAR ← IR(D)

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-14
SLIDE 14

13

q1 t4: MBR ← M

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-15
SLIDE 15

14

q1 t5: AC ← MBR

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-16
SLIDE 16

15

control logic unit

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-17
SLIDE 17

16

Objective

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

  • Given

– Instruction op code Q – Time step in micro program T

  • Output

– signals to register transfer – signals to selectors

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-18
SLIDE 18

17

Example

  • Step in micro program:

q1 t3 MAR ← IR(D)

  • Needs to signal

– MAR write flag set – MAR’s selector to input IR(D)

DI DO W A

16x8 RAM MAR

W

PC

W INC

IR

W C D

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-19
SLIDE 19

18

Add Wires to the Circuit

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Selector

S x1 x2

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-20
SLIDE 20

19

Inside the Control Logic Unit

Decoder Decoder

x1 x2 q1 t5 to selectior to MAR write Micro instruction: q1 AND t5: MAR ← IR(D)

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-21
SLIDE 21

20

Inside the Control Logic Unit

Decoder Decoder

x1 x2 q1 t5

AND

to selectior to MAR write Micro instruction: q1 AND t5: MAR ← IR(D)

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-22
SLIDE 22

21

Inside the Control Logic Unit

Decoder Decoder

x1 x2 q1 t5

AND

to selectior to MAR write

OR

Micro instruction: q1 AND t5: MAR ← IR(D) Set signal to MAR write flag

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-23
SLIDE 23

22

Inside the Control Logic Unit

Decoder Decoder

x1 x2 q1 t5

AND

to selectior to MAR write

OR OR

Micro instruction: q1 AND t5: MAR ← IR(D) Set appropriate value to MAR selector

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-24
SLIDE 24

23

Inside the Control Logic Unit

Decoder Decoder

x1 x2 q1 t5

AND

to selectior to MAR write

OR OR OR

Micro instruction: q1 AND t5: MAR ← IR(D) Increase micro program time step

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-25
SLIDE 25

24

Inside the Control Logic Unit

Control logic is a large matrix t0 t1 t2 t3 t4 t5 t6 t7 t8 q0 * * * * * * * * * q1 * * * * * * * * * q2 * * * * * * * * * q3 * * * * * * * * * q4 * * * * * * * * * q5 * * * * * * * * * q6 * * * * * * * * * q7 * * * * * * * * * q8 * * * * * * * * *

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-26
SLIDE 26

25

Inside the Control Logic Unit

Control logic is a large matrix t0 t1 t2 t3 t4 t5 t6 t7 t8 q0 * * * * * * * * * q1 * * * * * * * * * q2 * * * * * * * * * q3 * * * * * * * * * q4 * * * * * * * * * q5 * * * * * * * * * q6 * * * * * * * * * q7 * * * * * * * * * q8 * * * * * * * * *

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-27
SLIDE 27

26

Inside the Control Logic Unit

Control logic is a large matrix t0 t1 t2 t3 t4 t5 t6 t7 t8 q0 * * * * * * * * * q1 * * * * * x1x2t * * * q2 * * * * * * * * * q3 * * * * * * * * * q4 * * * * * * * * * q5 * * * * * * * * * q6 * * * * * * * * * q7 * * * * * * * * * q8 * * * * * * * * *

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-28
SLIDE 28

27

ldi

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-29
SLIDE 29

28

LDI: Load Indirectly

  • Specified memory address contains address for value
  • Basically a pointer operation
  • Steps

– load value of specified memory address – use that value as a memory address (second lookup) – store value from second lookup into accumulator

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-30
SLIDE 30

29

Micro Program for LDI

  • Load indirectly into accumulator

Op Code Time Command q2 t3 MAR ← IR(D) q2 t4 MBR ← M q2 t5 MAR ← MBR q2 t6 MBR ← M q2 t7 AC ← MBR

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-31
SLIDE 31

30

q2 t3: MAR ← IR(D)

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-32
SLIDE 32

31

q2 t4: MBR ← M

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-33
SLIDE 33

32

q2 t5: MAR ← MBR

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-34
SLIDE 34

33

q2 t6: MBR ← M

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-35
SLIDE 35

34

q2 t7: AC ← MBR

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-36
SLIDE 36

35

sta

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-37
SLIDE 37

36

STA: Store Value from Accumulator

  • We now need to write to memory
  • Address to be written with comes from instruction
  • Value needs to be transferred from accumulator

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-38
SLIDE 38

37

Micro Program for STA

  • Store value from accumulator

Op Code Time Command q3 t3 MAR ← IR(D) q3 t4 M ← AC

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-39
SLIDE 39

38

q3 t3: MAR ← IR(D)

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-40
SLIDE 40

39

q3 t4: M ← AC

D I DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-41
SLIDE 41

40

sti

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-42
SLIDE 42

41

STI: Store Value Indirectly

  • Specified memory address contains address for value
  • Steps

– load value of specified memory address – use that value as a memory address (second lookup) – store value from accumulator to that address

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-43
SLIDE 43

42

Micro Program for STI

  • Store indirectly into accumulator

Op Code Time Command q4 t3 MAR ← IR(D) q4 t4 MBR ← M q4 t3 MAR ← MBR q4 t4 M ← AC

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-44
SLIDE 44

43

q4 t3: MAR ← IR(D)

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-45
SLIDE 45

44

q4 t4: MBR ← M

DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Selector

S DI

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-46
SLIDE 46

45

q4 t5: MAR ← MBR

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-47
SLIDE 47

46

q4 t6: M ← AC

D I DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-48
SLIDE 48

47

arithmetic logic unit

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-49
SLIDE 49

48

Arithmetric Logic Unit

ALU

A B S CO CI Z SUB

  • Adds two numbers:

S=A+B

  • With subtraction flag:

S=A-B

  • Overflow handling with carry in (CI) and carry out (CO)
  • Zero flag:

set if result of operation is 0

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-50
SLIDE 50

49

Accumulator

ALU

A B S CO CI Z SUB

AC

W

  • Store result of ALU operation in accumulator (AC)

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-51
SLIDE 51

50

AC = AC ± B

ALU

A B S CO CI Z SUB

AC

W

  • Accumulator feeds back into ALU
  • Operations are AC = AC + B or AC = AC - B

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-52
SLIDE 52

51

ALU in Circuit

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

Selector

S

ALU

A B S CO CI Z SUB

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-53
SLIDE 53

52

add

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-54
SLIDE 54

53

ADD: Add to Accumulator

  • Add value from memory address to accumulator
  • Steps

– load value of specified memory address – use that value as input to arithmetic logic unit – store output from arithmetic logic unit into accumulator

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-55
SLIDE 55

54

Micro Program for ADD

  • Load indirectly into accumulator

Op Code Time Command q5 t3 MAR ← IR(D) q5 t4 MBR ← M q5 t5 AC ← AC + MBR

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-56
SLIDE 56

55

q5 t3: MAR ← IR(D)

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

Selector

S

ALU

A B S CO CI Z SUB

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-57
SLIDE 57

56

q5 t4: MBR ← M

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

Selector

S

ALU

A B S CO CI Z SUB

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-58
SLIDE 58

57

q5 t5: AC ← AC + MBR

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

Selector

S

ALU

A B S CO CI Z SUB

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-59
SLIDE 59

58

sub

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-60
SLIDE 60

59

SUB: Subtract from Accumulator

  • Subtract from accumulator the value from memory
  • Same as ADD, just set subtraction flag of ALU

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-61
SLIDE 61

60

Micro Program for SUB

  • Load indirectly into accumulator

Op Code Time Command q5 t3 MAR ← IR(D) q5 t4 MBR ← M q5 t5 AC ← AC - MBR

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-62
SLIDE 62

61

q5 t3: MAR ← IR(D)

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

Selector

S

ALU

A B S CO CI Z SUB

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-63
SLIDE 63

62

q5 t4: MBR ← M

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

Selector

S

ALU

A B S CO CI Z SUB

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-64
SLIDE 64

63

q5 t5: AC ← AC + MBR

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

Selector

S

ALU

A B S CO CI Z SUB

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-65
SLIDE 65

64

jmp

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-66
SLIDE 66

65

Program Counter (PC)

  • Position of the next instruction is stored in program counter
  • This gets updated during instruction fetch

Time Command t0 MAR ← PC t1 MBR ← M t2 IR ← MBR ⇒ t3 PC ← PC + 1

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-67
SLIDE 67

66

JMP: Jump

  • Assign value to position of the next instruction
  • Sequencing of micro program

– instruction fetch (includes program counter inc) – command-specific micro instructions

  • No problem that program counter gets modified twice

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-68
SLIDE 68

67

Micro Program for JMP

  • Change program counter to specified address

Op Code Time Command q7 t3 PC ← IR(D)

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-69
SLIDE 69

68

q7 t3: PC ← IR(D)

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

Selector

S

ALU

A B S CO CI Z SUB

AC

W

Selector

S

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-70
SLIDE 70

69

jpz

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-71
SLIDE 71

70

Zero Flag

  • Zero flag

– set when result of a ALU operation is 0 – stored in flag

ALU

A B S CO CI Z SUB

Z

W

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-72
SLIDE 72

71

Z Flag in Circuit

DI DO W A

16x8 RAM MAR MBR

W W

PC

W INC

IR

W

Decoder Control Logic Unit

C D

T

INC

Decoder

CLEAR

NOT

Q T

Selector

S

ALU

A B S CO CI Z SUB

AC

W

Selector

S

Z

W

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019

slide-73
SLIDE 73

72

Micro Program for JPZ

  • Z flag is a condition for executing a micro program

(same as JMP) Zero Op Code Time Command 1 q7 t3 PC ← IR(D)

  • If not set, no micro program is executed

Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions 16 September 2019