FazBrowse Wikipedia Viewer | Main Page |
Search Wikipedia:
|
Viewing: https://en.wikipedia.org/wiki/Microcode

Microcode

Contents
    Microcode
    Design
    Microprograms
Justification
    Vertical microcode
Writable control store
Micro-operations
External links

Program execution
General concepts
Types of code
Compilation strategies
Notable runtimes
Notable compilers & toolchains
ADC, which differ only in where they look to find the two operands.

Using the variation of the instruction, or "opcode", that most closely matches the ultimate operation can reduce the number of instructions to one, saving memory used by the program code and improving performance by leaving the data bus open for other operations. Internally, however, these instructions are not separate operations, but sequences of the operations the units actually perform. Converting a single instruction read from memory into the sequence of internal actions is the duty of the control unit, another unit within the processor.

Microcode

edit

The basic idea behind microcode is to replace the custom hardware logic implementing the instruction sequencing with a series of simple instructions run in a "microcode engine" in the processor. Whereas a custom logic system might have a series of diodes and gates that output a series of voltages on various control lines, the microcode engine is connected to these lines instead, and these are turned on and off as the engine reads the microcode instructions in sequence. The microcode instructions are often bit encoded to those lines, for instance, if bit 8 is true, that might mean that the ALU should be paused awaiting data. In this respect microcode is somewhat similar to the paper rolls in a player piano, where the holes represent which key should be pressed.

The distinction between custom logic and microcode may seem small, one uses a pattern of diodes and gates to decode the instruction and produce a sequence of signals, whereas the other encodes the signals as microinstructions that are read in sequence to produce the same results. The critical difference is that in a custom logic design, changes to the individual steps require the hardware to be redesigned. Using microcode, all that changes is the code stored in the memory containing the microcode or the storage device from which the microcode is loaded into the control store. This makes it much easier to fix problems in a microcode system. It also means that there is no effective limit to the complexity of the instructions, it is only limited by the amount of memory one is willing to use.

The lowest layer in a computer's software stack is traditionally raw machine code instructions for the processor. In microcoded processors, fetching and decoding those instructions, and executing them, may be done by microcode. To avoid confusion, each microprogram-related element is differentiated by the micro prefix: microinstruction, microassembler, microprogrammer, etc.

Complex digital processors may also employ more than one (possibly microcode-based) control unit in order to delegate sub-tasks that must be performed essentially asynchronously in parallel. For example, the VAX 9000 has a hardwired IBox unit to fetch and decode instructions, which it hands to a microcoded EBox unit to be executed, and the VAX 8800 has both a microcoded IBox and a microcoded EBox.

A high-level programmer, or even an assembly language programmer, does not normally see or change microcode. Unlike machine code, which often retains some backward compatibility among different processors in a family, microcode only runs on the exact electronic circuitry for which it is designed, as it constitutes an inherent part of the particular processor design itself.

Design

edit

Engineers normally write the microcode during the design phase of a processor, storing it in a read-only memory (ROM) or programmable logic array (PLA) structure, or in a combination of both. However, machines also exist that have some or all microcode stored in static random-access memory (SRAM) or flash memory. This is traditionally denoted as writable control store in the context of computers, which can be either read-only or read–write memory. In the latter case, the CPU initialization process loads microcode into the control store from another storage medium, with the possibility of altering the microcode to correct bugs in the instruction set, or to implement new machine instructions.

Microprograms

edit

Microprograms consist of series of microinstructions, which control the CPU at a very fundamental level of hardware circuitry. For example, a single typical horizontal microinstruction might specify the following operations simultaneously:

  • Connect register 1 to the A side of the ALU
  • Connect register 7 to the B side of the ALU
  • Set the ALU to perform two's-complement addition
  • Set the ALU's carry input to zero
  • Connect the ALU output to register 8
  • Update the condition codes from the ALU status flags (negative, zero, overflow, and carry)
  • Microjump to a given μPC address for the next microinstruction

To simultaneously control all processor's features in one cycle, the microinstruction is often wider than 50 bits; e.g., 128 bits on a 360/85 with an emulator feature. Microprograms are carefully designed and optimized for the fastest possible execution, as a slow microprogram would result in a slow machine instruction and degraded performance for related application programs that use such instructions.

Justification

edit

Microcode was originally developed as a simpler method of developing the control logic for a computer. Initially, CPU instruction sets were hardwired. Each step needed to fetch, decode, and execute the machine instructions (including any operand address calculations, reads, and writes) was controlled directly by combinational logic and rather minimal sequential state machine circuitry. While such hard-wired processors were very efficient, the need for powerful instruction sets with multi-step addressing and complex operations (see below) made them difficult to design and debug; highly encoded and varied-length instructions can contribute to this as well, especially when very irregular encodings are used.

Microcode simplified the job by allowing much of the processor's behaviour and programming model to be defined via microprogram routines rather than by dedicated circuitry. Even late in the design process, microcode could easily be changed, whereas hard-wired CPU designs were very cumbersome to change. Thus, this greatly facilitated CPU design.

From the 1940s to the late 1970s, a large portion of programming was done in assembly language; higher-level instructions mean greater programmer productivity, so an important advantage of microcode was the relative ease by which powerful machine instructions can be defined. The ultimate extension of this are "Directly Executable High Level Language" designs, in which each statement of a high-level language such as PL/I is entirely and directly executed by microcode, without compilation. The IBM Future Systems project and Data General Fountainhead Processor are examples of this. During the 1970s, CPU speeds grew more quickly than memory speeds and numerous techniques such as memory block transfer, memory pre-fetch and multi-level caches were used to alleviate this. High-level machine instructions, made possible by microcode, helped further, as fewer more complex machine instructions require less memory bandwidth. For example, an operation on a character string can be done as a single machine instruction, thus avoiding multiple instruction fetches.

Architectures with instruction sets implemented by complex microprograms included the IBM System/360 and Digital Equipment Corporation VAX. The approach of increasingly complex microcode-implemented instruction sets was later called complex instruction set computer (CISC). An alternate approach, used in many microprocessors, is to use one or more programmable logic array (PLA) or read-only memory (ROM) (instead of combinational logic) mainly for instruction decoding, and let a simple state machine (without much, or any, microcode) do most of the sequencing. The MOS Technology 6502 is an example of a microprocessor using a PLA for instruction decode and sequencing. The PLA is visible in photomicrographs of the chip, and its operation can be seen in the transistor-level simulation.

Microprogramming is still used in modern CPU designs. In some cases, after the microcode is debugged in simulation, logic functions are substituted for the control store.# Any line starting with a number-sign is a comment # This is just a label, the ordinary way assemblers symbolically represent a # memory address. InstructionJUMP: # To prepare for the next instruction, the instruction-decode microcode has already # moved the program counter to the memory address register. This instruction fetches # the target address of the jump instruction from the memory word following the # jump opcode, by copying from the memory data register to the memory address register. # This gives the memory system two clock ticks to fetch the next # instruction to the memory data register for use by the instruction decode. # The sequencer instruction "next" means just add 1 to the control word address. MDR, NONE, MAR, COPY, NEXT, NONE # This places the address of the next instruction into the PC. # This gives the memory system a clock tick to finish the fetch started on the # previous microinstruction. # The sequencer instruction is to jump to the start of the instruction decode. MAR, 1, PC, ADD, JMP, InstructionDecode # The instruction decode is not shown, because it is usually a mess, very particular # to the exact processor being emulated. Even this example is simplified. # Many CPUs have several ways to calculate the address, rather than just fetching # it from the word following the op-code. Therefore, rather than just one # jump instruction, those CPUs have a family of related jump instructions.

For each tick it is common to find that only some portions of the CPU are used, with the remaining groups of bits in the microinstruction being no-ops. With careful design of hardware and microcode, this property can be exploited to parallelise operations that use different areas of the CPU; for example, in the case above, the ALU is not required during the first tick, so it could potentially be used to complete an earlier arithmetic instruction.

Vertical microcode

edit

In vertical microcode, each microinstruction is significantly encoded, that is, the bit fields generally pass through intermediate combinatory logic that, in turn, generates the control and sequencing signals for internal CPU elements (ALU, registers, etc.). This is in contrast with horizontal microcode, in which the bit fields either directly produce the control and sequencing signals or are only minimally encoded. Consequently, vertical microcode requires smaller instruction lengths and less storage, but requires more time to decode, resulting in a slower CPU clock.

Some vertical microcode is just the assembly language of a simple conventional computer that is emulating a more complex computer. Some processors, such as DEC Alpha processors and the CMOS microprocessors on later IBM mainframes System/390 and z/Architecture, use machine code, running in a special mode that gives it access to special instructions, special registers, and other hardware resources unavailable to regular machine code, to implement some instructions and other functions, such as page table walks on Alpha processors. This is called PALcode on Alpha processors and millicode on IBM mainframe processors.

Another form of vertical microcode has two fields:

Field selectField value

The field select selects which part of the CPU will be controlled by this word of the control store. The field value controls that part of the CPU. With this type of microcode, a designer explicitly chooses to make a slower CPU to save money by reducing the unused bits in the control store; however, the reduced complexity may increase the CPU's clock frequency, which lessens the effect of an increased number of cycles per instruction.

As transistors grew cheaper, horizontal microcode came to dominate the design of CPUs using microcode, with vertical microcode being used less often.

When both vertical and horizontal microcode are used, the horizontal microcode may be referred to as nanocode or picocode.

Writable control store

edit

The design trend toward heavily microcoded processors with complex instructions began in the early 1960s and continued until roughly the mid-1980s. At that point the RISC design philosophy started becoming more prominent.

A CPU that uses microcode generally takes several clock cycles to execute a single instruction, one clock cycle for each step in the microprogram for that instruction. Some CISC processors include instructions that can take a very long time to execute. Such variations interfere with both interrupt latency and, what is far more important in modern systems, pipelining.

When designing a new processor, a hardwired control RISC has the following advantages over microcoded CISC:

  • Programming has largely moved away from assembly level, so it's no longer worthwhile to provide complex instructions for productivity reasons.
  • Simpler instruction sets allow direct execution by hardware, avoiding the performance penalty of microcoded execution.
  • Analysis shows complex instructions are rarely used, hence the machine resources devoted to them are largely wasted.
  • The machine resources devoted to rarely used complex instructions are better used for expediting performance of simpler, commonly used instructions.
  • Complex microcoded instructions may require many clock cycles that vary, and are difficult to pipeline for increased performance.

There are counterpoints as well:

  • The complex instructions in heavily microcoded implementations may not take much extra machine resources, except for microcode space. For example, the same ALU is often used to calculate an effective address and to compute the result from the operands, e.g., the original Z80, 8086, and others.
  • The simpler non-RISC instructions (i.e., involving direct memory operands) are frequently used by modern compilers. Even immediate to stack (i.e., memory result) arithmetic operations are commonly employed. Although such memory operations, often with varying length encodings, are more difficult to pipeline, it is still fully feasible to do so - clearly exemplified by the i486, AMD K5, Cyrix 6x86, Motorola 68040, etc.
  • Non-RISC instructions inherently perform more work per instruction (on average), and are also normally highly encoded, so they enable smaller overall size of the same program, and thus better use of limited cache memories.

Many RISC and VLIW processors are designed to execute every instruction (as long as it is in the cache) in a single cycle. This is very similar to the way CPUs with microcode execute one microinstruction per cycle. VLIW processors have instructions that behave similarly to very wide horizontal microcode, although typically without such fine-grained control over the hardware as provided by microcode. RISC instructions are sometimes similar to the narrow vertical microcode.

Micro-operations

edit

Modern CISC implementations, such as the x86 family starting with the NexGen Nx586, Intel Pentium Pro, and AMD K5, decode instructions into dynamically buffered micro-operations with an instruction encoding similar to RISC or traditional microcode. A hardwired instruction decode unit directly emits microoperations for common x86 instructions, but falls back to a more traditional microcode ROM containing microoperations for more complex or rarely used instructions.

For example, an x86 might look up microoperations from microcode to handle complex multistep operations such as loop or string instructions, floating-point unit transcendental functions or unusual values such as denormal numbers, and special-purpose instructions such as CPUID.

    Both, David (23 July 2020). "The central processing unit (CPU): Its components and functionality". Red Hat.
  1. ↑ VAX 9000 System Technical Description (PDF). Digital Equipment Corporation. May 1990. pp. 3-5 – 3-32. EK-KA90S-TD-001.
  2. ↑ Supnik, Bob (24 February 2008). "J-11: DEC's fourth and last PDP-11 microprocessor design ... features ... ROM/PLA control store". Archived from the original on 2011-07-09. Retrieved 2011-07-10.
  3. ↑ Bell, Gordon; Strecker, W.D. What Have We Learned from the PDP-11 – What We Have Learned from VAX and Alpha (PDF) (Report). p. 30. Retrieved 2025-06-26.
  4. ↑ Wilkes, Maurice (1951). The Best Way to Design an Automatic Calculating Machine (Technical report). University of Manchester.
  5. Clark, Douglas; Strecker, William (September 1980). "Comments on "The Case for the Reduced Instruction Set Computer," by Patterson and Ditzel". ACM SIGARCH Computer Architecture News. 8 (6): 34–38. doi:10.1145/641914.641918. S2CID 14939489.
  6. ↑ "Part I / Common Architecture, Chapter 6 Common PALcode Architecture". Alpha AXP Architecture Reference Manual (PDF) (Second ed.). Digital Press. 1995. ISBN 978-1-55558-145-9.
  7. ↑ IBM System/360 Model 25 Functional Characteristics (PDF). IBM. January 1968. p. 22. A24-3510-0. Retrieved October 29, 2021.
  8. 1 2 3 Soltis, Frank (September 1981). "Design of a Small Business Data Processing System". IEEE Computer. 14: 77–93. doi:10.1109/C-M.1981.220610. S2CID 398484.
  9. ↑ "Indiana Jones and the Infernal Machine". IGN. December 12, 2000. Archived from the original on September 27, 2013. Retrieved September 24, 2013.
  10. ↑ Digital Scientific Meta 4 Series 16 Computer System Reference Manual (PDF). Digital Scientific Corporation. May 1971. 7032MO. Archived (PDF) from the original on 2020-01-14. Retrieved 2020-01-14.
  11. ↑ Digital Scientific Meta 4 Computer System Typical ROM Pattern Listing and Program To Simulate The IBM 1130 Instruction Set (PDF). Digital Scientific Corporation. January 1970. M4/005P-170. Archived (PDF) from the original on 2020-03-24. Retrieved 2020-01-14.
  12. ↑ "80386 microcode disassembled « Reenigne blog". Retrieved 2026-05-23.
  13. ↑ Hayes, John P. (1978). Computer Architecture and Organization. McGraw-Hill. p. 300. ISBN 978-0-07-027363-4.
  14. ↑ Rogers, Bob (September–October 2012). "The What and Why of zEnterprise Millicode". IBM Systems Magazine. Archived from the original on 2013-10-16. Retrieved 2013-11-07.
  15. ↑ Koopman, Philip Jr. (1987). "Writable instruction set, stack oriented computers: The WISC Concept" (PDF). The Journal of Forth Application and Research: 49–71. Archived (PDF) from the original on 2008-05-11.
  16. ↑ IBM System/370 Principles of Operation (PDF). Fourth Edition. IBM. September 1974. pp. 98, 245. GA22-7000-4. Archived (PDF) from the original on 2012-02-29. Retrieved 2012-08-27.
  17. ↑ Stiller, Andreas; Paul, Matthias R. (1996-05-12). "Prozessorgeflüster". c't – magazin für computertechnik. Trends & News (in German). Heise Verlag. Archived from the original on 2017-08-28. Retrieved 2017-08-28.
  18. ↑ "Intel Microcode Update Utility for Linux". Archived from the original on 2012-02-26.
  19. ↑ "Server Products - BIOS Update required when Missing Microcode message is seen during POST". Intel. January 24, 2013. Archived from the original on September 1, 2014.
  20. ↑ Smith, Richard E. (1988). "A Historical Overview of Computer Architecture". Annals of the History of Computing. 10 (4): 277–303. Bibcode:1988IAHC...10d.277S. doi:10.1109/MAHC.1988.10039. S2CID 16405547. Retrieved June 21, 2006.
  21. Wilkes, M. V.; Stringer, J. B. (April 1953). "Microprogramming and the Design of the Control Circuits in an Electronic Digital Computer". Mathematical Proceedings of the Cambridge Philosophical Society. 49 (2): 230–238. Bibcode:1953PCPS...49..230W. doi:10.1017/S0305004100028322. S2CID 62230627. Retrieved August 23, 2006.
  22. Shirriff, Ken (December 2022). "How the 8086 processor's microcode engine works".
  23. External links

    edit
    Look up microcode in Wiktionary, the free dictionary.
Models
Architecture
Instruction set
architectures
Types
Instruction
sets
Execution
Instruction pipelining
Hazards
Out-of-order
Speculative
Parallelism
Level
Multithreading
Flynn's taxonomy
Processor
performance
Types
By application
Systems
on chip
Hardware
accelerators
Word size
Core count
Components
Functional
units
Logic
Registers
Control unit
Datapath
Circuitry
Power
management
Related

View original on Wikipedia | Back | FazBrowse Home