I wanted a computer,but all I got was a transistor.Denis Defreyne1
View Slide
2I will explain how to build a computer from scratch.I cannot do this without taking some shortcuts.I will tell lies.CAUTION
3
In the beginning,the transistor was created.4
5GATESOURCEDRAIN
6GATESOURCEDRAIN
7GATESOURCEDRAIN
8
9
10
11
12AND
13
14
15
16
OR17
Now we have gates,and we can forgetabout transistors.18
19ORAND XORNANDNOT…
A B Sum0 0 00 1 11 0 11 1 020
A B Carry0001A B Sum Carry0 0 00 1 11 0 11 1 021ANDXOR
22ANDABCARRYXOR SUM
ADDCARRYSUMAB23
24ADDCARRYSUMABCARRY
25ADDSUM0A0B0
26ADDSUM0A0B0ADDSUM1A1B1
27ADDSUM0A0B0ADDSUM1A1B1ADDSUM0A0B0ADDSUM1A1B1ADDA2B2SUM2
28ADDABSUM
ADD00010001000001010001011029
ADD1752230
31ADD RABMUL RABDIV RABMOD RAB
ABADDMULDIVMODRRRR32
ABADDMULDIVMODMUXSR33
34MUX
350MUX
361MUX
372MUX
383MUX
39ABADDMULDIVMODMUXSR
40ALU RABS
A B S Result15 7 0 (+) 2215 7 1 (*) 10515 7 2 (/) 215 7 3 (%) 141
Now we havean arithmetic logic unit.42
43OR NOTOR NOT QSR
OR NOTOR NOT QSR44
OR NOTOR NOT QSR45
OR NOTOR NOT QSR46
OR NOTOR NOT QSR47
OR NOTOR NOT QSR48
49SR-LATCHSRQsetreset
D-LATCHDEQ50dataenable write
51D-LATCHD0 Q0D-LATCHD1 Q1D-LATCHD2 Q2D-LATCHD3 Q3D-LATCHD4 Q4D-LATCHD5 Q5D-LATCHD6 Q6D-LATCHD7 Q7E
52REGISTER(8 BIT)DEQ
Now we have registers.53
Q:What distinguishes a computerfrom a simple calculator?54
A:You can program a computer,but not a calculator.55
56OPCODEVALUE 1VALUE 22715
57OPCODEVALUE 1VALUE 2ALU R
OPCODEVALUE 1VALUE 2ALUREGISTER(8 BIT)158
OPCODEVALUE 1VALUE 2ALUREGISTERFILEOUTPUT REG159
OPCODEINPUT REG 1INPUT REG 2REGISTERFILEOUTPUT REGALU00160
61OPCODEINPUT REG 1INPUT REG 2OUTPUT REG
62INSTRUCTIONREGISTEROPCODEINPUT REG 1INPUT REG 2OUTPUT REG
63MEMORYINSTRUCTIONREGISTEROPCODEINPUT REG 1INPUT REG 2OUTPUT REG
MEMORYINSTRUCTIONREGISTEROPCODEINPUT REG 1INPUT REG 2OUTPUT REG064
65INSTRUCTIONPOINTERREGISTERMEMORYINSTRUCTIONREGISTEROPCODEINPUT REG 1INPUT REG 2OUTPUT REG
66INSTRUCTIONPOINTERREGISTERMEMORYINSTRUCTIONREGISTERADD 4OPCODEINPUT REG 1INPUT REG 2OUTPUT REG
Now we have the hardwarefor a programmable computer,and we can forget the hardware.67
680 3 0 2Add register 0 and register 2,and store result in register 3: OPCODEINPUT REG 1OUTPUT REGINPUT REG 2
69“add r3 r0 r2”Add register 0 and register 2,and store result in register 3:
70“add r3 r0 r2”0 3 0 2assembly languagemachine codeassembler
16 0 0 12 127 56 16 10 3 224 211 18 1 0 00 0 7 32 15 2 1 191 0 1 15 0 2 6 1214 0 255 071
li r0, 819000li r1, 254163cmpi r1, 0jeq @endmov r2, r1mod r1, r0, r1mov r0, r2jmp @startprn r0halt72
73cmpmodaddsubmuldivxororandshlshrnotARITHMETIC
74jjejnejgjgejljlecmpmodaddsubmuldivxororandshlshrnotlwlhlbswshsbSTACK FUNCSPECIALcallretpushpopprnhaltBRANCHINGARITHMETICmovliMEMORY REG
DEMO75
github.com/ddfreyne/rcpu76
77
78slack @denis / mail [email protected]Denis DefreyneAsk me about Belgian beer.