Instructions
Philipp Koehn 11 September 2019
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
Instructions Philipp Koehn 11 September 2019 Philipp Koehn - - PowerPoint PPT Presentation
Instructions Philipp Koehn 11 September 2019 Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019 1 number adder Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019 Design Goal 2 Build a
Philipp Koehn 11 September 2019
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
1
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
2
Loop through memory with ripple counter
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
3
216=65,536 bytes
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
4
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
5
We can enter numbers and inspect with a control panel
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
6
D > CLK Q Q NOT NOT
OUT0 OUT1
D > CLK Q Q
OUT2
D > CLK Q Q
OUT3
OUT0 OUT1 OUT2 OUT3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
7
DI DO W A
64Kx8 RAM
16 8
Control Panel Ripple Counter Oscillator
CLK O
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
8
A B S CO CI
S=A+B
Carry out (CO)
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
9
D Q >CLK
stores value when clock turns to 1
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
10
8 8 8-BIT LATCH
D Q >CLK
8-BIT ADDER
B S A CO CI
CLOCK OUT
8 8
DATA
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
11
8 8 8-BIT LATCH
D Q >CLK
8-BIT ADDER
B S A CO CI
OUT
8 8
DI DO W A
64Kx8 RAM
1 6
CONTROL PANEL RIPPLE COUNTER OSCILLATOR
CLK O
put together
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
12
RIPPLE COUNTER OSCILLATOR
CLK O
AND
NOT
cut connection to clock if ripple counter reaches final number
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
13
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
14
4-BIT FULL ADDER A0 B3 S0 CO CI A1 A2 A3 B0 B1 B2 S1 S2 S3
B0 B1 B2 B3 SUB A0 A1 A2 A3 OVERFLOW SUM SUB SUB
indicate operation from last bit of ripple counter
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
15
8 8 8-BIT LATCH
D Q >CLK
ALU
B S A CO CI
OUT
8 8
DI DO W A
64Kx8 RAM
1 6
CONTROL PANEL RIPPLE COUNTER
CLK O SUB O0
OSCILLATOR AND
HALT
NOT
counter as instruction flag
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
16
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
17
⇒ A programmable computer
– separate instruction memory – instructions: add or subtract
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
18
8 8 8-BIT LATCH
D Q >CLK
ALU
B S A CO CI
OUT
8 8
DI DO W A
64Kx8 RAM
16
CONTROL PANEL RIPPLE COUNTER
CLK O SUB
OSCILLATOR AND
HALT
NOT
DI DO W A
64Kx8 RAM
1 6
CONTROL PANEL CONTROL UNIT
8
Code Data
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
19
Operation Code (hex) Add 20h Subtract 21h
Address Code Data Accumulator 0000h 20h Add 01h 0001h 20h Add 02h 0002h 21h Subtract 01h 0003h 20h Add 08h 0004h 21h Subtract 03h 00h 01h 03h 02h 0ah 07h
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
20
load number from memory into accumulator
store accumulator value in memory
block clock
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
21
Operation Code (hex) Load 10h Store 11h Add 20h Subtract 21h Halt FFh
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
22
8 8 8-BIT LATCH
D Q >CLK
ALU
B S A CO CI
OUT
8
DI DO W A
64Kx8 RAM
1 6
CONTROL PANEL RIPPLE COUNTER
CLK O SUB
OSCILLATOR AND
HALT
NOT
DI DO W A
64Kx8 RAM
16
CONTROL PANEL CTRL UNIT
8
Code Data
8 8 SELECTOR 8
INSTR STR SUB HALT LD
NOT NOT
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
23
8 8 8-BIT LATCH
D Q >CLK
ALU
B S A CO CI
OUT
8
DI DO W A
64Kx8 RAM
1 6
CONTROL PANEL RIPPLE COUNTER
CLK O SUB
OSCILLATOR AND
HALT
NOT
DI DO W A
64Kx8 RAM
16
CONTROL PANEL CTRL UNIT
8
Code Data
8 8 SELECTOR 8
INSTR STR SUB HALT LD
NOT
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
24
8 8 8-BIT LATCH
D Q >CLK
ALU
B S A CO CI
OUT
8
DI DO W A
64Kx8 RAM
1 6
CONTROL PANEL RIPPLE COUNTER
CLK O SUB
OSCILLATOR AND
HALT
NOT
DI DO W A
64Kx8 RAM
16
CONTROL PANEL CTRL UNIT
8
Code Data
8 8 SELECTOR 8
INSTR STR SUB HALT LD
NOT
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
25
8 8 8-BIT LATCH
D Q >CLK
ALU
B S A CO CI
OUT
8
DI DO W A
64Kx8 RAM
1 6
CONTROL PANEL RIPPLE COUNTER
CLK O SUB
OSCILLATOR AND
HALT
NOT
DI DO W A
64Kx8 RAM
16
CONTROL PANEL CTRL UNIT
8
Code Data
8 8 SELECTOR 8
INSTR STR SUB HALT LD
NOT
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
26
Operation Code LD STR SUB HALT (hex) Load 10h 1 Store 11h 1 Add 20h Subtract 21h 1 Halt FFh 1
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
27
Address Code Data Accumulator 0000h 10h Load 56h 0001h 20h Add 2Ah 0002h 21h Subtract 38h 0003h 11h Store 0004h FFh Halt 00h 56h 80h 48h 48h 48h
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
28
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
29
– unsigned: 0 to 255 – signed:
Add the bytes separately
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
30
76ABh + 232Ch
0ABh +2Ch
076h +23h
99D7h
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
31
76ABh + 236Ch
0ABh +6Ch
(add the carry) 001h +76h +23h
9AD7h
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
32
– when addition results in a carry, store this in a flag – new add instruction that includes carry if flag set
– when subtraction results in a carry, store this in a flag – new subtract instruction that includes carry if flag set
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
33
ALU
B S A CO CI SUB
CTRL UNIT
INSTR STR CO HALT LD D >CLK Q CI SUB
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
34
Operation Code (hex) Load 10h Store 11h Add 20h Subtract 21h Add with carry 22h Subtract with borrow 23h Halt FFh
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
35
Address Code Data Carry Accumulator 0000h 10h Load ABh 0001h 20h Add 6Ch 0002h 11h Store 0003h 10h Load 76h 0004h 22h Add with carry 23h 0005h 11h Store 0006h FFh Halt 00h ABh 1 17h 1 17h 1 76h 9Ah 9Ah 9Ah
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
36
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
37
– code memory for instructions – data memory
– store code and data in same memory – add explicit addresses to instructions
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
38
Address Data 4000h ABh 4001h 76h 4002h 6Ch 4003h 23h
Address Bytes Code 0000h 10h 00h 40h Load 4000h 0003h 20h 02h 40h Add 4002h 0006h 11h 04h 40h Store 4004h 0009h 10h 01h 40h Load 4001h 000Ch 22h 03h 40h Add with carry 4003h 000Fh 11h 05h 40h Store 4005h 0012h FFh Halt Note: Instructions take up 1 or 3 bytes
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
39
DI DO W A
64Kx8 RAM CONTROL PANEL RIPPLE COUNTER
CLK O
OSCILLATOR
AND
HALT
NOT
8 8 8 8 LATCH
D Q >CLK
8 8 LATCH
D Q >CLK
8 LATCH
D Q >CLK
CTRL UNIT
INSTR STR CO HALT LD CI SUB Z D1 D2
INSTRUCTION FETCH 8
CLK S X INSTR CLK
3 registers: code and 2 byte data
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
40
DI DO W A
64Kx8 RAM CONTROL PANEL RIPPLE COUNTER
CLK O
OSCILLATOR
AND
HALT
NOT
8 8 8 8 LATCH
D Q >CLK
8 8 LATCH
D Q >CLK
8 LATCH
D Q >CLK
CTRL UNIT
INSTR STR CO HALT LD CI SUB Z D1 D2
INSTRUCTION FETCH 8
CLK S X INSTR CLK
Transfer bytes from memory to instruction code and data register
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
41
DI DO W A
64Kx8 RAM CONTROL PANEL RIPPLE COUNTER
CLK O
OSCILLATOR
AND
HALT
NOT
8 8 8 8 LATCH
D Q >CLK
8 8 LATCH
D Q >CLK
8 LATCH
D Q >CLK
CTRL UNIT
INSTR STR CO HALT LD CI SUB Z D1 D2
INSTRUCTION FETCH 8
CLK S X INSTR CLK
Instruction fetch logic determines which register is written to
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
42
DI DO W A
64Kx8 RAM CONTROL PANEL RIPPLE COUNTER
CLK O
OSCILLATOR
AND
HALT
NOT
8 8 8 8 LATCH
D Q >CLK
8 8 LATCH
D Q >CLK
8 LATCH
D Q >CLK
CTRL UNIT
INSTR STR CO HALT LD CI SUB Z D1 D2
INSTRUCTION FETCH 8
CLK S X INSTR CLK
This is informed by instruction code
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
43
DI DO W A
64Kx8 RAM CONTROL PANEL RIPPLE COUNTER
CLK O
OSCILLATOR
AND
HALT
NOT
8 8 8 8 LATCH
D Q >CLK
8 8 LATCH
D Q >CLK
8 LATCH
D Q >CLK
CTRL UNIT
INSTR STR CO HALT LD CI SUB Z D1 D2
INSTRUCTION FETCH 8
CLK S X INSTR CLK
Once all registers are filled, execute instruction
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
44
read byte from memory, pass to ALU
read byte from memory, store in accumulator
read byte from accumulator, store in memory
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
45
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
46
load number1 into accumulator loop subtract 1 from number2 last if number2 = 0 add number1 to accumulator store accumulator in result
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
47
– set the ripple counter to specified value
– detect that subtraction resulted in number 0 – implemented as flag of the ALU
– check if zero flag is set – only then update ripple counter – otherwise, do nothing
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
48
ALU
B S A CO CI SUB
CTRL UNIT
INSTR STR CO HALT LD D >CLK Q CI SUB
D >CLK Q
Z Z
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
49
Operation Code (hex) Load 10h Store 11h Add 20h Subtract 21h Add with carry 22h Subtract with borrow 23h Jump 30h Jump if zero 31h Jump if carry 32h Jump if not zero 33h Jump if not carry 34h Halt FFh
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019
50
Address Data 4000h 0Bh 4001h 0Fh 4002h 01h
Address Bytes Code 0000h 10h 00h 40h Load 4000h ; load number1 0003h 11h 03h 40h Store 4003h ; save in result 0006h 10h 01h 40h Load 4001h ; load number2 0009h 21h 02h 40h Subtract 4002h ; subtract 1 000Bh 31h 18h 00h jump if zero to 0018h ; jump to end if done 000Fh 10h 03h 40h load 4003h ; load result 0012h 20h 00h 40h add 4000h ; add number1 0015h 30h 03h 00h jump to 0003h ; loop 0018h FFh halt ; quit
Philipp Koehn Computer Systems Fundamental: Instructions 11 September 2019