Instruction Cycle

  • A program residing in the memory unit of the computer consists of a sequence of instructions. The program is executed in the computer by going through a cycle for each instruction. Each instruction cycle in turn is subdivided into a sequence of subcycles or phases. In the basic computer each instruction cycle consists of the following phases:


  • 1. Fetch an instruction from memory.
    2. Decode the instruction.
    3. Read the effective address from memory if the instruction has an indirect
    address.
    4. Execute the instruction.

  • Upon the completion of step 4, the control goes back to step 1 to fetch, decode, and execute the next instruction. This process continues indefinitely unless a HALT instruction is encountered.


  • Fetch and Decode


    1. Initially, the program counter PC is loaded with the address of the first instruction in the program.


    2. The sequence counter SC is cleared to 0, providing a decoded timing signal T0. After each clock pulse, SC is incremented by one, so that the timing signals go through a sequence T0, T1, T2, and so on.


    3. The micro operations for the fetch and decode phases can be specified by the following register transfer statements.


    4. T0: AR ← PC
      T1: IR ← M[AR], PC ← PC + 1
      T2: D0, .... , D7 ← Decode IR(12-14), AR ← IR(0-11), I ← IR(15)
      

    5. Since only AR is connected to the address inputs of memory, it is necessary to transfer the address from PC to AR during the clock transition associated with timing signal T0. The instruction read from memory is then placed in the instruction register IR with the clock transition associated with timing signal T1.


    6. computer-design


    7. At the same time, PC is incremented by one to prepare it for the address of the next instruction in the program. At time T2, the operation code in IR is decoded, the indirect bit is transferred to flip-flop I, and the address part of the instruction is transferred to AR .


    8. Note that SC is incremented after each clock pulse to produce the sequence T0, T1, and T2


    9. Figure above shows how the first two register transfer statements are implemented in the bus system.


    10. To provide the data path for the transfer of PC to AR we must apply timing signal T0 to achieve the following connection:


    11. 1. Place the content of PC onto the bus by making the bus selection inputs
      S2S1S0 equal to 010.
      
      2. Transfer the content of the bus to AR by enabling the LD input of AR .
      

    12. The next clock transition initiates the transfer from PC to AR since T0 = 1. In order to implement the second statement : T1: IR ← M[AR], PC ← PC + 1 it is necessary to use timing signal T1 to provide the following connections in the bus system.


    13. 1. Enable the read input of memory.
      2. Place the content of memory onto the bus by making S2S1S0 = 111.
      3. Transfer the content of the bus to IR by enabling the LD input of IR.
      4. Increment PC by enabling the INR input of PC.
      

    14. The next clock transition initiates the read and increment operations since T1 = 1.


    15. Figure above duplicates a portion of the bus system and shows how T0 and T1 are connected to the control inputs of the registers, the memory, and the bus selection inputs. Multiple input OR gates are included in the diagram because there are other control functions that will initiate similar operations.




Determine the Type of Instruction



  • The timing signal that is active after the decoding is T3. During time T3, the control unit determines the type of instruction that was just read from memory.


  • The flowchart of Fig. below presents an initial configuration for the instruction cycle and shows how the control determines the instruction type after the decoding.


  • The three possible instruction types available in the basic computer are specified in Fig. on basic computer formats.


  • computer-design
  • Decoder output D7 is equal to 1 if the operation code is equal to binary 111. From Fig. on basic computer formats we determine that if D7 = 1, the instruction must be a


  • computer-designregister-reference or input-output type.


  • If D7 = 0, the operation code must be one of the other seven values 000 through 110, specifying a memory-reference instruction.


  • Control then inspects the value of the first bit of the instruction, which is now available in flip-flop I. If D7 = 0 and I = 1, we have a memory reference instruction with an indirect address.


  • It is then necessary to read the effective address from memory. The microoperation for the indirect address condition can be symbolized by the register transfer statement : AR ← M[AR]


  • Initially, AR holds the address part of the instruction. This address is used during the memory read operation. The word at the address given by AR is read from memory and placed on the common bus. The LD input of AR is then enabled to receive the indirect address that resided in the 12 least significant bits of the memory word.


  • The three instruction types are subdivided into four separate paths. The selected operation is activated with the clock transition associated with timing signal T3. This can be symbolized as follows:


  • D'7 IT3: AR ← M[AR]
    D'7 I'T3: Nothing
    D7 I'T3: Execute a register-reference instruction
    D7IT3: Execute an input-output instruction
    

  • When a memory-reference instruction with I = 0 is encountered, it is not necessary to do anything since the effective address is already in AR.


  • However, the sequence counter SC must be incremented when D'7T3 = 1, so that the execution of the memory-reference instruction can be continued with timing variable T4


  • A register-reference or input-output instruction can be executed with the clock associated with timing signal T3. After the instruction is executed, SC is cleared to 0 and control returns to the fetch phase with T0 = 1.


  • Note that the sequence counter SC is either incremented or cleared to 0 with every positive clock transition. We will adopt the convention that if SC is incremented, we will not write the statement SC ← SC + 1, but it will be implied that the control goes to the next timing signal in sequence. When SC is to be cleared, we will include the statement SC ← 0.


  • The register transfers needed for the execution of the register-reference instructions are presented in this section.




Register-Reference Instructions



  • Register-reference instructions are recognized by the control when D7 = 1 and I = 0.


  • These instructions use bits 0 through 11 of the instruction code to specify one of 12 instructions.


  • These 12 bits are available in IR(0-11). They were also transferred to AR during time T2.


  • The control functions and microoperations for the register-reference instructions are. listed in Table below. These instructions are executed with the clock transition associated with timing variable T3.


  • Each control function needs the Boolean relation D7I'T3, which we designate for convenience by the symbol r.


  • The control function is distinguished by one of the bits in IR(0-11). By assigning the symbol Bi to bit i of IR, all control functions can be simply denoted by rBi.


  • For example, the instruction CLA has the hexadecimal code 7800, which gives the binary equivalent 0111 1000 0000 0000. The first bit is a zero and is equivalent to I'.


  • The next three bits constitute the operation code and are recognized from decoder output D7. Bit 11 in IR is I and is recognized from B11. The control function that initiates the microoperation for this instruction is D7I'T3B11 = rB11.


  • The execution of a register-reference instruction is completed at time T3.


  • The sequence counter SC is cleared to 0 and the control goes back to fetch the next instruction with timing signal T0.


  • The first seven register-reference instructions perform clear, complement, circular shift, and increment microoperations on the AC or E registers.


  • The next four instructions cause a skip of the next instruction in sequence when a stated condition is satisfied. The skipping of the instruction is achieved by incrementing PC once again (in addition, it is being incremented during the fetch phase at time T1).


  • The condition control statements must be recognized as part of the control conditions .


  • The AC is positive when the sign bit in AC(15) = 0; it is negative when AC(15) = 1. The content of AC is zero (AC = 0) if all the flip-flops of the register are zero. The HLT instruction clears a start-stop flip-flop S and stops the sequence counter from counting. To restore the operation of the computer, the start-stop flip-flop must be set manually.


  • computer-design

Memory-Reference Instructions



  • In order to specify the rnicrooperations needed for the execution of each instruction, it is necessary that the function that they are intended to perform be defined precisely.


  • We will now show that the function of the memory-reference instructions can be defined precisely by means of register transfer notation.


  • Table below lists the seven memory-reference instructions. The decoded output Di for i = 0, 1, 2, 3, 4, 5, and 6 from the operation decoder that belongs to each instruction is included in the table.


  • The effective address of the instruction is in the address register AR and was placed there during timing signal T2 when I = 0, or during timing signal T3 when I = 1.


  • The execution of the memory-reference instructions starts with timing signal T4. The symbolic description of each instruction is specified in the table in terms of register transfer notation.


  • The actual execution of the instruction in the bus system will require a sequence of microoperations.


  • This is because data stored in memory cannot be processed directly.


  • The data must be read from memory to a register where they can be operated on with logic circuits.


  • We now explain the operation of each instruction and list the control functions and microoperations needed for their execution.


  • computer-design




AND to AC



  • This is an instruction that performs the AND logic operation on pairs of bits in AC and the memory word specified by the effective address.


  • The result of the operation is transferred to AC. The microoperations that execute this instruction are:
    D0T4: DR ← M[AR]
    D0T5: AC ← AC ∧ DR, SC ← 0


  • The control function for this instruction uses the operation decoder D0 since this output of the decoder is active when the instruction has an AND operation whose binary code value is 000. Two timing signals are needed to execute the instruction.


  • The clock transition associated with timing signal T4 transfers the operand from memory into DR.


  • The clock transition associated with the next timing signal T5 transfers to AC the result of the AND logic operation between the contents of DR and AC.


  • The same clock transition clears SC to 0, transferring control to timing signal T0 to start a new instruction cycle.




ADD to AC



  • This instruction adds the content of the memory word specified by the effective address to the value of AC.


  • The sum is transferred into AC and the output carry Cout is transferred to the E (extended accumulator) flip-flop.


  • The microoperations needed to execute this instruction are
    D1T4: DR ← M[AR]
    D1T5: AC ← AC + DR, E ← Cout, SC ← 0


  • The same two timing signals, T4 and T5, are used again but with operation decoder D1 instead of D0, which was used for the AND instruction.


  • After the instruction is fetched from memory and decoded, only one output of the operation decoder will be active, and that output determines the sequence of rnicrooperations that the control follows during the execution of a memory-reference instruction.




LDA: Load to AC



  • This instruction transfers the memory word specified by the effective address to AC.


  • The microoperations needed to execute this instruction are
    D2T4: DR ← M [AR]
    D2T5: AC ← DR, SC ← 0


  • Note that there is no direct path from the bus into AC (see figure under Common Bus System).


  • The adder and logic circuit receive information from DR which can be transferred into AC.


  • Therefore, it is necessary to read the memory word into DR first and then transfer the content of DR into AC.


  • The reason for not connecting the bus to the inputs of AC is the delay encountered in the adder and logic circuit.


  • It is assumed that the time it takes to read from memory and transfer the word through the bus as well as the adder and logic circuit is more than the time of one clock cycle.


  • By not connecting the bus to the inputs of AC we can maintain one clock cycle per rnicrooperation.




STA: Store AC



  • This instruction stores the content of AC into the memory word specified by the effective address. Since the output of AC is applied to the bus and the data input of memory is connected to the bus, we can execute this instruction with one microoperation:
    D3T4: M [AR] ← AC, SC ← 0



Comments