cse$305$introduc0on$to$ …zhiyang/teaching/cse305/...letʼs$start,$recall$last0me$abacus$case$ $...

20
CSE 305 Introduc0on to Programming Languages Lecture 2 CSE @ SUNYBuffalo Zhi Yang Courtesy of Google

Upload: others

Post on 03-Apr-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

CSE  305  Introduc0on  to  Programming  Languages    

Lecture  2    

CSE  @  SUNY-­‐Buffalo    Zhi  Yang    

Courtesy  of  Google      

Page 2: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

No0ce    •  Lecture  Time:  •  10:00am  -­‐  12:05pm  Clement  322    

 Recita.on  Time:  Bring  your  laptop  if  you  can  !~~~  

•  12:10pm  -­‐  1:15pm  Clement  322    We  will  be  using  recita0on  0me  for  explaining  homeworks  and  answering  ques0ons(you  can  grab  your  lunch  at  the  recita0on  0me).  We  also  give  quiz!  (but  the  quiz  account  for  no  points~~~)      Office  Hour:    

•  If  you  have  personal  issue,  just  come,  from  the  week  of  May27,every  Friday  1:00  -­‐  2:00  pm  Davis  106  

Page 3: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

Bulle0n  Board  

•  We  will  be  giving  out  homework  half    week  before  the  lecture,  so  if  you  have  any  problem,    

       you  can  use  recita0on  0me  in  class  ~~~      •  For  hw1,  For  division  opera0on,  what  you  need  to  get  is  quo0ent,  and  remainder  ~~~    

     

Page 4: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

Let’s  start,  recall  last  0me  abacus  case    • 1300  B.C.:  Chinese  use  wire  and  beads  to  redesign  abacus.  The  Chinese  abacus  shows  similari0es  to  the  Roman  model.  It  is  unclear  which  model  influenced  the  other.  

• On  the  leb,  you  see  two  abacuses  (abaci  is  also  correct).  On  both  abacuses,  we  see  the  number  1998.  The  top  area  of  each  abacus  is  used  for  fives,  and  the  bofom  area  is  used  for  ones.  Abacuses  are  used  for  doing  arithme0c.  When  doing  arithme0c,  you  move  the  beads.  The  posi0on  of  the  beads  represents  the  sum,  or  product,  so  far.  It  is  how  you  can  remember  the  par0al  sum  or  product.  Experts  in  the  use  of  the  abacus  can  be  very  fast  (and  accurate),  oben  faster  than  an  expert  with  a  calculator,  especially  addi0on  and  subtrac0on.  Such  an  expert  on  the  abacus  is  especially  adept  at  data  entry.  

• The  Japanese  abacus,  the  soroban,  is  more  elegant,  as  the  Chinese  abacus  has  redundant  beads.  With  the  Chinese  abacus,  you  never  have  to  use  the  bofom  bead  in  each  column,  in  both  the  "ones"  and  "fives"  areas.  These  extra  beads  are  apparently  useful,  if  you  use  an  extra  step  every  0me  you  carry.  You  no0ce  that  you  have  all  five  beads  up,  so  then  you  know  you  should  execute  a  carry.  

Ques0on:  both  Japanese  and  Chinese  abacus  are  10-­‐base,  can  we  make  a    2-­‐base  abacus?    For  example,  we  want  a  2-­‐based  representa0on  of  1998.      

Page 5: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

•  1)  First,  yes,  we  can  make  a  2-­‐base  abacus  (Courtesy  of  Jim  Loy)    

 

Generaliza0on  of  Concept  of  Abacus  

This  is  the  number  1998.  

Let’s  do  a  calcula0on  of  1998+232  like  last  0me  we  did  again  .    

•  2)  It  looks  like  a  modern  concept  of  switches  ~~~    

Or  a  memory  unit:      

Page 6: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

OK,  don’t  be  in  a  hurry,  let  see  how  modern  addi0on  works  •  Let’s  summarize  base-­‐2  addi0on  (courtesy  of  Wikipedia):              first  number(A):                        0                                                0                                1                                1              Second  number(B):  +        0                                        +                    1                +            0                              1                result:                                                0                                                                1                                  1                              0                carry:                                                    0                                                              0                                  0                                1  

Let’s  summarize,  for  result:                                                                                                for  carry:                                  

So,  we  get  conclusion:  the  result  can  be  represented  by  a  XOR  gate,  and  the  carry  can  be  represented  by  an  AND  gate      

Page 7: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

 OK,  what  is  a  gate(BTW)?    •  A  logic  gate  is  an  idealized  or  physical  device  implemen0ng  

a  Boolean  func0on,  that  is,  it  performs  a  logical  opera0on  on  one  or  more  logical  inputs,  and  produces  a  single  logical  output:(courtesy  of  Wikipedia):  

Page 8: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

Logic  gate(Cont.)  

•  Those  are  seven  gates  we  will  be  using  in  hw1:  

Page 9: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

So  we  do  an  1-­‐bit  base2  adder  based  on  the  unit  of  base2  abacus    •  So  this  1-­‐bit  base2  adder  is    called  half  adder(courtesy  of  Wikipedia):  

 •  In  comparison,  a  full  adder  must  consider  the  carry  from  previous  level  :        

Page 10: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

Can  I  become  lazier?    First,  recall  what  we  call  it  1-­‐bit  full  adder:    

So,  we  make  a  simpler  version  of  4  bit  adder,  what  we  call  a  Ripple-­‐Carry  Adder:    

Page 11: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

4  bit  Carry  Look  Ahead  Adder  •  Below  is  the  schema0c(courtesy  of  Professor  Sam  Kozai0s,  sorry  I  am  too  lazy  ~~~  )    

Page 12: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

It’s  0me  to  get  hand  dirty:  what  is  underline  device  for  implemen0ng  logic  gates?    

•  There  is  a  history  ~~~  or  you  can  say,  a  real  story  ~~~  

   

Page 13: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

So  we  need  a  2-­‐state  electronic  “switches”  to  represent  our  modern  “abacus”  

The  first  inven0on  is  a    electromagne0c  relay  (Courtesy  of  John  Savard)    

Ques0on:  If  we  want  out  to  be  high  voltage(or  1),    what  are  A,  B,  C,  D,  E  respec0vely?    

Page 14: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

Answer    

Logic:    OUT  =  ABC  +  DE    (no0ce  above  graph  only  give  one  combina0on  of  all  possible  inputs  ~~~)      

Page 15: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

Now,  improvement:  Vacuum  Tube    

Page 16: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

Well,  a  lifle  more  modern  device  ~~~    transistors  ~~~  

Page 17: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

History  of  those  devices  ~~~    •  Howard  Aiken  •  (1944)  The  Mark  I  ,through  a  collabora0on  with  Harvard  University,  IBM,  and  the  

U.S.  War  Department,  was  developed  to  handle  a  large  amount  of  number  crunching.  The  complex  equa0on  solving  that  was  needed  to  map  logis0cs  in  the  military  was  the  driving  force  behind  this  project.  (  The  United  States  was  at  war  with  Germany.)  The  Mark  I  was  the  first  automa.c  calculator.  It  was  not  electronic,  but  did  use  electromagne0c  relays  with  mechanical  counters.  It  was  said  that  when  it  ran  the  clicking  sound  was  unbearable.  Paper  tape  with  hole  punched  in  it  provided  the  instruc0on  sets,  and  the  output  was  returned  through  holes  punched  in  cards.  

•  hfps://www.youtube.com/watch?v=qDaYDOJk6Rc  

Page 18: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

Vacuum  Tube  •  J.  Presper  Eckert  and  John  W.  Mauchly  •  (ENIAC,  1946  University  of  Pennsylvania)  The  ENIAC  (Electronic  Numerical  

Integrator  and  Calculator)  was  an  electronic  computer  sponsored  by  the  war  department.  It  was  classified  because  of  war  purposes.  The  ENIAC  was  so  large  that  it  took  up  a  room  ten  feet  high  by  about  ten  feet  wide  and  several  hundred  feet  in  length.  It  could  perform  mul0plica0on  in  the  3/1000  of  a  second  range.  There  were  18,000  vacuum  tubes  in  the  machine  and  instruc0ons  had  to  be  fed  into  the  machine  by  way  of  switches  because  there  was  no  internal  memory  within  the  machine.  

•  hfps://www.youtube.com/watch?v=k4oGI_dNaPc  

Page 19: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

Transistors  ~~~  •  From  November  17,  1947  to  December  23,  1947,  John  Bardeen  and  

Walter  Brafain  at  AT&T's  Bell  Labs  in  the  United  States,  performed  experiments  and  observed  that  when  two  gold  point  contacts  were  applied  to  a  crystal  of  germanium,  a  signal  was  produced  with  the  output  power  greater  than  the  input.    Solid  State  Physics  Group  leader  William  Shockley  saw  the  poten0al  in  this,  and  over  the  next  few  months  worked  to  greatly  expand  the  knowledge  of  semiconductors.  The  term  transistor  was  coined  by  John  R.  Pierce  as  a  portmanteau  of  the  term  "transfer  resistor”.  According  to  Lillian  Hoddeson  and  Vicki  Daitch,  authors  of  a  biography  of  John  Bardeen,  Shockley  had  proposed  that  Bell  Labs'  first  patent  for  a  transistor  should  be  based  on  the  field-­‐effect  and  that  he  be  named  as  the  inventor.  Having  unearthed  Lilienfeld’s  patents  that  went  into  obscurity  years  earlier,  lawyers  at  Bell  Labs  advised  against  Shockley's  proposal  because  the  idea  of  a  field-­‐effect  transistor  that  used  an  electric  field  as  a  "grid"  was  not  new.  Instead,  what  Bardeen,  Brafain,  and  Shockley  invented  in  1947  was  the  first  bipolar  point-­‐contact  transistor.  In  acknowledgement  of  this  accomplishment,  Shockley,  Bardeen,  and  Brafain  were  jointly  awarded  the  1956  Nobel  Prize  in  Physics  "for  their  researches  on  semiconductors  and  their  discovery  of  the  transistor  effect.”  

•  hfps://www.youtube.com/watch?v=b4TLAozsQyE  

•  hfps://www.youtube.com/watch?v=b4TLAozsQyE  

Page 20: CSE$305$Introduc0on$to$ …zhiyang/teaching/cse305/...Letʼs$start,$recall$last0me$abacus$case$ $ •1300B.C.: $Chinese$use$wire$and$beads$to$redesign$ abacus.$The$Chinese$abacus$shows$similari0es$to$the$Roman$

Brief  introduc0on  to  Verilog  

•  Verilog,  standardlized  as  IEEE  1364,  is  a  hardware  descrip0on  language,  it  is  most  commonly  used  in  the  design  and  verifica0on  of  digital  circuit  and  register-­‐transfer  level  of  abstrac0on.    

•  Go  here      hfp://en.wikipedia.org/wiki/Verilog