cs64 computer organization - computer science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · cs64...

18
1 CS64 Computer Organization Lecture 1 Prof. Heather Zheng (1) Your computer never complains about the # of languages you use..

Upload: trinhthien

Post on 30-Jul-2018

241 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

1

CS64 Computer Organization

Lecture 1

Prof. Heather Zheng

(1) Your computer never complains about the # of languages you use..

Page 2: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

2

(2) The same program runs on almost all the computers…

?

Page 3: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

3

How  Computer  Operates  

http://www.staff.ncl.ac.uk/roger.broughton/museum/iomedia/pc.htm

Levels  of  Representa5on  

lw      $t0,  0($2)  lw      $t1,  4($2)  sw      $t1,  0($2)  sw      $t0,  4($2)  

temp = v[k];!v[k] = v[k+1];!

v[k+1] = temp;!

0000 1001 1100 0110 1010 1111 0101 1000 1010 1111 0101 1000 0000 1001 1100 0110 1100 0110 1010 1111 0101 1000 0000 1001 0101 1000 0000 1001 1100 0110 1010 1111 !

High Level Language Program (e.g., C)!

Assembly Language Program (e.g.,MIPS)!

Machine Language Program (MIPS)!

Hardware Architecture Description (Logic, Logisim, etc.) !

Compiler!

Assembler!

Machine Interpretation!

Logic Circuit Description (Logisim, etc.)!

Architecture Implementation!

Page 4: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

4

Levels  of  Representa5on  

lw      $t0,  0($2)  lw      $t1,  4($2)  sw      $t1,  0($2)  sw      $t0,  4($2)  

temp = v[k];!v[k] = v[k+1];!

v[k+1] = temp;!

0000 1001 1100 0110 1010 1111 0101 1000 1010 1111 0101 1000 0000 1001 1100 0110 1100 0110 1010 1111 0101 1000 0000 1001 0101 1000 0000 1001 1100 0110 1010 1111 !

High Level Language Program (e.g., C)!

Assembly Language Program (e.g.,MIPS)!

Machine Language Program (MIPS)!

Hardware Architecture Description (Logic, Logisim, etc.) !

Compiler!

Assembler!

Machine Interpretation!

Logic Circuit Description (Logisim, etc.)!

Architecture Implementation!

Abstrac5ons  

*  Coordina5on  across  many  levels  (layers)  of  abstrac0on  *  ISA  can  free  hardware/so9ware  from  each  other  

I/O system!Processor!

Compiler!Operating!

System!(Mac OSX)!

Application (ex: browser)!

Digital Design!Circuit Design!

Instruction Set! Architecture (ISA)!

Datapath & Control !

transistors!

Memory!Hardware!

Software! Assembler!

Page 5: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

5

Levels  of  Representa5on  

lw      $t0,  0($2)  lw      $t1,  4($2)  sw      $t1,  0($2)  sw      $t0,  4($2)  

temp = v[k];!v[k] = v[k+1];!

v[k+1] = temp;!

0000 1001 1100 0110 1010 1111 0101 1000 1010 1111 0101 1000 0000 1001 1100 0110 1100 0110 1010 1111 0101 1000 0000 1001 0101 1000 0000 1001 1100 0110 1010 1111 !

High Level Language Program (e.g., C)!

Assembly Language Program (e.g.,MIPS)!

Machine Language Program (MIPS)!

Hardware Architecture Description (Logic, Logisim, etc.) !

Compiler!

Assembler!

Machine Interpretation!

Logic Circuit Description (Logisim, etc.)!

Architecture Implementation!

Assembly  programming  

Digital  logic  design    

Linking  SoAware  &  Hardware  

software

hardware

Digital  logic  design  

Assembly  programming  

Page 6: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

6

WHY  DO  I  CARE?  

From  a  Programmer’s  Perspec5ve  

•  Most  people  learn  to  program  in  a  high  level  language  (e.g.  Java,  C++,  etc.)  – Abstracts  hardware  to  reduce  programming  complexity    

– Difficult  or  impossible  to  do  some  programming  tasks  efficiently    

•  Lower-­‐level  languages  needed  for  low-­‐level  programming    – Lower-­‐level  means  more  control  and  flexibility    

Improve  Your  SoIware’s  Efficiency  and  Speed  

Page 7: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

7

From  a  Hardware  Designer’s  Perspec5ve  

•  Understand  the  interac5on  between  hardware  and  soAware  

•  Build  a  proper  goal  of  hardware  design  

Improve  Your  Hardware’s  Performance  Avoid  Unnecessary  Complexity  à  Reduce  Cost  

Lecture    Schedule  

Page 8: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

8

General  Class  Info  •  When,  where  and  who  

–  Lecture:  TTh  11-­‐12:15pm,  SH  1430  –  Discussion  (required):  Friday,  12-­‐12:50  (SH1609),  1-­‐1:50  (LSB  1101)  

– Website:  hPp://www.cs.ucsb.edu/~htzheng/teach/cs64s11  –  Professor:  Heather  Zheng,  [email protected]  –  TA:  Gang  Wang  ([email protected]),  Wendy  Chun  ([email protected])  

•  Office  Hours:  –  Prof.  Zheng:    TBD  (HFH  1121)    –  TA:  TBD  

General  Class  Info  (2)  •  Prerequisites  

–  Engineering  3  or  CS  5AA-­‐ZZ  or  16;  and,  Mathema5cs  3C    

– Not  open  if  you  have  received  credit  for  ECE  15B  or  15  

•  Textbooks  –  R  -­‐-­‐  Charles  H.  Roth,  Jr.  and  Larry  Kinney,  Fundamentals  of  Logic  Design,  6th  Edi5on      

–  B  -­‐-­‐  Robert  L.  Brijon:  MIPS  Assembly  Language  Programming    

–  Class  handouts  

Page 9: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

9

Grading  Policy  •  Grading  

–  Homework  :  20%    –  Lab  :  25%    –  Quiz:  10%    (5-­‐7)  

•  Randomly  scheduled  throughout  the  quarter  •  Simple  ques5ons,  no  ajendance  =  0  

– Midterm:  20%      –  Final:  25%    

•  Academic  conduct  –  Verbal  discussion  of  homework  assignments  is  fine  –  No  sharing  of  wrijen  assignments  or  lab  assignments  –  Chea5ng  will  not  be  tolerated!  And  will  be  treated  seriously  and  punished  harshly  

Homework  and  Lab  

•  Homework  – 3-­‐5    total  – No  late  HW  submissions  accepted  

•  Labs  – 3-­‐4  – Use  PCSPIM  to  do  assembly  programming  – Mul5-­‐level  logic  design  – Sugges5on:  start  early  

•  One-­‐5me  2-­‐day  extension  coupon  

Page 10: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

10

Discussion  group  

•  Google  Group  (CS64S11)  as  the  discussion  forum  /  mailing  list    

hjp://groups.google.com/group/cs64s11    I  will  mass  add  everyone  using  your  umail  account    Before  April  1,  email  [email protected]  With  your  name  and  preferred  email  account  so  that  we  will  add  you  to  the  group    

INTRODUCTION  TO  COMPUTER  SYSTEMS  

History  and  Basic  Concepts  

Page 11: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

11

History  of  Computer  

Abacus – C. 3000 B.C.

Transistors - 1947

Apple II -- 1977 IBM PC - 1981

Page 12: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

12

2X transistors/chip per 1.5-2 years

http://www.guarddawg.net/GuardDawg/MooresLaw.jpg

Moore’s Law

The  Rate  of  Technology  Advance    

•  2X    every  2.0  years  in  memory  size;      every  1.5  years  in  processor  speed;      every  1.0  year  in  disk  capacity;    

•       Moore’s  Law  enables  processor                2X  transistors/chip  per  1.5  years  

Page 13: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

13

COMPUTER  BASICS  

5  components  of  any  Computer  

Processor! !

Computer!

Control!(“brain”)!

Datapath!(“brawn”)!

Memory!!!(where !programs, !data !live when!running)!

Devices!

Input!

Output!

Keyboard, Mouse!

Display, Printer!

Disk (where !programs, !data !live when!not running)!

Hello World!

Page 14: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

14

Opening  up  a  computer  box  

•  Can  you  find  the  5  classic  components?  •  I/O  –  Mouse,  Keyboard,  Monitor,  Printer..  •  Memory    

–   ROM,  RAM,  DRAM,  Cache  –   Hard  disk,  FLASH  

•  Processor-­‐  Motherboard  – CPU  

HOW  DO  WE  COMMAND  A  CPU?    

Basic  job  of  a  CPU:  execute  lots  of  instruc5ons.    

Page 15: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

15

Instruc5ons  •  Language  of  the  Machine  

–  Arithme5c  such  as  add  and  subtract  –  Logic  instruc5ons  such  as  and,  or,  and  not  –  Data  instruc5ons  such  as  move,  load,  and  store  –  Control  flow  instruc5ons  such  as  goto,  if  ...  goto,  

•  More  restricted  -­‐  Different  CPUs  implement  different  sets  of  instruc5ons.      

•  The  set  of  instruc5ons  a  par5cular  CPU  implements  is  an  Instruc5on  Set  Architecture  (ISA).  –  Examples:  Intel  80x86  (Pen5um  4),  IBM/Motorola  PowerPC  (Macintosh),  MIPS  (  Nintendo,  Silicon  Graphics,  Sony),  Intel  IA64,  ...  

Instruc5on  Set  Architectures(1/2)  •  Describes  the  aspects  of  a  computer  architecture  visible  to  

a  programmer  –  The  na5ve  datatypes,  instruc5ons,  registers,  addressing  modes,  memory  architecture,    interrupt  and  excep5on  handling,  and  external  I/O  (if  any).    

•  ISA  is  dis5nguished  from  the  microarchitecture,  which  is  the  set  of  processor  design  techniques  used  to  implement  the  instruc5on  set.    –  Computers  with  different  microarchitecture  can  share  a  common  instruc5on  set.    

–  For  example,  the  Intel  Pen5um  and  the  AMD  Athlon  implement  nearly  iden5cal  versions  of  the  x86  instruc5on  set,  but  have  radically  different  internal  design  

Page 16: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

16

Instruc5on  Set  Architectures(2/2)  •  Early  trend  was  to  add  more  instruc5ons  to  new  CPUs  to  do  

elaborate  opera5ons  –  VAX  architecture  had  an  instruc5on  to  mul5ply  polynomials!  –  Complex  Instruc5on  Set  Compu5ng  (CISC)  

•  RISC  philosophy  (Cocke  IBM,  Pajerson,  Hennessy,  1980s)    –  Reduced  Instruc5on  Set  Compu5ng  (RISC)  –  Keep  the  instruc5on  set  small  and  simple,  makes  it  easier  to  build  fast  hardware.  

–  Let  soAware  do  complicated  opera5ons  by  composing  simpler  ones.  

–  Simpler  is  Faster!  

MIPS  Architecture  •  MIPS  –  semiconductor  company  that  built  one  of  

the  first  commercial  RISC  architectures  •  Nintendo  64,  playsta5on,  PL2,  PSP,  HP  printers,  

Cisco  routers,  use  MIPS  processors.    •  Why  MIPS  instead  of  Intel  80x86?  

–  MIPS  is  simple,  elegant.    Don’t  want  to  get  bogged  down  in  grijy  details.  

–  MIPS  widely  used  in  embedded  apps,  x86  lijle  used  in  embedded,  and  more  embedded  computers  than  PCs  

–  By  the  late  1990s  it  was  es5mated  that  one  in  three  RISC  chips  produced  were  MIPS-­‐based  designs.    

Page 17: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

17

MIPS  Programming  and  Emula5on  

•  MIPS  assembly  language  =  MIPS  instruc5ons  •  A  freely  available  "MIPS  R2000/R3000  Simulator"  called  

SPIM    –  UNIX  or  GNU/Linux;  Mac  OS  X;  MS  Windows  95,  98,  NT,  2000,  XP;  and  DOS)    

•  Good  for  learning  MIPS  assembly  language  programming  and  the  general  concepts  of  RISC-­‐assembly  language  programming  

•  Informa5on  –  PLEASE  READ!  hjp://www.cs.wisc.edu/~larus/spim.html  –  We  will  be  using  PCSPIM  to  do  projects  

Page 18: CS64 Computer Organization - Computer Science | …htzheng/teach/cs64s11/pdf/lecture1.pdf · CS64 Computer Organization Lecture 1 ... programming$ Digital$logic$ ... • Nintendo$64,$playstaon,$PL2,$PSP,$HP$printers,$

18

TODO:  Tutorial  on  PCSPIM  

 •  Read  hjp://www.cs.wisc.edu/~larus/spim.html  •  Especially  hjp://www.cs.wisc.edu/~larus/PCSpim.pdf  

•  Highly  recommended  –  tutorial  videos  – h5p://users.ece.gatech.edu/~sudha/2030/temp/spim/spim-­‐tutorial.html  

•  Install  and  Get  to  know  PCSPIM  

PCSPIM