Machine Language Writing a program for a computer consists of specifying, directly or indirectly, a sequence of machine instructions. Machine instructions inside the computer form a binary pattern which is difficult, if not impossible, for people to work with and understand. It is preferable to write programs with the more familiar symbols of the alphanumeric character set. As a consequence, there is a need for translating user-oriented symbolic programs into binary programs recognized by the hardware.
A program is a list of instructions or statements for directing the computer to perform a required data-processing task. There are various types of programming languages that one may write for a computer, but the computer can execute programs only when they are represented internally in binary.
Programs written for a computer may be in one of the following categories: Binary code: This is a sequence of instructions and operands in binary that list the exact representation of instructions as they appear in computer memory. Octal or hexadecimal code: This is an equivalent translation of the binary code to octal or hexadecimal representation. Symbolic code: The user employs symbols (letters, numerals, or special characters) for the operation part, the address part, and other parts of the instruction code. Each symbolic instruction can be translated into one binary coded instruction. This translation is done by a special program called an assembler. Because an assembler translates the
High-level programming languages: These are special languages developed to reflect the procedures used in the solution of a problem rather than be concerned with the computer hardware behavior. An example of a high-level programming language is Fortran. It employs problem oriented symbols and formats. The program is written in a sequence of statements in a form that people prefer to think in when solving a problem.
. The first column gives the memory location (in binary) of each instruction or operand. The second column lists the binary content of these memory locations. However, a person looking at this program will have a difficult time understanding what is to be achieved when this program is executed. Writing 16 bits for each instruction is tedious because there are too many digits. We can reduce the number of digits per instruction if we write the octal or hexadecimal equivalent of the binary code.
.
. The program in Table uses the symbolic names of instructions instead of their binary or hexadecimal equivalent. The address parts of memory-reference instructions, as well as operands, remain in their hexadecimal value. Symbolic programs are easier to handle, and as a consequence, it is preferable to write programs with symbols. These symbols can be converted to their binary code equivalent to produce the binary program.
.
.
Control Unit The Control Unit is the part of the computer’s central processing unit (CPU), which directs the operation of the processor. The component which receives the input signal/information/instruction from the user and converts into control signals for the execution in the CPU. It controls and directs the main memory, arithmetic & logic unit (ALU), input and output devices, and also responsible for the instructions that are sent to the CPU of a computer. It fetches the instructions from the main memory of a processor and sent to the processor instruction register, which contains register contents.
. The control unit converts the input into control signals and then sent to the processor and directs the execution of a program. The operations that have to performed are directed by the processor on the computer. Mainly Central Processing Unit (CPU) and Graphical Processing Unit (GPU) require a control unit as the internal part.
Functions of the Control Unit It coordinates the sequence of data movements into, out of, and between a processor’s many sub-units. It interprets instructions. It controls data flow inside the processor. It receives external instructions or commands to which it converts to sequence of control signals. It controls many execution units(i.e. ALU , data buffers and registers ) contained within a CPU. It also handles multiple tasks, such as fetching, decoding, execution handling and storing results.
Design of Control Unit The design of this can be done using two types of a control unit which include the following. Hardwire based Microprogrammed based(single-level and two-level)
Hardwired Control Unit In the hardwired organization, the control logic is executed with gates, flip-flops, decoders, and other digital circuits. A hardwired control requires changes in the wiring among the various elements if the design has to be modified or changed. It consists of two decoders, a sequence counter, and a number of control logic gates. An instruction read from memory is placed in the instruction register (IR).
Micro Programmable control unit Microprogramming is a second alternative for designing the control unit of a digital computer. The principle of microprogramming is an elegant and systematic method for controlling the microoperation sequences in a digital computer. For example, CPUs with microprogrammed control unit are Intel 8080, Motorola 68000, and any CISC (Complex Instruction Set Computer) CPUs. A control unit whose binary control values are saved as words in memory is called a microprogrammed control unit.
In a bus-organized system, the control signals that specify microoperations are groups of bits that select the paths in multiplexers, decoders, and arithmetic logic units. The control unit initiates a series of sequential steps of microoperations. During any given time, certain microoperations are to be initiated, while others remain idle. The control variables at any given time can be represented by a string of 1’s and 0’s called a control word.
The content of the words in ROM are fixed and cannot be altered by simple programming since no writing capability is available in the ROM. The use of a microprogram involves placing all control variables in words of ROM for use by the control unit through successive read operations. The content of the word in ROM at a given address specifies a microinstruction.
A memory that is part of a control unit is referred to as a control memory. A computer that employs a microprogrammed control unit will have two separate memories: a main memory and a control memory. The main memory is available to the user for storing the programs. The contents of main memory may alter when the data are manipulated and every time that the program is changed. The user’s program in main memory consists of machine instructions and data. In contrast, the control memory holds a fixed microprogram that cannot be altered by the occasional user. The microprogram consists of microinstructions that specify various internal control signals for execution of register microoperations. Each machine instruction initiates a series of microinstructions in control memory. These microinstructions generate the microoperations to fetch the instruction from main memory; to evaluate the effective address, to execute the operation specified by the instruction, and to return control to the fetch phase in order to repeat the cycle for the next instruction.
The control memory is assumed to be a ROM, within which all control information is permanently stored. The control memory address register specifies the address of the microinstruction, and the control data register holds the microinstruction read from memory. The control data register holds the present microinstruction while the next address is computed and read from memory. The data register is sometimes called a pipeline register. It allows the execution of the microoperations specified by the control word simultaneously with the generation of the next microinstruction.
The microinstruction contains a control word that specifies one or more microoperations for the data processor. Once these operations are executed, the control must determine the next address. The location of the next microinstruction may be the one next in sequence, or it may be located somewhere else in the control memory. For this reason it is necessary to use some bits of the present microinstruction to control the generation of the address of the next microinstruction. While the microoperations are being executed, the next address is computed in the next address generator circuit and then transferred into the control address register to read the next microinstruction. The next address generator is sometimes called microprogram sequencer.
The main advantage of the microprogrammed control is the fact that once the hardware configuration is established, there should be no need for further hardware or wiring changes. If we want to establish a different control sequence for the system, all we need to do is specify a different set of microinstructions for control memory. The hardware configuration should not be changed for different operations; the only thing that must be changed is the microprogram residing in control memory.
Address Sequencing Microinstructions are stored in control memory in groups, with each group specifying a routine. Each computer instruction has its own microprogram routine in control memory to generate the microoperations that execute the instruction. The hardware that controls the address sequencing of the control memory must be capable of sequencing the microinstructions within a routine and be able to branch from one routine to another.
An initial address is loaded into the control address register when power is turned on in the computer. This address is usually the address of the first microinstruction that activates the instruction fetch routine. The fetch routine may be sequenced by incrementing the control address register through the rest of its microinstructions. At the end of the fetch routine, the instruction is in the instruction register of the computer.
The control memory next must go through the routine that determines the effective address of the operand. A machine instruction may have bits that specify various addressing modes, such as indirect address and index registers. The effective address computation routine in control memory can be reached through a branch microinstruction, which is conditioned on the status of the mode bits of the instruction. When the effective address computation routine is completed, the address of the operand is available in the memory address register.
The next step is to generate the microoperations that execute the instruction fetched from memory. The microoperation steps to be generated in processor registers depend on the operation code part of the instruction. Each instruction has its own microprogram routine stored in a given location of control memory. The transformation from the instruction code bits to an address in control memory where the routine is located is referred to as a mapping process. Once the required routine is reached, the microinstructions that execute the instruction may be sequenced by incrementing the control address register,
.
.
Microprogram Example
The micro-programmed control unit can be classified into two types based on the type of Control Word stored in the Control Memory. Horizontal micro-programmed control unit Vertical micro-programmed control unit.
Horizontal micro-programmed control unit In the Horizontal micro-programmed control unit, the control signals are represented in the decoded binary format, i.e., 1 bit/CS. Here ‘n’ control signals require n bit encoding. In the horizontal format, each control signal is represented by a single bit in the control word. Thus, if the design has 500 control signals, this will require 500 bits in each control word to store the control bits. • In this format, the control store looks horizontal in shape since the control words are wide. Each micro-instruction specifies many different micro-operations to be performed in parallel. • The disadvantage of the horizontal format is that the size of the control store is large. However, it has the advantage of speed of operation as the control signals will be ready as soon as the control word is fetched from the control store.
Vertical Micro-programmed Control Unit Each micro-instruction specifies single (or few) micro-operations to be performed. In contrast to the Horizontal micro-programmed CU, a higher degree of encoding and variable format can be applied in the vertical micro-programmed control unit. With the help of encoded binary format, we can represent the control signals in the vertical micro-programmed CU. Here, log2n bit encoding is needed for 'n' control signals. With the help of vertical CU, we can shorten the length of microinstruction as well as prevent the length of microinstruction from being directly affected by the increasing memory capacity.
In the vertical microcode organization, the following steps are performed: – Identify the number of distinct control words in the design. – Encode each distinct control word by assigning a unique n-bit code to it, where n is log2 (number of distinct control words). – Instead of storing the actual control signals that need to be generated, only the n-bit code is stored for each CW. – Use a nx2n decoder to generate a decoded signal for each distinct control word.
Nano programming In microprogrammed processors, an instruction fetched from memory is interpreted by a micro program stored in a single control memory CM; whereas in other microprogrammed processors, the micro instructions are not directly used by the decoder to generate control signals. This is achieved by the use of a second control memory called a Nano control memory ( nCM ). So now there are two levels of control memories, a higher level control memory is known as micro control memory (µCM) and a lower level control memory is known as Nano control memory ( nCM ). Thus a microinstruction is in primary control-store memory, it then has the control signals generated for each microinstruction using a secondary control store memory The output word from the secondary memory is called Nano instruction. The µCM stores micro instructions whereas nCM stores nano instructions. The decoder uses Nano instructions from nCM to generate control signals
Here we have a two-level control memory. The instruction is fetched from the main memory into instruction register IR. Using its opcode we load address of its first micro-instruction into µPC, Using this address we fetch the micro-instruction from micro control memory (µCM) into micro instruction register µIR. This is in vertical form and decoded by a decoder. The decoded output loads a new address in a nano program counter ( nPC ). By using this address, the nano-instruction is fetched from nano-control memory ( nCM ) into nano instruction register ( nIR ). This is in horizontal form and can directly generate control signals which can be multiple at a time. Such a combination gives advantage of both techniques. The size of the control Memory is small as micro-instructions are vertical.