Microprogrammed Control Unit: Microprogrammed Control Unit produces control signals by using micro-instructions. Micro program: A program is a set of instructions. An instruction requires a set of micro-operations. Micro-operations are performed using control signals. Here, these control signals are generated using micro-instructions .This means every instruction requires a set of micro-instructions . A set of micro-instructions are called micro-program. Microprograms for all instructions are stored in a small memory called control memory. The control memory is present inside the processor. Working: Consider an instruction that is fetched from the main memory into the instruction Register (IR). The processor uses its unique opcode to identify the address of the first micro-instruction. That address is loaded into CMAR (Control Memory Address Register). This address is decoded to decide the corresponding memory instruction from the control Memory. Micro-instructions will only have a control field. The control field Indicates the control signals to be generated. Most micro-instructions will not have an address field. Usually µPC will simply get incremented after every micro-instruction. This is as long as the micro-program is executing sequentially. If there is a branch micro-instruction only then there will be an address filed. If the branch is unconditional, the branch address will be directly loaded into CMAR. For conditional branches, the branch condition will check the appropriate flag. This is done using a MUX which has all flag inputs. If the condition is true, then the mux will inform CMAR to load the branch address. If the condition is false CMAR will simply get incremented. The control memory is usually implemented using flash ROM as it is non-volatile. Microprogrammed control unit Advantages : 1. The main advantage is flexibility. 2. Any change in the control unit can be performed by simply changing the micro-instruction. 3. Can be easily debugged as compared to hardwired control unit. Most micro-instructions are executed sequentially, they don’t require any address field. 5. Reduction of size of control memory. 4. Disadvantages : 1. Control memory has to be present inside the processor, therefore increases processor size. 2. This also increases the cost of the processor. Applications of Microprogrammed Control Unit : Microprogramming has many advantages like flexibility, simplicity, cost-effectiveness etc. Therefore, it has a major contribution in the following applications – 1. Development of control units – Modern processors have very large and complex instruction sets. Microprogramming is used for making control units of such processors, because it is far less complex and can be easily modified. 2. High level language support – Modern high level languages have more advanced and complex data types. Microprogramming can provide support for such data types directly from the processor level. Therefore, the language becomes easy to compile and also faster to execute. 3. User tailoring of the control unit – As the control Unit is developed using software, it can be easily reprogrammed. This can be used for custom-made modifications of the Control Unit. For this purpose, the control memory must be writeable like RAM or flash ROMs. 4. Emulation – Emulation is when one processor (say A) is made to emulate or behave like another processor (say B). To do this, A must be able to execute the instructions of B. If we re-program the control memory of A, same as that of B, then A will be able to emulate the behavior of B, for every instruction. This is possible only in microprogrammed control units. Used generally when a main processor has to emulate the behavior of a math co-processor. 5. Improving the operating system – Microprogramming can be used to implement complex and secure functions of the OS. This not only makes the OS more powerful and efficient, but more importantly secure, as it provides the OS a higher degree of protection from malicious virus attacks. Micro-Diagnostics or error debugging – As Microprogrammed Control Units are software based, debugging an error is far more easy as compared to doing the same for a complex hardwired control unit. This allows monitoring, detection and repairs of any kind of system errors in the control unit. It can also use as a runtime substitute, if the corresponding hardwired component fails. 7. Development of special purpose processors – All processors are not general purpose. Many applications require special purpose processors like DSP(Digital Signal Processors) for communication, GPU (Graphic Processor Unit) for image processing. They have complex instruction sets and also need to be constantly upgraded. Microprogrammed control unit is the best choice for them 6. Types of Micro-programmed Control Unit – Based on the type of Control Word 1. Horizontal Micro-programmed Control Unit : The control signals are represented in the decoded binary format that is 1 bit/CS. Example: If 53 Control signals are present in the processor then 53 bits are required. More than 1 control signal can be enabled at a time. • It supports longer control words. • It is used in parallel processing applications. • It allows a higher degree of parallelism. If degree is n, n CS is enabled at a time. It requires no additional hardware(decoders). It means it is faster than Vertical Microprogrammed. • It is more flexible than vertical microprogrammed 2. Vertical Micro-programmed Control Unit : The control signals are represented in the encoded binary format. For N control signals- Log2(N) bits are required. • It supports shorter control words. • It supports easy implementation of new control signals therefore it is more flexible. • It allows a low degree of parallelism i.e., the degree of parallelism is either 0 or 1. • Requires additional hardware (decoders) to generate control signals, it implies it is slower than horizontal microprogrammed. • It is less flexible than horizontal but more flexible than that of a hardwired control unit. • Example: Consider a hypothetical Control Unit that supports 4 k words. The Hardware contains 64 control signals and 16 Flags. What is the size of control word used in bits and control memory in a byte using: a) Horizontal Programming b) Vertical programming Solution: a)For Horizontal 64 bits for 64 signals + 16 bits for flags Control Word Size = 64 + 16 = 80 bits //Control Memory = 4 kW = ( (4* 80) / 8 ) = 40 kB b) For Vertical 6 bits for 64 signals i.e log 264 4 bits for 16 flags i.e log 216 12 bits for 4K words i.e log 2(4*1024) Control Word Size = 4 + 6 + 12 = 22 bits //Control Memory = 4 kW = ( (4* 22) / 8 ) = 11 kB