Sub topic 17
Horizontal and vertical microinstructions
This chapter assumes you know what a control store is, how a microprogrammed control unit steps through microinstructions, and what a control signal does on a datapath. Here we look at how a microinstruction word is laid out, and how that layout decides the size of the control store.
What a microinstruction holds
A microinstruction is one word in the control store. It must say two things:
- Which control signals to assert during this clock step. This is the control field.
- Which microinstruction runs next. This is the sequencing field, made of a condition-select field and a next-address field.
The way the control field is encoded gives two styles: horizontal and vertical. The sequencing field is mostly the same in both.
Horizontal microinstructions
In a horizontal format, each control signal gets its own bit. If the datapath has 40 signals, the control field has 40 bits. A bit value of 1 asserts the signal.
- Any set of signals can be asserted in the same step, so the microprogram has maximum parallelism.
- No decoder is needed between the control store and the datapath, so the signals arrive quickly.
- The word is very wide, so the control store is large.
- Most bits in a word are 0, so the encoding wastes space.
Vertical microinstructions
In a vertical format, signals are grouped into fields, and each field is binary encoded. A field with n possible choices needs ceil(log2 n) bits. A decoder after the control store expands each field into individual signals.
- The word is narrow, so the control store is small.
- Only one choice per field can be active at a time, so less work happens per step and the microprogram needs more microinstructions.
- The decoders add gate delay to every step.
Field grouping and mutually exclusive signals
Signals can share a field only if they are never needed at the same time. Typical examples are the ALU function select (add, subtract, AND, OR) and the register that drives the bus. The ALU does one operation at a time, and only one source may drive a shared bus.
Signals that must be asserted together in the same step must go in different fields. If two such signals were forced into one field, the microprogram would need two steps.
Grouping gives a middle option called a nanoprogrammed or partially encoded format. Real machines usually use a mix, with some fields encoded and some left as single bits.
Sizing the control store
GATE questions on this topic mostly ask for the control store size. The word width is:
control word width = control field bits + condition-select bits + next-address bits
The control store size is the number of words multiplied by the word width.
For the next-address field, an address in a store of N words needs ceil(log2 N) bits.
The following program computes the width and total size for both formats.
from math import ceil, log2
def horizontal_width(num_signals, cond_bits, store_words):
addr_bits = ceil(log2(store_words))
return num_signals + cond_bits + addr_bits
def vertical_width(field_choices, cond_bits, store_words):
addr_bits = ceil(log2(store_words))
control_bits = sum(ceil(log2(n)) for n in field_choices)
return control_bits + cond_bits + addr_bits
words = 256
cond_bits = 2
# 36 signals, one bit each
h = horizontal_width(36, cond_bits, words)
# the same 36 signals grouped into fields of 8, 8, 4, 16 choices
# (fields hold mutually exclusive signals; a "no signal" choice counts)
v = vertical_width([8, 8, 4, 16], cond_bits, words)
print("horizontal width:", h, "bits, store:", h * words, "bits")
print("vertical width: ", v, "bits, store:", v * words, "bits")The output is:
horizontal width: 46 bits, store: 11776 bits
vertical width: 19 bits, store: 4864 bitsThe horizontal control field takes 36 bits. The vertical one takes 3 + 3 + 2 + 4 = 12 bits. The condition select (2 bits) and next address (8 bits) are the same in both.
Counting the "no operation" choice
A field must be able to say "assert none of my signals" if some steps need nothing from that field. So a field that controls n signals, where at most one is asserted, has n + 1 choices. Then it needs ceil(log2(n + 1)) bits.
- 7 mutually exclusive signals plus "none" gives 8 choices and 3 bits.
- 8 mutually exclusive signals plus "none" gives 9 choices and 4 bits.
Read the question carefully for whether "none" is counted. Many GATE questions state the number of signals per field and expect you to add the idle case only if told it is needed.
Worked example
A control unit has 24 control signals. They split into groups of mutually exclusive signals of size 7, 3, 5 and 4 (the remaining 5 signals are independent and each uses its own bit). The control store has 512 words, and the condition-select field has 3 bits.
- Next-address bits: ceil(log2 512) = 9.
- Encoded fields with an idle choice: 7 + 1 = 8 choices needs 3 bits. 3 + 1 = 4 choices needs 2 bits. 5 + 1 = 6 choices needs 3 bits. 4 + 1 = 5 choices needs 3 bits. Total 11 bits.
- Independent signals: 5 bits.
- Control field: 11 + 5 = 16 bits.
- Word width: 16 + 3 + 9 = 28 bits.
- Store size: 512 × 28 = 14336 bits, or 1.75 KiB.
Check: 7 + 3 + 5 + 4 + 5 = 24 signals, so every signal is covered.
Comparison
The table shows the trade-off in each design property.
| Property | Horizontal | Vertical |
|---|---|---|
| Control field encoding | One bit per signal | Encoded fields |
| Word width | Wide | Narrow |
| Control store size | Large | Small |
| Signals per step | Many in parallel | Limited by fields |
| Decoder delay | None | One decoder level |
| Microprogram length | Short | Longer |
| Speed | Faster | Slower |
| Flexibility to add signals | Add a bit | May need field redesign |
The trade-off is not one-sided. A vertical format makes each word smaller but can need more words, because less runs in parallel. For most designs the width saving still dominates.
Diagram of the two paths
The diagram shows how the control word reaches the datapath in each style.
Common mistakes
- Using log2 of the number of signals for the whole control field. Encoding works per field, not over all signals together.
- Forgetting the ceiling in ceil(log2 n). 5 choices need 3 bits, not 2.32.
- Forgetting the next-address bits or the condition-select bits.
- Placing signals that must fire together in the same field.
- Mixing up the two names. Horizontal means wide with no decoding. Vertical means narrow with decoding.
Exercises
Exercise
A horizontal microprogrammed control unit has 48 control signals, a 4-bit condition-select field, and a control store of 1024 words. What is the word width in bits, and what is the control store size in KiB?
Show answer
Next-address bits = log2 1024 = 10. Word width = 48 + 4 + 10 = 62 bits. Store size = 1024 × 62 = 63488 bits = 7936 bytes = 7.75 KiB.
Exercise
A vertical format groups control signals into three fields. Field A selects one of 12 signals, field B selects one of 5 signals, and field C selects one of 20 signals. In each field, "no signal" is also a valid choice. How many control-field bits are needed, and how does this compare with a horizontal field for the same 37 signals?
Show answer
Each field has one extra choice. A: 13 choices, 4 bits. B: 6 choices, 3 bits. C: 21 choices, 5 bits. Total = 12 bits. Horizontal needs 12 + 5 + 20 = 37 bits, so the vertical format saves 25 bits per word.
Exercise
A control unit has a control store of 2048 words. Each word has a 3-bit condition-select field and a 7-bit encoded control field. The control store is 2048 × W bits. What is W, and how many bits of the word are the next-address field?
Show answer
Next-address bits = log2 2048 = 11. W = 7 + 3 + 11 = 21 bits. The store holds 2048 × 21 = 43008 bits.