CO By Rakesh Roshan

14,393
-1

Published on

I am working as a Assistant Professor in ITS, Ghaziabad. This is very useful to U.P.Technical University,Uttrakhand Technical University students. Give feedback to friendly_rakesh2003@yahoo.co.in

Published in: Technology, Business
4 Comments
13 Likes
Statistics
Notes
No Downloads
Views
Total Views
14,393
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
0
Comments
4
Likes
13
Embeds 0
No embeds

No notes for slide

CO By Rakesh Roshan

  1. 1. Computer Organization UNIT 2 Prepared By Prof. Rakesh Roshan [email_address] n By RAKESH ROSHAN 09971640291
  2. 2. Hardwired and Micro Programmed (Control unit) By RAKESH ROSHAN 09971640291
  3. 3. Fundamental Concepts <ul><li>Key register in the processor is the IR. Suppose that each instruction comprises 4 bytes, and that it is stored in one memory word.To execute an instruction, the processor has to perform the following three steps: </li></ul><ul><li>Fetch the contents of the memory location pointed to by the PC. The contents of this location are interpreted as an instruction to be executed. Hence, they are loaded into the IR. Symbolically this can be written as </li></ul><ul><li>IR  [[PC]] </li></ul><ul><li>Assuming that the memory is byte addressable, increment the contents of the PC by 4, that is, PC  [PC] + 4 </li></ul><ul><li>Carry out the actions specified by the instruction in the IR. </li></ul><ul><li>In cases where an instruction occupies more than one word , step 1 and 2 must be </li></ul><ul><li>repeated as many times as necessary to fetch the complete instruction . These two </li></ul><ul><li>steps are usually referred to as the fetch phase; step 3 constitutes the execute phase. </li></ul>By RAKESH ROSHAN 09971640291
  4. 4. An organization in which the arithmetic and logic unit (ALU) and all the registers are interconnected via a single common bus. This bus is internal to the processor and should not be confused with the external bus that connects the processor to the memory and I/O devices. Single Bus Organization of the datapath inside the Processor Instruction Decoder and Control logic IR R0 R(n-1) TEMP PC MAR MDR Y Z Internal Processor Bus MUX ALU Address Line Data Lines Constant 4 Select Add Sub XOR Control Signals Carry in ALU Control Lines Figure 1 By RAKESH ROSHAN 09971640291
  5. 5. Register Transfer <ul><li>Suppose that we wish to transfer the contents of register R1 to Register R4. This can be accomplished </li></ul><ul><li>As follows: </li></ul><ul><li>Enable the output of register R1 by setting R1 out to 1. This places the contents of R1 on the </li></ul><ul><li>processor bus. </li></ul><ul><li>Enable the input of register R4 by setting R4in to 1. This loads data from the processor bus </li></ul><ul><li>into register R4. </li></ul><ul><li>All operation s and data transfers within the processor take place within time periods defined by the </li></ul><ul><li>Processor clock. </li></ul>Performing an arithmetic or logic Operation <ul><li>The ALU is a combinational circuit that has no internal storage. It performs arithmetic and logic operations on the two operands applied to its A and B inputs. In figure, one of the operands is the output of the multiplexer MUX and the other operand is obtained directly from the bus. The result produced by the ALU is stored temporarily in register Z. Therefore , a sequence of operations to add the contents of register R1 to those of register R2 and store the result in register R3 is </li></ul><ul><li>R1 out , Y in </li></ul><ul><li>R2 out , Select Y, Add , Z in </li></ul><ul><li>Z out , R3 in </li></ul><ul><li>The signals whose names are given in any step are activated for the duration of the clock cycle </li></ul><ul><li>corresponding to that step.All other signals are inactive. Hence </li></ul><ul><li>In Step 1, the output of register R1 and the input of register Y are enabled, causing the contents of </li></ul><ul><li>R1 to be transferred over the bus to Y. </li></ul><ul><li>In Step 2, the multiplexer’s Select signal is set to Select Y, causing the multiplexer to gate the </li></ul><ul><li>contents of register Y to input A of the ALU. At the same time, the contents of register R2 are gated </li></ul><ul><li>onto the bus and hence , to input B. The function performed by the ALU depends on the signals </li></ul><ul><li>applied to its control lines . In this case , the Add line set to 1 , causing the output of the ALU to be </li></ul><ul><li>the sum of the two numbers at inputs A and B. This sum is loaded into register Z because its input </li></ul><ul><li>control signal is activated. </li></ul>By RAKESH ROSHAN 09971640291
  6. 6. In step 3, the contents of register Z are transferred to the destination register, R3 . This last transfer cannot be carried out during step 2, because only one register output can be connected to the bus during any clock cycle. Fetching a Word From Memory To fetch a word of information from memory, the processor has to specify the address of the memory location where this information is stored and request a Read operation. This applies whether the information to be fetched represents an instruction in a program or an operand specifies by an instruction. The processor transfers the required address to the MAR, whose output is connected to the address lines of the memory bus. At the same time, the processor uses the control lines of the memory bus to indicate that a Read operation is needed. When the requested data are received from the memory they are stored in register MDR , from where they can be transferred to other registers in the processor. The connections for register MDR are shown in figure. It has four control signals: MDR in and MDR out control the connection to the internal bus, and MDR inE and MDR outE control the connection to the external bus. Memory-bus Data lines Internal Processor bus MDR X X X X MDR outE MDR out MDR inE MDR in Figure 2 By RAKESH ROSHAN 09971640291
  7. 7. Storing a word in Memory <ul><li>Writing a word into a memory location follows a similar procedure . The desired address is loaded into MAR. </li></ul><ul><li>Then, the data to be written are loaded into MDR, and a Write command is issued. Hence, executing the </li></ul><ul><li>Instruction MOVE R2,(R1) requires the following sequence: </li></ul><ul><li>R1 out ,MAR in </li></ul><ul><li>R2 out , MDR in , Write </li></ul><ul><li>MDR outE , WMFC </li></ul><ul><li>As in the case of read operation , the Write control signal causes the memory bus interface hardware to issue </li></ul><ul><li>a Write command on the memory bus.The processor remains in step 3 until the memory operation is completed </li></ul><ul><li>and an MFC(Memory Function Completed) response is received. </li></ul>Execution of a Complete Instruction <ul><li>Consider the instruction </li></ul><ul><li>Add (R3),R1 </li></ul><ul><li>Which adds the contents of a memory location pointed to by R3 to register R1. Executing this instruction requires the following actions: </li></ul><ul><li>Fetch the instruction. </li></ul><ul><li>Fetch the first operand (the contents of the memory location pointed to by R3). </li></ul><ul><li>Perform the addition. </li></ul><ul><li>Load the result into R1. </li></ul>By RAKESH ROSHAN 09971640291
  8. 8. Steps 1 through 3 constitute the instruction fetch phase, which is the same for all instructions. The instructions decoding circuit interprets the contents of the IR at the beginning of step 4. This enables the control circuitry to activate the control signals for steps 4 through 7, which constitutes the execution phase. The contents of register R3 are transferred to the MAR in step 4, and a memory read operation is initiated. Then the contents of R1 are transferred to register Y in step 5, to prepare for the addition operation. When the Read operation is completed, the memory operand is available in register MDR and the addition operation is performed in step 6. The contents of MDR are gated to the bus, and thus also to the B input of the ALU, and register Y is selected as the second input to the ALU by choosing SelectY. The sum is stored in register Z, then transferred to R1 in step 7 . The End signal causes a new instruction fetch cycle to begin by returning to step 1. Figure 3 By RAKESH ROSHAN 09971640291 Step Action 1 PC out , MAR in ,Read, Select4, Add, Z in 2 Z out , PC in , Y in , WMFC(Wait for memory function completed) 3 MDR out , IR in 4 R3 out , MAR in , Read 5 R1 out , Y in , WMFC 6 MDR out , SelectY, Add, Z in 7 Z out , R1 in , End
  9. 9. Multiple Bus Organization To reduce the number of steps needed, most commercial processors provide multiple internal paths that enable several transfers to take place in parallel . The figure depicts a three –bus structure used to connect the registers and the ALU of a processor. All general purpose registers are combined into a single block is called the register file. Buses A and B are used to transfer the source operands to the A and B inputs of the ALU, where an arithmetic or logic operation may be performed. The result is transferred to the destination over bus C. If needed the ALU may simply pass one of its two input operands unmodified to bus C. We will call the ALU control signals for such an operation R=A or R=B. A second feature is the introduction of the Incrementer unit , which is used to increment the PC by constant value. Using the incrementer eliminates the need to add constant value to the PC using the main ALU. The source for the constant at the ALU input multiplexer is still useful. Constant A B R Figure 4 By RAKESH ROSHAN 09971640291 Incrementer PC MAR MDR IR Instruction Decoder Register File MUX ALU Bus A Bus B Bus C Address Lines Memory bus Data lines
  10. 10. HARDWIRED CONTROL To execute instructions, the processor must have some means of generating the control signals needed in the proper sequence . Computer designers use a wide variety of techniques to solve this problem. The approaches used fall into one of two categories : hardwired control and micro programmed control. Control step counter Decoder/ encoder External inputs Condition codes Clock IR Control Signal CLK The control hardware shown can be viewed as a state machine that changes from one state to another in every clock cycle , depending on the contents of the instruction register, the condition codes and the external inputs. The outputs of the state machine are the control signals. The sequence of operations carried out by this machine is determined by the wiring of the logic elements, hence the name “hardwired”. A controller that uses this approach can operate at high speed. However, it has little flexibility and the complexity of the instruction set it can implement is limited. Control unit organization Figure 5 By RAKESH ROSHAN 09971640291
  11. 11. A Complete Processor This structure has an instruction unit that fetches instructions from an instruction cache or from the main memory when the desired instructions are not already in the cache . It has separate processing units to deal with integer data and floating-point data . A data cache is inserted between these units and the main memory. Using separate caches for instructions and data is common practices today. Other processors use a single cache that stores both data and instructions. The processor is connected to the system bus and hence, to the rest of the computer , by means of a bus interface. Although we have shown just one integer and one floating-point unit, a processor may include several units of each type to increase the potential for concurrent operations. The way in which multiple units can be organized to increase the rate of instruction execution. Figure 6 By RAKESH ROSHAN 09971640291 Instruction unit Integer unit Floating-Point unit Instruction Cache Data Cache Bus interface Main Memory Input/ Output Processor System Bus
  12. 12. Micro programmed Control <ul><li>The purpose of the control unit in a digital system is to initiate a series of sequential steps of operations. At any given time, some operations are to be initiated while others remain idle. </li></ul><ul><li>The control variables at any given time can be represented by a string of 1’s and 0’s called a control word. So the control words can be programmed to initiate the various components in the data processor. </li></ul><ul><li>A control unit whose binary control variables are stored in a memory is called a micro programmed control unit. </li></ul><ul><li>Each word in control memory is called a microinstruction. </li></ul><ul><li>A sequence of microinstructions constitute the micro program. </li></ul><ul><li>The control memory can be a ROM. </li></ul><ul><li>By reading the content of the word in ROM at a given address specified the micro operations for the data processor. </li></ul><ul><li>Dynamic microprogramming: A micro program to be loaded initially from the computer console or from magnetic disks. </li></ul><ul><li>Generation configuration of a micro programmed control </li></ul><ul><ul><li>Control address register: Specifies the address of the microinstruction. </li></ul></ul><ul><ul><li>Control data register: Holds the microinstruction read from memory. </li></ul></ul><ul><ul><li>The location of the next microinstruction is generated by the sequencer . The location may be the next one in sequence, or it may be located elsewhere in the control memory. Some bit of the present microinstruction are used to generate the address of the next microinstruction. </li></ul></ul>By RAKESH ROSHAN 09971640291
  13. 13. Basic Organization of Micro programmed control unit Starting address generator IR Clock Micro PC Control store CW <ul><li>A Control Word(CW) is a word whose individual bits represent the various control signals. Each of the control steps in the control sequence of an instruction define a unique combination of 1s and 0s in the CW. </li></ul><ul><li>The micro routines for all instructions in the instruction set of a computer are stored in a special memory called the control store. </li></ul><ul><li>A sequence of CWs corresponding to the control sequence of a machine instruction constitutes the micro routines for that instruction, and the individual control words in this micro routines are referred to as microinstructions. </li></ul><ul><li>To read the control words sequentially from the control store , a micro-Program Counter is used. Every time a new instruction is loaded into the IR, the output of the block labeled “starting address generator” is loaded into the micro-PC. The micro-PC is then automatically incremented by the clock , causing successive micro instructions to be read from the control store. </li></ul><ul><li>Hence the control signals are delivered to various parts of the processor in the correct sequence. </li></ul>Figure 7 By RAKESH ROSHAN 09971640291
  14. 14. Micro programmed Control: Advantages & Disadvantages <ul><li>Advantages </li></ul><ul><ul><li>Flexible and structured design </li></ul></ul><ul><ul><li>Testing sequences can be easily incorporated </li></ul></ul><ul><ul><li>Easy to document and debug </li></ul></ul><ul><li>Disadvantages </li></ul><ul><ul><li>Expensive especially for small designs </li></ul></ul><ul><ul><li>Slower than random logic </li></ul></ul>By RAKESH ROSHAN 09971640291
  15. 15. An Example of microinstructions Microinstructions The individual control words in this microroutine are referred to as microinstructions. A straight forward way to structure microinstructions is to assign one bit position to each control signal , as in table. However, this scheme has one serious drawback- assigning individual bits to each control signal result in long microinstructions because the number of required signals is usually large. Moreover, only a few bits are set to 1 in any given microinstruction, which means the available bit space is poorly used. Figure 8 By RAKESH ROSHAN 09971640291
  16. 16. Partial format for field-encoded microinstructions F1(4) F2(3) F3(3) F4(4) F5(2) F6(1) F7(1) F8(1) Grouping control signals into fields requires a little more hardware because decoder circuits must be used to decode the bit patterns of each field into individual control signals. The cost of this additional hardware is more than offset by the reduced number of bits in each microinstruction, which result in a smaller control store. Only 20 bits are needed to store the patterns for the 42 signals. Vertical and Horizontal Organization Highly encoded schemes that use compact codes to specify only a small number of control functions in each microinstruction are referred to as a vertical organization. On the other hand, the minimally encoded scheme , in which many resources can be controlled with a single microinstruction, is called a horizontal organization. The horizontal approach is useful when a higher operating speed is desired and when the machine instruction allows parallel use of resources. The vertical approach results is considerably slower operating speeds because more microinstructions are needed to perform the desired control functions'. Although fewer bits are required for each microinstruction, this does not imply that the total number of bits in the control store is smaller. Figure 9 By RAKESH ROSHAN 09971640291 0000:No transfer 0001:Pcout 0010:MDRout 0011:Zout 0100:R0out 0101:R1out 0110:R2out 0111:R3out 1010:TEMPout 1011:Offsetout 000:No transfer 001:Pcin 010:IRin 011:Zin 100:R0in 101:R1in 110:R2in 111:R3in 000:No transfer 001:MARin 010:MDRin 011:TEMPin 100:Yin 0000:Add 0001:Sub . . . . . . . . 1111:XOR 00:No transfer 01:Read 10:Write 0:SelectY 1:Select4 0:No action 1:WMFC 0:Continue 1:End
  17. 17. Microprogram Sequencing <ul><li>If all microprograms require only straightforward sequential execution of microinstructions except for branches, letting a μ PC governs the sequencing would be efficient. </li></ul><ul><li>However, two disadvantages: </li></ul><ul><li>Having a separate microroutine for each machine instruction results in a large total number of microinstructions and a large control store. </li></ul><ul><li>Longer execution time because it takes more time to carry out the required branches. </li></ul><ul><li>Example: Add src, Rdst </li></ul><ul><li>Four addressing modes: register, autoincrement, autodecrement, and indexed (with indirect forms). </li></ul>By RAKESH ROSHAN 09971640291
  18. 18. - Bit-ORing - Wide-Branch Addressing - WMFC By RAKESH ROSHAN 09971640291
  19. 19. Microinstructions with Next-Address Field <ul><li>The microprogram we discussed requires several branch microinstructions, which perform no useful operation in the datapath. </li></ul><ul><li>A powerful alternative approach is to include an address field as a part of every microinstruction to indicate the location of the next microinstruction to be fetched. </li></ul><ul><li>Pros: separate branch microinstructions are virtually eliminated; few limitations in assigning addresses to microinstructions. </li></ul><ul><li>Cons: additional bits for the address field (around 1/6) </li></ul>By RAKESH ROSHAN 09971640291
  20. 20. Microinstructions with Next-Address Field By RAKESH ROSHAN 09971640291
  21. 21. Prefetching Microinstructions One drawback of microprogrammed control is that it leads to a slower operating speed because of the time it takes to fetch microinstructions from the control store. Faster operation is achieved if the next microinstruction is prefetched while the current one is being executed. In this way , the execution time can be overlapped with the fetch time. Prefetching microinstructions presents some organizational difficulties . Sometimes the status flags and the result of the currently executed microinstruction are needed to determine the address of the next microinstruction. In these cases , the fetch must be repeated with the correct address, which requires more complex hardware. However , the disadvantages are minor, and the prefetching technique is often used. By RAKESH ROSHAN 09971640291
  22. 22. Emulation The main function of microprogrammed control is to provide a means for simple, flexible and relatively inexpensive execution of machine instructions. However , it also offers other interesting possibilities. Its flexibility in using a machine’s resources allows diverse classes of instructions to be implemented . Given a computer with a certain instruction set, it is possible to define additional machine instructions and implement them with extra microroutines. An extension of the preceding idea leads to another interesting possibility. Suppose we add to the instruction repertoire of a given computer, M1, an entirely new set of instructions that is in fact the instruction set of a computer , M2. Programs written in the machine language of M2 can then be run on computer M1, that is M1 emulates M2. By RAKESH ROSHAN 09971640291

×