IDC Herzliy Shimon Schocken Course Overview Shimon Schocken Spring 2005 Course Overview 1 Elements of Computing Systems Course gols Course ojectives: Understnd how HW+SW systems re uilt, nd how they work Lern how to rek complex prolems into simpler ones Lern how lrge scle development projects re plnned nd executed Hve fun. Methodology: Build / experiment with trnsprent computer tht we cn fully understnd. Course Overview 2 Elements of Computing Systems
Course theme nd structure Humn Thought Astrct design Chpters 9, 12 H.L. Lnguge & Operting Sys. Compiler Chpters 10-11 Virtul Mchine Softwre hierrchy VM Trnsltor Chpters 7-8 Assemly Lnguge Assemler Chpter 6 Mchine Lnguge Computer Architecture Chpters 4-5 Hrdwre hierrchy Hrdwre Pltform Gte Logic Chpters 1-3 Chips & Logic Gtes Electricl Engineering Physics (Astrction implementtion prdigm) Course Overview 3 Elements of Computing Systems Resources nd rules Book Lectures Exercises Tools Course site Exm Projects Individul work policy Course Overview 4 Elements of Computing Systems
Appliction level: Pong Bll strction Bt strction Course Overview 5 Elements of Computing Systems The ig picture Humn Thought Astrct design Chpters 9, 12 H.L. Lnguge & Operting Sys. Compiler Chpters 10-11 Virtul Mchine Softwre hierrchy VM Trnsltor Chpters 7-8 Assemly Lnguge Assemler Chpter 6 Mchine Lnguge Computer Architecture Chpters 4-5 Hrdwre hierrchy Hrdwre Pltform Gte Logic Chpters 1-3 Chips & Logic Gtes Electricl Engineering Physics Course Overview 6 Elements of Computing Systems
High-level progrmming /** A Grphic Bt for Pong Gme */ clss Bt { field int x, y; // screen loction of the t's top-left corner field int width, height; // t's width & height // The clss constructor nd most of the clss methods re omitted } /** Drws (color=true) or erses (color=flse) the t */ method void drw(oolen color) { do Screen.setColor(color); do Screen.drwRectngle(x,y,x+width,y+height); return; } /** Moves the t one step (4 pixels) to the right. */ method void mover() { do drw(flse); // erse the t t the current loction let x = x + 4; // chnge the t's X-loction // ut don't go eyond the screen's right order if ((x + width) > 511) { let x = 511 - width; } do drw(true); // re-drw the t in the new loction return; } A typicl cll to n operting system method Bll strction Bt strction Course Overview 7 Elements of Computing Systems Operting system level /** An OS-level screen driver tht strcts the computer's physicl screen */ clss Screen { sttic oolen currentcolor; // the current color // The Screen clss is collection of methods, ech implementing one // strct screen-oriented opertion. Most of this code is omitted. } /** Drws rectngle in the current color. */ // the rectngle's top left corner is nchored t screen loction (x0,y0) // nd its width nd length re x1 nd y1, respectively. function void drwrectngle(int x0, int y0, int x1, int y1) { vr int x, y; let x = x0; while (x < x1) { let y = y0; while(y < y1) { do Screen.drwPixel(x,y); let y = y+1; } let x = x+1; } } Course Overview 8 Elements of Computing Systems
The ig picture Humn Thought Astrct design Chpters 9, 12 H.L. Lnguge & Operting Sys. Compiler Chpters 10-11 Virtul Mchine Softwre hierrchy VM Trnsltor Chpters 7-8 Assemly Lnguge Assemler Chpter 6 Mchine Lnguge Computer Architecture Chpters 4-5 Hrdwre hierrchy Hrdwre Pltform Gte Logic Chpters 1-3 Chips & Logic Gtes Electricl Engineering Physics Course Overview 9 Elements of Computing Systems The complete compiltion model Some... lnguge Some Other lnguge... Jck lnguge Proj. 9: uilding n pp. Proj. 12: uilding the OS Some compiler Some Other compiler Jck compiler Projects 10-11 VM lnguge VM implementtion over CISC pltforms VM imp. over RISC pltforms VM emultor VM imp. over the Hck pltform Projects 7-8 CISC mchine lnguge RISC mchine lnguge... written in high-level lnguge Hck mchine lnguge...... Projects 1-6 CISC mchine RISC mchine other digitl pltforms, ech equipped with its VM implementtion Any computer Hck computer Course Overview 10 Elements of Computing Systems
Compiltion > Intermedite code Source code (x+width)>511 prsing x + 511 width code genertion push x push width dd push 511 gt Astrction Syntx Anlysis Prse Tree Semntic Synthesis Implementtion Modulrity The implementtion is lso n strction. Course Overview 11 Elements of Computing Systems The Virtul Mchine (VM) if ((x+width)>511) { let x=511-width; } // VM implementtion push x // s1 push width // s2 dd // s3 memory (efore)... width x...... 450 75 sp s2 75 450 s4 s5 s9 push 511 gt if-goto L1 goto L2 // s4 // s5 // s6 // s7 sp 525 511 sp 1 sp 511 450 L1: push 511 push width su pop x L2:... // s8 // s9 // s10 // s11 sp s10 61 memory (fter)... width x...... 450 61 Course Overview 12 Elements of Computing Systems
The ig picture Humn Thought Astrct design Chpters 9, 12 H.L. Lnguge & Operting Sys. Compiler Chpters 10-11 Virtul Mchine Softwre hierrchy VM Trnsltor Chpters 7-8 Assemly Lnguge Assemler Chpter 6 Mchine Lnguge Computer Architecture Chpters 4-5 Hrdwre hierrchy Hrdwre Pltform Gte Logic Chpters 1-3 Chips & Logic Gtes Electricl Engineering Physics Course Overview 13 Elements of Computing Systems Low-level progrmming Virtul mchine progrm... push x push width dd push 511 gt if-goto L1 goto L2 L1: push 511 push width su pop x L2: VM trnsltor Assemly progrm // push 511 @511 D=A // D=511 @SP A=M M=D // *SP=D @SP @SP M=M+1 // SP++ Assemler Executle 0000000000000000 1110110010001000... Course Overview 14 Elements of Computing Systems
The ig picture Humn Thought Astrct design Chpters 9, 12 H.L. Lnguge & Operting Sys. Compiler Chpters 10-11 Virtul Mchine Softwre hierrchy VM Trnsltor Chpters 7-8 Assemly Lnguge Assemler Chpter 6 Mchine Lnguge Computer Architecture Chpters 4-5 Hrdwre hierrchy Hrdwre Pltform Gte Logic Chpters 1-3 Chips & Logic Gtes Electricl Engineering Physics Course Overview 15 Elements of Computing Systems Mchine lnguge semntics Code semntics, s interpreted y the Hck hrdwre pltform Instruction code (0= ddress inst.) Address Code syntx 0000000000000000 1111110111001000 @0 M=M-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 1 1 1 0 0 1 0 0 0 Instruction code (1= compute inst.) ALU opertion code Destintion Code Jump Code (M-1) (M) (no jump) We need HW rchitecture tht will relize this semntics The HW pltform should e designed to: Prse instructions, nd Execute them Course Overview 16 Elements of Computing Systems
Computer rchitecture instruction Instruction Memory D A M ALU dt Dt Memory (M) Progrm Counter ddress of next instruction dt in RAM(A) A typicl Von Neumnn mchine Course Overview 17 Elements of Computing Systems The ig picture Humn Thought Astrct design Chpters 9, 12 H.L. Lnguge & Operting Sys. Compiler Chpters 10-11 Virtul Mchine Softwre hierrchy VM Trnsltor Chpters 7-8 Assemly Lnguge Assemler Chpter 6 Mchine Lnguge Computer Architecture Chpters 4-5 Hrdwre hierrchy Hrdwre Pltform Gte Logic Chpters 1-3 Chips & Logic Gtes Electricl Engineering Physics Course Overview 18 Elements of Computing Systems
Gte logic HW pltform = inter-connected set of chips Chips re mde of simpler chips, ll the wy down to logic gtes Logic gte = HW element tht implements certin Boolen function Every chip nd gte hs n interfce, specifying WHAT it is doing, nd n implementtion, specifying HOW it is doing it. Interfce Implementtion Xor Not And Or 0 0 0 0 1 1 1 0 1 1 1 0 Not And Course Overview 19 Elements of Computing Systems Hrdwre Description Lnguge (HDL) Not And Or Not And CHIP Xor { IN,; OUT ; PARTS: Not(in=,=Not); Not(in=,=Not); And(=,=Not,=w1); And(=Not,=,=w2); Or(=w1,=w2,=); } Course Overview 20 Elements of Computing Systems
The tour ends Interfce Implementtion (CMOS) Nnd 0 0 1 0 1 1 1 0 1 1 1 0 Course Overview 21 Elements of Computing Systems On the power of strctions Astrction: n ttempt to cpture in thought the essence of something Cognitive Mth Sciences Computer science Top down / ottom up Astrction Implementtion ( ) the sic theme Built using / Reduced into: Astrction Course Overview 22 Elements of Computing Systems
Fmous strction Course Overview 23 Elements of Computing Systems Finl note We delierte not ends, ut mens. For doctor does not delierte whether he shll hel, nor n ortor whether he shll persude... They ssume the end nd consider how nd y wht mens it is ttined, nd if it seems esily nd est produced therey; And if it is chieved y some mens, they consider how it will e chieved, nd y wht mens this will e chieved, until they come to the first cuse. And wht is lst in the order of nlysis seems to e first in the order of ecoming. Course Overview 24 Elements of Computing Systems
IDC Herzliy Shimon Schocken Boolen Logic Shimon Schocken Course Overview 25 Elements of Computing Systems Boolen lger Some elementry Boolen opertors: Not(x) And(x,y) Or(x,y) Nnd(x,y) Boolen functions: x y z f ( x, y, z) = ( x + y) z x Not(x) Not(x) 0 1 1 0 x y Or(x,y) Or(x,y) 0 0 0 0 1 1 1 0 1 1 1 1 x y And(x,y) And(x,y) 0 0 0 0 1 0 1 0 0 1 1 1 x y Nnd(x,x) Nnd(x,x) 0 0 1 0 1 1 1 0 1 1 1 0 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 0 Functionl expression VS truth tle expression Importnt result: Every Boolen function cn e expressed using And, Or, Not Course Overview 26 Elements of Computing Systems
All Boolen functions of 2 vriles Course Overview 27 Elements of Computing Systems Boolen lger Given: Nnd(,), flse Not() = Nnd(,) true = Not(flse) And(,) =... George Boole, 1815-1864 ( A Clculus of Logic ) Or(,) =... Xor(,) =... Etc. Course Overview 28 Elements of Computing Systems
Gte logic Gte logic gte rchitecture designed to implement oolen function Elementry gtes: Composite gtes: Interfce VS implementtion. Course Overview 29 Elements of Computing Systems Circuit implementtions AND gte 0 0 0 0 1 0 1 0 0 1 1 1 OR gte 0 0 0 0 1 1 1 0 1 1 1 1 power supply power supply c 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 c AND (,,c) c AND AND Physicl reliztions of logic gtes re irrelevnt to computer science. Course Overview 30 Elements of Computing Systems
Gte Logic Interfce Xor Clude Shnnon, 1916-2001 0 0 0 0 1 1 1 0 1 1 1 0 Implementtion Not And ( Symolic Anlysis of Rely nd Switching Circuits ) Or Not And Xor(,)=Or(,Not(),Not(),)) Course Overview 31 Elements of Computing Systems Project 1: elementry logic gtes Given: Nnd(,), flse Build: Nnd(,) Nnd(,) 0 0 1 0 1 1 1 0 1 1 1 0 Not() =... true =... And(,) =... Or(,) =... Mux(s,,) =... Etc. - 12 gtes ltogether. Course Overview 32 Elements of Computing Systems
Building n And gte And And.cmp 0 0 0 0 1 0 1 0 0 1 1 1 Contrct: When running your.hdl on our.tst, your. should e the sme s our.cmp. And.hdl And.tst CHIP CHIP And And { IN IN,, ; ; OUT OUT ; ; // // implementtion missing missing } lod lod And.hdl, And.hdl, put-file And., And., compre-to And.cmp, And.cmp, put-list ; ; set set 0,set 0,set 0,evl,put; set set 0,set 0,set 1,evl,put; set set 1,set 1,set 0,evl,put; set set 1, 1, set set 1, 1, evl, evl, put; put; Course Overview 33 Elements of Computing Systems Building n And gte Implementtion: And(,) = Not(Nnd(,)) NAND x in NOT And.hdl CHIP CHIP And And { IN IN,, ; ; OUT OUT ; ; Nnd( Nnd( =,, =,, = x); x); Not(in Not(in = x, x, = ) ) } Course Overview 34 Elements of Computing Systems
Hrdwre simultor HDL progrm test script put file Course Overview 35 Elements of Computing Systems Multiplexor (n interesting chip) sel sel 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1 Mux sel 0 1 Implementtion: sed on Not, And, Or gtes. Course Overview 36 Elements of Computing Systems
Cnonicl representtion Suspect function (-l-leinitz): Ech suspect my or my not hve n lii (), motivtion to commit the crime (m), nd reltionship to the wepon found in the scene of the crime (w). The police decides to focus ttention only on suspects for whom the proposition Not() And (m Or w) is true. Truth tle of the "suspect" function s (, m, w) = ( m + w) Cnonicl form: s (, m, w) = m w + mw + mw Course Overview 37 Elements of Computing Systems Two possile implementtions s (, m, w) = ( m + w) m w nd or s s (, m, w) = m w + mw + mw m w nd nd or s nd Course Overview 38 Elements of Computing Systems
Progrmmle Logic Device for 3-wy functions c nd legend: ctive fuse lown fuse 8 nd terms connected to the sme 3 inputs. or f(,,c) nd single or term connected to the puts of 8 nd terms _ PLD implementtion of f(,,c)= c + c (the on/off sttes of the fuses determine which gtes prticipte in the computtion) Course Overview 39 Elements of Computing Systems Some oservtions Ech Boolen function hs cnonicl representtion The cnonicl representtion is expressed in terms of And, Not, Or And, Not, Or cn e expressed in terms of Nnd lone Ergo, every Boolen function cn e relized y strndrd PLD consisting of Nnd gtes only Mss production c nd Universl uilding locks, unique connectivity (neurons).. or f(,,c) nd Course Overview 40 Elements of Computing Systems
IDC Herzliy Shimon Schocken Boolen Arithmetic Shimon Schocken Course Overview 41 Elements of Computing Systems Counting systems quntity deciml inry 3-it register 0 0 000 1 1 001 2 10 010 3 11 011 4 100 100 5 101 101 6 110 110 7 111 111 8 1000 overflow 9 1001 overflow 10 1010 overflow Course Overview 42 Elements of Computing Systems
Rtionle (9038) ten = 9 10 3 + 0 10 2 1 + 3 10 + 8 10 0 = 9038 (10011) two = 1 2 4 + 0 2 3 + 0 2 2 + 1 2 1 + 1 2 0 = 19 ( x n x n 1... x0 ) n = x i= 0 i i Course Overview 43 Elements of Computing Systems Binry ddition Assuming 4-it system: 0 0 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 no overflow 1 1 1 1 1 0 1 1 0 1 1 1 1 0 0 1 0 overflow Algorithm: exctly the sme s in deciml ddition Overflow (MSB crry) hs to e delt with. Course Overview 44 Elements of Computing Systems
Representing negtive numers (4-it system) 0 0000 1 0001 1111-1 2 0010 1110-2 3 0011 1101-3 4 0100 1100-4 5 0101 1011-5 6 0110 1010-6 7 0111 1001-7 1000-8 The codes of ll positive numers egin with 0 The codes of ll negtive numers egin with 1 To convert numer: leve ll triling 0 s nd first 1 intct, nd flip ll the remining its Exmple: 2-5 = 2 + (-5) = 0 0 1 0 + 1 0 1 1 1 1 0 1 = -3 Course Overview 45 Elements of Computing Systems Building n Adder chip 16 16 16-it dder 16 Adder: chip designed to dd two integers The construction hierrchy: Hlf dder: designed to dd 2 its Full dder: designed to dd 3 its Adder: designed to dd two n-it numers Course Overview 46 Elements of Computing Systems
Hlf dder (designed to dd 2 its) crry sum 0 0 0 0 0 0 0 1 0 1 0 1 hlf dder sum crry 0 1 1 0 Implementtion: sed on two gtes tht you ve seen efore. Course Overview 47 Elements of Computing Systems Full dder (designed to dd 3 its) c crry sum 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 1 1 1 0 1 0 0 0 1 c full dder sum crry 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1 Implementtion: cn e sed on hlf-dder gtes. Course Overview 48 Elements of Computing Systems
n-it Adder 16 16 16-it dder 16... 1 0 1 1 0 0 1 0 + 1 1 0 1 Implementtion: rry of full-dder gtes Course Overview 49 Elements of Computing Systems The ALU (of the Hck pltform) hlf dder sum crry c full dder sum crry x y 16 16 16-it dder 16 zx nx zy ny f no (x, y, control its) = x+y, x-y, y x, x y 16 its 16 its ALU 16 its 0, 1, -1, x, y, -x, -y, x!, y!, x+1, y+1, x-1, y-1, zr ng x&y, x y Course Overview 50 Elements of Computing Systems
ALU logic Course Overview 51 Elements of Computing Systems The ALU in the CPU context c1,c2,,c6 D D A A M Mux A/M ALU RAM Course Overview 52 Elements of Computing Systems
End note: Leinitz Descried inry clculus nd 4-it dder in 1694 The inry system my e used in plce of the deciml system; express ll numers y unity nd y nothing Prctice: uilt one of the first mechnicl clcultors Theory: dremed univerl, forml, lnguge of thought -- the Chrcteristic Universlis The drem s end: Turing nd Goedl in 1930 s. Course Overview 53 Elements of Computing Systems