Microcode

From Computer History Wiki
Jump to: navigation, search

Microcode (in the form of a microprogram) refers to a technique for implementing the functionality needed to control the internal operation of a CPU.

On each microcycle (analogous, internally, to the cycles of the main CPU), a microinstruction is fetched, and used to control the operation of the CPU's internal hardware elements during that microcycle: routing data out of registers (including internal registers not visible to the programmer) and/or main memory, through the ALU (while selecting which operation is to be performed by it), and then storing the results as apropriate. They are thus analagous to the instructions of the main CPU, but at a much lower level.

Background

The earliest generation of CPU's used collections of gates and flip-flops to implement the functionality of controlling the operation of the internal elements. As the instruction sets and overall architecture of early computers became more complex, the design of those combinatorial logic networks became more challenging.

In 1947, the Whirlwind computer introduced the concept of a control store; a wide read-only memory whose outputs directly controlled internal elements of the CPU. (E.g. one bit in a control word might control the latching of an internal register.)

The CPU cycled through the words in the control store, to execute instructions. Viewing (and implementing) the internal operation of the CPU in this way made the design task easier.

Enhancements

In 1951, Maurice Wilkes suggested more widespread use of that technique (to get rid of the design burden, and chance of errors, in using un-structured logic aggregations for control); he added conditional branching, to make microcode more flexible. Over time, more concepts from higher-level languages have been added to microcode, such as subroutines.

Although early microcode was implemented in read-only memory (the Whirlwind ROM was a diode matrix), some later computers included high-speed RAM for part of the control store, so that the instruction set could be dynamically extended to speed up applications.

Recently, microcode has been augmented with programmable logic arrays, which are usually given the job of decoding instructions (something done more efficiently in combinatorial logic).

Other advantages and uses

Once microprogramming came into more general use, a number of other advantages, and uses, appeared.

With much of the control for a microprogrammed machine in the microprogram, bugs in the CPU could often be fixed by replacing the microprogram alone, without required hardware changes. (With the coming of the microprocessor, where the microprogram is often in ROM in the chip, this is usually no longer possible.)

Microprogramming also made it possible to offer a range (in performance and cost terms) of machines which all had the same basic architecture, but different internal implementations; microcode could be used to make the different machines all support the same instruction set. This was originally, and most influentially, displayed by the IBM System/360 line of computers. This too is now not common, since it is not usual to offer multiple implementations with differing performance at the same time; however, it can be used to meet an analogous goal, making new generations of microprocessors implement the identical instruction set to previous ones.

The System/360 also showed another use for microcode: System/360 computers included microcode to emulate earlier IBM computers (such as the IBM 1401); in an era when most programming was done in assembly language, this allowed people to upgrade to a System/360 machine without discarding their investment in software for the earlier machine.

Once a microcoded CPU had been designed, it was relatively easy to expand the instruction set to include more complex instructions (something whose only per-unit repeated cost was larger microcode memories). For much of the lifetime of computers, the CPU was faster than the main memory; in such an environment, it made sense to make the instructions of the CPU as powerful (complicated) as possible, so a single instruction fetch (which is, of course, pure overhead in terms of the actual computation) does as much as possible. Such complex instructions are more easily implemented with a microcode approach, than with combinatorial logic.

Further reading

External links