Question: Machine Operation time through C Programming Language ? Assume you are running the code on a microprocessor with five internal units, having no pipeline or

Machine Operation time through C Programming Language ?

Assume you are running the code on a microprocessor with five internal units, having no pipeline or cache capabilities. Different instructions require particular units to operate. Unit operating times are given in the following table

Operation Memory Access

Units

Operating time

Instruction Fetch(IF)

1600 ns

Instruction Decode (ID)

200 ns

Operand Fetch (OF)

1600 ns

Operation Execution (OE)

200 ns

Operant store (OS)

1600 ns

Operation Cache Access

Units

Operating time

Instruction Fetch(IF)

200 ns

Instruction Decode (ID)

200 ns

Operand Fetch (OF)

200 ns

Operation Execution (OE)

200 ns

Operant store (OS)

200 ns

Unit Description:

Instruction Fetch Unit (IF): Reads the next instruction from memory.

Instruction Decode Unit (ID): Figure out what the instruction says to do. In other words, ID unit translates the opcode into the control signals.

Operand Fetch Unit (OF): Gets the values that the ALU needs to work on.

operands: an operand is the part of a computer instruction that specifies data that is to be operating on or manipulated.

Operation Execution Unit (OE): perform ALU operation, decide if jump/branch should be taken

Operant Store Unit (OS): Store the results back into the memory.

Task:

Compute the overall operating time of the given code. That means for each instruction in code, add the following blocks and replace the 0 with proper values from the above tables when applicable. Some instructions may not use a particular unit, and some may require more than one unit. Adjust the calculation of opTime accordingly. Keep in mind that the first time an instruction or data that is not in cache - is being accessed, the operation time is main memory + cache access. Make sure you calculate the timings with the assumption of CPU having 2-way interleaving pipeline. Also, you should be careful that some instructions might have conflicts.

// Explain your answers here

opTime += 0; // IF unit

opTime += 0; // ID unit

opTime += 0; // OF unit

opTime += 0; // OE unit

opTime += 0; // OS unit

**Below is the code**

#include "stdio.h" int main(void) { /* Unless otherwise indicated, all statments in the code REQUIRE incrementation of the opTime variable. The amount of time that an internal unit uses during operation is given in the pdf. There are five internal units, and different instructions require particular units to operate. opTime += 0; // IF (Instruction Fetch) unit opTime += 0; // ID (Instruction Decode) unit opTime += 0; // OF (Operand Fetch) unit opTime += 0; // OE (Operation Execution) unit opTime += 0; // OS (Operant Store) unit Keep in mind that the first time an instruction or data - that is not in cache - is being accessed, the operation time is main memory (read from memory) + cache access (save in the cache). Also, assume the cache is unlimited, thus, no saving to the main memory is required. For the purpose of this assignment, treat numbers as non-operand (constants). */ // To keep track of runtime // DO NOT include in opTime calculation! float opTime = 0.0; //An arbitrary number for use as a condition in second 'for' loop int n = 1000; //some float variables that represent registers and memory locations float x = 1; float y = 1; float z = 1; float t = 0; float k = 1; float m = 0; // Iterator declaration; In C, declaring 'i' must be done before initializing a 'for' loop // DO NOT include in opTime calculation! int i; // Assume 'for' loop instruction is read only one time, but it checks and incremants i 100 times! // Each command requires incrementing opTime variable relative to what it does. for( i = 0 ; i<100; i++) { // Hint: Watch out for the pipeline conflict when calculate timing x = y + z; y = x; z = y + i; if ( z == y) m = 1; } printf(" x = %f y = %f z = %f t = %f k = %f Operating time 01 = %f ns ", x,y,z,t,k, opTime); //re-initializing registers and memory locations x = 1; y = 0; z = 0; t = 0; k = 0; // Assume for instruction is read only onetime, but it checks and incremants i for 1000 times! n is initialized before. for( i = 0; i < n ; i++) { // Hint: Watch out for the pipeline conflict when calculate timing y = t + 1; k = y + 5; t = t + i; } printf(" x = %f y = %f z = %f t = %f k = %f Total operating time = %f ns ", x,y,z,t,k, opTime); // Do not include in opTime calculation! return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!