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

Post on 11-Aug-2021

13 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

CO200 – Computer Organization and Architecture

Basavaraj Talawar, CSE, NITK

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

Learning from the Course

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

execution?

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

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.

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.

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.

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

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!

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;}

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.

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!

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;

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;

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

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

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

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

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

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 ++

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.

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’

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

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);}

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

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);}

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 !

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

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

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

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.

Extra Slides

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;}

● 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];}

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);}

What do we learn in this course?

● What does a computer do?

X = 10; Y = 20;

X = 20; Y = 10;

The Binary Code

● Code for tasks to perform.– Program

● Hardware ‘interprets’ the code– Decode

● Hardware ‘accomplishes the task’– Execute

The Processor

● The processor decodes and executes the binary code

● Where does the code reside?

PROCESSOR MEMORY

Storesprograms

Decodes,Executes

Instructions

The Computer System

PROCESSOR MEMORY

Hard Drive

The Computer System

PROCESSOR MEMORY

I/O Devices

Interconnect

I/O DevicesI/O Devices

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

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

return of the Binary Code

● Program– Instructions and Data

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

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

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 !!!

top related