Header

Saturday 7 September 2013

IGNOU BCA 2nd sem Solved Assignment - What is the use of pipelining in a processor? Explain with the help of an example. Draw the diagram and explain a four stage instruction pipeline which has the following cycles:

What is the use of pipelining in a processor? Explain with the help  of an example. Draw the diagram and explain a four stage instruction pipeline which has the following cycles:
Ans

The pipeline itself comprises a whole task that has been broken out into smaller sub-tasks. The concept actually has its roots in mass production manufacturing plants, such as Ford Motor Company. Henry Ford determined long ago that even though it took several hours to physically build a car, he could actually produce a car a minute if he broke out all of the steps required to put a car together into different physical stations on an assembly line. As such, one station was responsible for putting in the engine, another the tires, another the seats, and so on.
The lifecycle of an instruction
The basic action of any microprocessor as it moves through the instruction stream can be broken down into a series of four simple steps, which each instruction in the code stream goes through in order to be executed:

  1. Fetch the next instruction from
  1. the address stored in the program counter.
  1. the address stored in the program counter.
  1. Store that instruction in the instruction register and decode
  1. it, and increment the address in the program counter.
  1. Execute the instruction
  1. currently in the instruction register. If the instruction is not a branch
  1. instruction but an arithmetic instruction, send it to the proper ALU.
  1. currently in the instruction register. If the instruction is not a branch
  1. instruction but an arithmetic instruction, send it to the proper ALU.
b. Add the contents of the input registers.
  1. Fetch
  1.  Decode
  1. Execute
  1. Write (or "write-back")


a. Read the contents of the input registers.
4. Write the results of that instruction from the ALU back into the destination register.
In a modern processor, the four steps above get repeated over and over again until the program is finished executing. These are, in fact, the four stages in a classic RISC pipeline. (I'll define the term "pipeline" shortly; for now, just think of a pipeline as a series of stages that each instruction in the code stream must pass through when the code stream is being executed.) Here are the four stages in their abbreviated form, the form in which you'll most often see them:
Each of the above stages could be said to represent one phase in the "lifecycle" of an instruction. An instruction starts out in the fetch phase, moves to the decode phase, then to the execute phase, and finally to the write phase. Each phase takes a fixed, but by no means equal, amount of time. In most of the example processors with which we'll be working in this article, all four phases take an equal amount of time; this is not usually the case in real-world processors. In any case, if a simple example processor takes exactly 1 nanosecond to complete each stage, then the that processor can finish one instruction every 4 nanoseconds.
A pipelined example

Pipelining a processor means breaking down its instruction execution process?what I've been calling the instruction's "lifecycle"? into a series of discrete pipeline stages which can be completed in sequence by specialized hardware. Recall the way that we broke down the SUV assembly process into five discrete steps, with one dedicated crew assigned to complete each step, and you'll get the idea.

Because an instruction's lifecycle consists of four fairly distinct phases, we can start by breaking down the single-cycle processor's instruction execution process into a sequence of four discreet pipeline stages, where each pipeline stage corresponds to a phase in the standard instruction lifecycle:

Stage 1: Fetch the instruction from code storage.
Stage 2: Decode the instruction.
Stage 3: Execute the instruction.
Stage 4: Write the results of the instruction back to the register file.

Note that the number of pipeline stages is referred to as the pipeline depth. So our four-stage pipeline has a pipeline depth of four.


Write a program in 8086 assembly Language (with proper comments) to find if the two given strings of length 5 are reverse of each other. You may assume that both the strings are available in the memory. Make suitable assumptions, if any.
DATA SEGMENT
        STR1 DB "ENTER YOUR STRING HERE ->$"
        STR2 DB "YOUR STRING IS ->$"
        STR3 DB "LENGTH OF STRING IS(DIRECT) ->$"
        STR4 DB "LENGTH OF STRING IS(COUNT) ->$"
        INSTR1 DB 20 DUP("$")
        NEWLINE DB 10,13,"$"
        LN DB 5 DUP("$")
        N DB "$"
        S DB ?

DATA ENDS

CODE SEGMENT
        ASSUME DS:DATA,CS:CODE
START:

        MOV AX,DATA
        MOV DS,AX

        LEA SI,INSTR1

;GET STRING
        MOV AH,09H
        LEA DX,STR1
        INT 21H

        MOV AH,0AH
        MOV DX,SI
        INT 21H


        MOV AH,09H
        LEA DX,NEWLINE
        INT 21H

;PRINT THE STRING

        MOV AH,09H
        LEA DX,STR2
        INT 21H

        MOV AH,09H
        LEA DX,INSTR1+2
        INT 21H

        MOV AH,09H
        LEA DX,NEWLINE
        INT 21H

;PRINT LENGTH OF STRING (DIRECT)
        MOV AH,09H
        LEA DX,STR3
        INT 21H

        MOV BL,INSTR1+1

        ADD BL,30H
        MOV AH,02H
        MOV DL,BL
        INT 21H

        MOV AH,09H
        LEA DX,NEWLINE
        INT 21H


;PRINT LENGTH OF STRING ANOTHER WAY

        MOV AH,09H
        LEA DX,STR4
        INT 21H
       
        ADD SI,2
        MOV AX,00


     L2:CMP BYTE PTR[SI],"$"
        JE L1
        INC SI
        ADD AL,1
        JMP L2

     L1:SUB AL,1
        ADD AL,30H
                      
        MOV AH,02H
        MOV DL,AL
        INT 21H


        MOV AH,4CH
        INT 21H


CODE ENDS
END START

No comments:

Post a Comment