انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

Lec8: control unit part1

الكلية كلية العلوم للبنات     القسم قسم الحاسبات     المرحلة 3
أستاذ المادة نور كاظم ايوب مهدي المهدي       11/01/2016 15:11:30
8. CONTROL UNIT
The control unit (CU) is the main component that directs the system operations by sending control signals to the datapath. These signals control the flow of data within the CPU and between the CPU and external units such as memory and I/O. There are mainly two different types of control units: hardwired CU and micro programmed CU.
8.1 Hardwired control:
Control buses generally carry signals between the control unit and other computer components in a clock-driven manner.
The system clock produces a continuous sequence of pulses in a specified duration and frequency. A sequence of steps t0 , t1 , t2 , . . . , (t0 , t1 , t2 , . . .) are used to execute a certain instruction. The op-code field of a fetched instruction is decoded to provide the control signal generator with information about the instruction to be executed.

Step information generated by a logic circuit module is used with other inputs to generate control signals. The signal generator can be specified simply by a set of Boolean equations for its output in terms of its inputs. Figure above shows a block diagram that describes how timing is used in generating control signals.
Fixed logic circuits that correspond directly to the Boolean expressions are used to generate the control signals. Let us explain the implementation using a simple example. Assume that the instruction set of a machine has the three instructions: Inst-x, Inst-y, and Inst-z; and A, B, C, D, E, F, G, and H are control lines. The following table shows the control lines that should be activated for the three instructions at the three steps t0 , t1 , and t2 .

The Boolean expressions for control lines A, B, and C can be obtained as follows:

A =Inst-x . t1 ‏ +Inst-z . t1 = (Inst-x +‏ Inst-z) . t1
B = Inst-x . t0 +‏ Inst-y .t2
C = Inst-x . t1 +‏ Inst-x . t2 ‏ +Inst-y . t2 ‏ + Inst-z .t1
= (Inst-x ‏ + Inst-z) .t1 +‏ (Inst-x +‏ Inst-y) . t2
The following figure shows the logic circuits for these control lines. Boolean expressions for the rest of the control lines can be obtained in a similar way.


The following figure shows the state diagram in the execution cycle of these instructions:

Clearly hardwired control is faster than micro programmed control. However, hardwired control could be very expensive and complicated for complex systems. Hardwired control is more economical for small control units. Hardwired control will require a redesign of the entire systems in the case of any change.
8.2 Micro programmed Control Unit :
In micro programmed control, the control signals associated with operations are stored in special memory units inaccessible by the programmer as control words. A control word is a microinstruction that specifies one or more micro operations. A sequence of microinstructions is called a micro program, which is stored in a ROM or RAM called a control memory (CM).
A micro program consists of a sequence of micro instructions. A microinstruction is a vector of bits, where each bit is a control signal, condition code, or the address of the next microinstruction. Microinstructions are fetched from CM the same way program instructions are fetched from main memory:

When an instruction is fetched from memory, the op-code field of the instruction will determine which microprogram is to be executed. In other words, the op-code is mapped to a microinstruction address in the control memory.
8.2.1 How to generate Control Words?
Microinstructions can be classified as horizontal or vertical.Individual bits in horizontal microinstructions correspond to individual control lines.Horizontal microinstructions are long and allow maximum parallelism since each bit controls a single control line. This method requires arranging micro operations and registers (taking into consideration that there are two situations for each a register in/out) according to a particular sequence.

Example: suppose you have the following arrangement for micro operations and registers:
Sub, add, clear y, set carry, ARin, Yin, Yout, Zout, Zin,
DRout,PCout, PCin, ARout, Read, WMFC, IRout, IRin
Generate CW for fetch cycle for the instruction: add R1,X.
Sol:
Micro instructions (Steps) Control Words
Pcout, Arin, set carry, clear y,read ,add,zin 01111000101001000
Zout,PCin,WMFC 00000001000100100
DRout, IRin 00000000010000001




The disadvantage of this method is: the length of the control unit is very long, why?

In vertical microinstructions, control lines are coded into specific fields within a microinstruction. Decoders are needed to map a field of k bits to 2k possible combinations of control lines. For example, a 3-bit field in a microinstruction could be used to specify any one of eight possible lines. Because of the encoding, vertical microinstructions are much shorter than horizontal ones.
Control lines encoded in the same field cannot be activated simultaneously. Therefore, vertical microinstructions
allow only limited parallelism. It should be noted that no decoding is needed in horizontal microinstructions while decoding is necessary in the vertical case. Here is an example of what may look like groups:


F1 (4 bits) F2(3 bits) F3(2bits)
0000 no action
0001 PCout
0010 DRout
0011 Zout
0100 R0out
0101 R1 out
0011 R2 out
0111 R3 out
1000 Source out
1001 dest out
1010 temp out
1011 address out 000 no action
001 PCin
010 IRin
011 Zin
100 R0 in
101 R1 in
110 R2 in
111 R3 in 00 no action
01 AR in
10 DR in
11 temp in
F4 (2 bits)
00 no action
01 Yin
10 Source in
11 dest in
F5 (4 bits) F6(2 bit)
0000 no action
0001 add
0010 sub
….. 00 no action
01 read
10 write
F7 ( 1 bit) F8 ( 1 bit)
0 no action
1 clear y 0 carry in =0
1 carry in=1
F9( 1 bit) F10 ( 1 bit)
0 no action
1 WMFC 0 continue
1 end




Sol:
F1 F2 F3 F4 F5 F6 F7 F8 F9 F10
M1 0001 011 00 00 0001 01 1 1 0 0
M2 0011 001 00 00 0000 00 0 0 1 0
M3 0000 010 10 00 0000 00 00 0 0 0

8.3 Exercises
1) Using the same information above try to find the CW for execution phase.
2) Using the same information above try to find the CW for the following instructions:
a- 50 Jmp 100
b- Load v
c- inc
d- mov x,R1
e- mul R1,[R2]-
3) Build a groups of signals (F1, F2, F3), the operations belonged to each group are shown below:
F1: Pc, AR, DR,I R, AC, BX,CX,DX (in mode).
F2: Pc, AR, DR, IR, Ac, BX,CX,DX (out mode).
F3: sub, add, div, mul.


المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .