SCRAM Instructions II Philipp Koehn 23 February 2018 Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
Reminder 1 • 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 II 23 February 2018
Circuit (At This Point) 2 W W MAR A 16x8 RAM W S PC Selector DI DO INC W MBR W IR C D Decoder Q W AC Control Logic Unit T NOT INC CLEAR Decoder T Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
Instruction Fetch 3 • Retrieve instruction from memory • Increase program counter Time Command MAR ← PC t 0 MBR ← M, PC ← PC + 1 t 1 IR ← MBR t 2 Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
Micro Program for STA 4 • Store value from accumulator Op Code Time Command MAR ← IR(D) q 3 t 3 M ← AC q 3 t 4 Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
q 3 t 3 : MAR ← IR(D) 5 W W MAR A 16x8 RAM W S PC Selector DI DO INC W MBR W IR C D Decoder Q W AC Control Logic Unit T NOT INC CLEAR Decoder T Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
q 3 t 4 : M ← AC 6 W W MAR A 16x8 RAM W S PC Selector D I DO INC W MBR W IR C D Decoder Q W AC Control Logic Unit T NOT INC CLEAR Decoder T Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
7 arithmetic logic unit Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
Arithmetric Logic Unit 8 A B SUB ALU CO CI Z S • 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 II 23 February 2018
Accumulator 9 A B SUB ALU CO CI Z S W AC • Store result of ALU operation in accumulator (AC) Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
AC = AC ± B 10 A B SUB ALU CO CI Z S W AC • Accumulator feeds back into ALU • Operations are AC = AC + B or AC = AC - B Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
ALU in Circuit 11 W W A MAR 16x8 RAM W PC S Selector DI DO INC W MBR W IR C D Decoder A B SUB ALU CO CI Z Q S Control S Selector Logic Unit W AC T NOT INC CLEAR Decoder T Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
12 add Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
ADD: Add to Accumulator 13 • Add value from memory address to accumulator • 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 II 23 February 2018
Micro Program for ADD 14 • Load indirectly into accumulator Op Code Time Command MAR ← IR(D) q 5 t 3 MBR ← M q 5 t 4 AC ← AC + MBR q 5 t 5 Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
q 5 t 3 : MAR ← IR(D) 15 W W MAR A 16x8 RAM W S PC Selector DI DO INC W MBR W IR C D Decoder A B SUB ALU CO CI Z Q S Control S Selector Logic Unit W AC T NOT INC CLEAR Decoder T Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
q 5 t 4 : MBR ← M 16 W W MAR A 16x8 RAM W S PC Selector DI DO INC W MBR W IR C D Decoder A B SUB ALU CO CI Z Q S Control S Selector Logic Unit W AC T NOT INC CLEAR Decoder T Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
q 5 t 5 : AC ← AC + MBR 17 W W MAR A 16x8 RAM W S PC Selector DI DO INC W MBR W IR C D Decoder A B SUB ALU CO CI Z Q S Control S Selector Logic Unit W AC T NOT INC CLEAR Decoder T Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
18 sub Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
SUB: Subtract from Accumulator 19 • Subtract from accumulator the value from memory • Same as ADD, just set subtraction flag of ALU Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
Micro Program for SUB 20 • Load indirectly into accumulator Op Code Time Command MAR ← IR(D) q 5 t 3 MBR ← M q 5 t 4 AC ← AC - MBR q 5 t 5 Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
q 5 t 3 : MAR ← IR(D) 21 W W MAR A 16x8 RAM W S PC Selector DI DO INC W MBR W IR C D Decoder A B SUB ALU CO CI Z Q S Control S Selector Logic Unit W AC T NOT INC CLEAR Decoder T Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
q 5 t 4 : MBR ← M 22 W W MAR A 16x8 RAM W S PC Selector DI DO INC W MBR W IR C D Decoder A B SUB ALU CO CI Z Q S Control S Selector Logic Unit W AC T NOT INC CLEAR Decoder T Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
q 5 t 5 : AC ← AC + MBR 23 W W MAR A 16x8 RAM W S PC Selector DI DO INC W MBR W IR C D Decoder A B SUB ALU CO CI Z Q S Control S Selector Logic Unit W AC T NOT INC CLEAR Decoder T Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
24 jmp Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
Program Counter (PC) 25 • Position of the next instruction is stored in program counter • This gets updated during instruction fetch Time Command MAR ← PC t 0 MBR ← M t 1 IR ← MBR t 2 ⇒ PC ← PC + 1 t 3 Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
JMP: Jump 26 • 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 II 23 February 2018
Micro Program for JMP 27 • Change program counter to specified address Op Code Time Command PC ← IR(D) q 7 t 3 Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
q 7 t 3 : PC ← IR(D) 28 W W MAR A 16x8 RAM W S PC Selector DI DO INC W MBR W IR C D Decoder A B SUB ALU CO CI Z Q S Control S Selector Logic Unit W AC T NOT INC CLEAR Decoder T Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
29 jpz Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
Zero Flag 30 • Zero flag – set when result of a ALU operation is 0 – stored in flag A B SUB ALU CO CI W Z Z S Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
Z Flag in Circuit 31 W W A MAR 16x8 RAM W S PC Selector DO DI INC W MBR W IR C D Decoder A B SUB ALU CO CI W Z Z Q S Control S Selector Logic Unit W AC T NOT INC CLEAR Decoder T Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
Micro Program for JPZ 32 • Z flag is a condition for executing a micro program (same as JMP) Zero Op Code Time Command 1 PC ← IR(D) q 7 t 3 • If not set, no micro program is executed Philipp Koehn Computer Systems Fundamentals: SCRAM Instructions II 23 February 2018
Recommend
More recommend