co200 – computer organization and architecture · m. morris mano. computer system architecture....

43
CO200 – Computer Organization and Architecture Basavaraj Talawar, CSE, NITK http://bt.nitk.ac.in/c/18b/co200/index.html

Upload: others

Post on 11-Aug-2021

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

CO200 – Computer Organization and Architecture

Basavaraj Talawar, CSE, NITK

http://bt.nitk.ac.in/c/18b/co200/index.html

Page 2: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

Learning from the Course

● How does the hardware execute our program?– What goes on ‘under the hood’ during program

execution?

Page 3: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

Learning from the Course

● How does the hardware execute our program?– What goes on ‘under the hood’ during program

execution?

● Which components of the system are ‘at work’?– Design of these components

Page 4: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What does the hardware see?

int main() { int i, a=2, b=3, sum=0; sum = a + b;}

int main() { int i, a=2, b=3, sum=0; sum = a + b;}

This is what the Programmer sees.

This is what the Programmer sees.

Page 5: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What does the hardware see?

int main() { int i, a=2, b=3, sum=0; sum = a + b;}

int main() { int i, a=2, b=3, sum=0; sum = a + b;}

CompilerCompiler

This is what the Programmer sees.

This is what the Programmer sees.

Page 6: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What does the hardware see?

int main() { int i, a=2, b=3, sum=0; sum = a + b;}

int main() { int i, a=2, b=3, sum=0; sum = a + b;}

This is what the Programmer sees.

This is what the Programmer sees.

Binary CodeBinary Code

CompilerCompiler

This is what the Machine sees.

This is what the Machine sees.

Page 7: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What does the hardware see?

● What does the binary code (a.out) contain?

● What happens when do$ ./a.out

● What does the binary code (a.out) contain?

● What happens when do$ ./a.out

Binary CodeBinary Code

Page 8: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

The Program

int main() { int a=2, b=3, sum=0; sum = a + b;}

int main() { int a=2, b=3, sum=0; sum = a + b;}

Start here!Start here!

Page 9: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

The Program

Allocate space in memory for these data!

Allocate space in memory for these data!

int main() { int a=2, b=3, sum=0; sum = a + b;}

int main() { int a=2, b=3, sum=0; sum = a + b;}

Page 10: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

The Program

int main() { int a=2, b=3, sum=0; sum = a + b;}

int main() { int a=2, b=3, sum=0; sum = a + b;}

Add a and b and store the result in c.

Add a and b and store the result in c.

Page 11: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

The Program

int main() { int a=2, b=3, sum=0; sum = a + b;}

int main() { int a=2, b=3, sum=0; sum = a + b;} Exit the program!Exit the program!

Page 12: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What goes on under the hood?

int main() { int a=2, b=3, sum=0; sum = a + b;}

int main() { int a=2, b=3, sum=0; sum = a + b;}

Add a and b and store the result in c.

Add a and b and store the result in c.

sum = a + b;sum = a + b;

Page 13: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What goes on under the hood?

int main() { int a=2, b=3, sum=0; sum = a + b;}

int main() { int a=2, b=3, sum=0; sum = a + b;}

Add a and b and store the result in c.

Add a and b and store the result in c.

PROCESSOR MEMORY

Programs andData reside hereAll the work is

done here

sum = a + b;sum = a + b;

Page 14: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What goes on under the hood?

int main() { int a=2, b=3, sum=0; sum = a + b;}

int main() { int a=2, b=3, sum=0; sum = a + b;}

Add a and b and store the result in c.

Add a and b and store the result in c.

PROCESSORPROCESSOR MEMORYMEMORY

sum = a + b;sum = a + b;

aa bb cc

Page 15: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What goes on under the hood?

int main() { int a=2, b=3, sum=0; sum = a + b;}

int main() { int a=2, b=3, sum=0; sum = a + b;}

Add a and b and store the result in c.

Add a and b and store the result in c.

PROCESSORPROCESSOR

MEMORYMEMORY

sum = a + b;sum = a + b;

aa bb ccALUALU

00

Page 16: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What goes on under the hood?

int main() { int a=2, b=3, sum=0; sum = a + b;}

int main() { int a=2, b=3, sum=0; sum = a + b;}

Add a and b and store the result in c.

Add a and b and store the result in c.

PROCESSORPROCESSOR

MEMORYMEMORY

sum = a + b;sum = a + b;

aa bb ccALUALU aa bb

11

Load a, bLoad a, b

Page 17: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What goes on under the hood?

int main() { int a=2, b=3, sum=0; sum = a + b;}

int main() { int a=2, b=3, sum=0; sum = a + b;}

Add a and b and store the result in c.

Add a and b and store the result in c.

PROCESSORPROCESSOR

MEMORYMEMORY

sum = a + b;sum = a + b;

aa bb ccALUALU

aa bb

11

Page 18: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What goes on under the hood?

int main() { int a=2, b=3, sum=0; sum = a + b;}

int main() { int a=2, b=3, sum=0; sum = a + b;}

Add a and b and store the result in c.

Add a and b and store the result in c.

PROCESSORPROCESSOR

MEMORYMEMORY

sum = a + b;sum = a + b;

aa bb ccALUALU

aa bb

aa bb

Feed a, b to ALU

Feed a, b to ALU

22

Page 19: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What goes on under the hood?

int main() { int a=2, b=3, sum=0; sum = a + b;}

int main() { int a=2, b=3, sum=0; sum = a + b;}

Add a and b and store the result in c.

Add a and b and store the result in c.

PROCESSORPROCESSOR

MEMORYMEMORY

sum = a + b;sum = a + b;

aa bb ccALUALU

aa bb

aa bb

Addition in ALU

Addition in ALU

22 ++

Page 20: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What goes on under the hood?

int main() { int a=2, b=3, sum=0; sum = a + b;}

int main() { int a=2, b=3, sum=0; sum = a + b;}

Add a and b and store the result in c.

Add a and b and store the result in c.

PROCESSORPROCESSOR

MEMORYMEMORY

sum = a + b;sum = a + b;

aa bb ccALUALU

aa bb a+ba+b

aa bb22

Add a, b.Write a+b.

Add a, b.Write a+b.

Page 21: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What goes on under the hood?

int main() { int a=2, b=3, sum=0; sum = a + b;}

int main() { int a=2, b=3, sum=0; sum = a + b;}

Add a and b and store the result in c.

Add a and b and store the result in c.

PROCESSORPROCESSOR

MEMORYMEMORY

sum = a + b;sum = a + b;

aa bb a+ba+bALUALU

aa bb a+ba+b

a+ba+b33

Store a+b in memory in ‘c’

Store a+b in memory in ‘c’

Page 22: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What goes on under the hood?

int main() { int a=2, b=3, sum=0; sum = a + b;}

int main() { int a=2, b=3, sum=0; sum = a + b;}

Add a and b and store the result in c.

Add a and b and store the result in c.

sum = a + b;sum = a + b;

● Variables – memory locations● Load the values from memory into the processor● Feed the inputs to the ALU● Arithmetic operation in the ALU – Addition● Save the sum in the processor● Store the calculated sum from the processor to the memory

● Variables – memory locations● Load the values from memory into the processor● Feed the inputs to the ALU● Arithmetic operation in the ALU – Addition● Save the sum in the processor● Store the calculated sum from the processor to the memory

Page 23: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

A Bigger Program

int calculate_sum(int a[], int i) { int sum=0; i=0; for(i=0;i<5;i++)   sum = sum + a[i];return sum;}

int main() { int i, a[5]={2,3,5,7,11}, sum=0; sum=calculate_sum(a, 5);}

int calculate_sum(int a[], int i) { int sum=0; i=0; for(i=0;i<5;i++)   sum = sum + a[i];return sum;}

int main() { int i, a[5]={2,3,5,7,11}, sum=0; sum=calculate_sum(a, 5);}

Page 24: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

A Bigger Program

int calculate_sum(int a[], int i) { int sum=0; i=0; for(i=0;i<5;i++)   sum = sum + a[i];return sum;}

int main() { int i, a[5]={2,3,5,7,11}, sum=0; sum=calculate_sum(a, 5);}

int calculate_sum(int a[], int i) { int sum=0; i=0; for(i=0;i<5;i++)   sum = sum + a[i];return sum;}

int main() { int i, a[5]={2,3,5,7,11}, sum=0; sum=calculate_sum(a, 5);}

● Condition evaluation

● Function call and return

● Parameters pass and

return

● Condition evaluation

● Function call and return

● Parameters pass and

return

Page 25: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

An Even Bigger Program !

int calculate_sum(int a[], int i) { int sum=0; i=0; for(i=0;i<5;i++)   sum = sum + a[i];return sum;}

int main() { int i, a[5]={2,3,5,7,11}, sum=0; sum=calculate_sum(a, 5); printf(“the sum: %d.”, sum);}

int calculate_sum(int a[], int i) { int sum=0; i=0; for(i=0;i<5;i++)   sum = sum + a[i];return sum;}

int main() { int i, a[5]={2,3,5,7,11}, sum=0; sum=calculate_sum(a, 5); printf(“the sum: %d.”, sum);}

Page 26: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

An Even Bigger Program !

int calculate_sum(int a[], int i) { int sum=0; i=0; for(i=0;i<5;i++)   sum = sum + a[i];return sum;}

int main() { int i, a[5]={2,3,5,7,11}, sum=0; sum=calculate_sum(a, 5); printf(“the sum: %d.”, sum);}

int calculate_sum(int a[], int i) { int sum=0; i=0; for(i=0;i<5;i++)   sum = sum + a[i];return sum;}

int main() { int i, a[5]={2,3,5,7,11}, sum=0; sum=calculate_sum(a, 5); printf(“the sum: %d.”, sum);}

● I/O operation !● I/O operation !

Page 27: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

Computer Organization and Architecture – This Course

InstructionsInstructions

The Binary Program(a.out)

The Binary Program(a.out)

DataData

Function CallsFunction Calls

Binary Code

I/O OperationsI/O Operations

Page 28: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

Computer Organization and Architecture – This Course

InstructionsInstructions

The Binary Program(a.out)

The Binary Program(a.out)

ALU DesignALU Design

DataData Datapath DesignDatapath Design

Memory HierarchyMemory Hierarchy

Function CallsFunction Calls Control Unit DesignControl Unit Design

Hardware UnitsBinary Code

I/O OperationsI/O Operations

Page 29: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

Course Details

● Assignments (~4)– RISC-V Assembly language programming

– Hardware design - Build components in HDL

● Tutorials (8 – 10)– Solve problems in class; Teams of 2; Every week.

● Midterm and Final Exam● Class slides will be on the course website

Page 30: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

Course Reference Texts● David A Patterson and John L Hennessy. Computer Organization

and Design – The Hardware/Software Interface. RISC-V Edition, Morgan Kaufmann. 2018.

● M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007.● Hamacher, Vranesic, Zaky. Computer Organization, 5e. Tata McGraw

Hill, 2011.● John P Hayes. Computer Architecture and Organization, 3e. McGraw

Hill, 1998.● David Harris and Sarah Harris. Digital Design and Computer

Architecture. 2e. MK. 2013.● NPTEL Courses (www.nptel.co.in)

– Matthew Jacob – High Performance Computing, Bhaskaran Raman – Computer Organisation and Architecture, S. Raman – Computer Organization, Jatindra Kumar Deka – Computer Organisation and Architecture.

Page 31: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

Extra Slides

Page 32: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

The Program

● Variables – memory locations● Load the values from memory● Arithmetic operation – Addition● Store the sum into memory

● Variables – memory locations● Load the values from memory● Arithmetic operation – Addition● Store the sum into memory

int main() { int a=2, b=3, sum=0; sum = a + b;}

int main() { int a=2, b=3, sum=0; sum = a + b;}

Page 33: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

● Variables – memory locations● Load the values from memory● Store the sum into memory● Arithmetic operation – Addition● Condition evaluation

● Variables – memory locations● Load the values from memory● Store the sum into memory● Arithmetic operation – Addition● Condition evaluation

int main() { int i, a[5]={2,3,5,7,11}, sum=0; for(i=0;i<5;i++)   sum = sum + a[i];}

int main() { int i, a[5]={2,3,5,7,11}, sum=0; for(i=0;i<5;i++)   sum = sum + a[i];}

Page 34: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

A Bigger Program

● Variables – memory locations

● Load the values from memory

● Store the sum into memory

● Arithmetic operation – Addition

● Condition evaluation

● Function call, return,

parameters pass and return

● Variables – memory locations

● Load the values from memory

● Store the sum into memory

● Arithmetic operation – Addition

● Condition evaluation

● Function call, return,

parameters pass and return

int calculate_sum(int a[], int i) { int sum=0; i=0; for(i=0;i<5;i++)   sum = sum + a[i];return sum;}

int main() { int i, a[5]={2,3,5,7,11}, sum=0; sum=calculate_sum(a, 5);}

int calculate_sum(int a[], int i) { int sum=0; i=0; for(i=0;i<5;i++)   sum = sum + a[i];return sum;}

int main() { int i, a[5]={2,3,5,7,11}, sum=0; sum=calculate_sum(a, 5);}

Page 35: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What do we learn in this course?

● What does a computer do?

X = 10; Y = 20;

X = 20; Y = 10;

Page 36: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

The Binary Code

● Code for tasks to perform.– Program

● Hardware ‘interprets’ the code– Decode

● Hardware ‘accomplishes the task’– Execute

Page 37: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

The Processor

● The processor decodes and executes the binary code

● Where does the code reside?

PROCESSOR MEMORY

Storesprograms

Decodes,Executes

Instructions

Page 38: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

The Computer System

PROCESSOR MEMORY

Hard Drive

Page 39: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

The Computer System

PROCESSOR MEMORY

I/O Devices

Interconnect

I/O DevicesI/O Devices

Page 40: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

InstructionsInstructions

The Binary Program(a.out)

The Binary Program(a.out)

ALU DesignALU Design

DataData Datapath DesignDatapath Design

Memory HierarchyMemory Hierarchy

Function CallsFunction Calls Control Unit DesignControl Unit Design

Hardware UnitsBinary Code

Computer Organization and Architecture – Not in this Course

PipeliningPipelining I/O ProcessingI/O Processing Parallel ProcessingParallel Processing

Page 41: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

What do we learn in this course?

● What does a computer do?

v[k] = 10; v[k+1] = 20;

v[k] = 20; v[k+1] = 10;

C Program Binary Code Execution

Compiler Hardware

Page 42: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

return of the Binary Code

● Program– Instructions and Data

● Instructions– Arithmetic, Logic, Memory transfer, and others.

● Data– Characters, Integers, Floating point numbers, etc.

Page 43: CO200 – Computer Organization and Architecture · M. Morris Mano. Computer System Architecture. 3e. Pearson, 2007. ... Organisation and Architecture, S. Raman – Computer Organization,

This Course

PROCESSOR MEMORY

I/O Devices

Interconnect

I/O DevicesI/O Devices

Program Layout(Instructions and Data)How are bits stored?

Decode, Execute

Input and OutputDevices, Communication

A whole lot more !!!