3. Block-Code Technique
To each of the 2K instructions a unique binary bit pattern of
length K is assigned.
A K-to-2K decoder can then be used to decode all the
instructions. For example,
3 to 8 Decoder
Instructio
n 1
Instructio
n 2
Instructio
n 3Instructio
n 4
Instructio
n 5Instructio
n 6Instructio
n 7Instructio
n 8
3 op-code bit
4. • CONSIDER AN 4+12 BIT INSTRUCTION WITH A 4-BIT OP-CODE AND THREE
4-BIT ADDRESSES.
• IT CAN AT MOST ENCODE 16 THREE-ADDRESS INSTRUCTIONS.
• IF THERE ARE ONLY 15 SUCH THREE-ADDRESS INSTRUCTIONS, THEN ONE OF THE
UNUSED OP-CODE CAN BE USED TO EXPAND TO TWO-ADDRESS, ONE-ADDRESS
OR ZERO ADDRESS INSTRUCTIONS.
• AGAIN, THIS EXPANDED OP-CODE CAN ENCODE AT MOST 16 TWO-ADDRESS INSTRUCTIONS. AND
IF THERE ARE LESS THAN 16 SUCH INSTRUCTIONS, WE CAN EXPAND THE OP-CODE FURTHER
Expanding op-code technique
Op-code Address 1 Address 2 Address 3
1111 Op-code Address 1 Address 2
1111 1111 Op-code Address 1
1111 1111 1111 Op-code
5. FEWER BITS ARE USED FOR MOST FREQUENTLY USED INSTRUCTIONS AND MORE FOR THE LEAST
FREQUENTLY USED ONES.
Huffman Encoding
• Given the probability of occurrences of each instruction, it is possible to
encode all the instructions with minimal number of bits, and with the
following property:
1
1/
2
1/1
6
1/1
6
1/1
6
1/1
6
1/
8
1/
8
1/
4
1/
4
1/
4
1/
8
1/
8
1/
2
1/
4
0
1
11
1
1
11
0
0
0 0 0 0
HALT JUMP SHIFT NOT AND ADD STO LOAD
000
0
000
1
001
0
001
1
01
0
01
1
1
0
1
1
6. ADVANTAGE:
• MINIMAL NUMBER OF BITS
DISADVANTAGE:
• MUST DECODE INSTRUCTIONS BIT-BY-BIT, (CAN BE SLOW).
• TO DECODE, MUST HAVE A LOGICAL REPRESENTATION OF THE ENCODED TREE,
AND FOLLOW BRANCHES AS WE DECIPHER BITS
• FACT IS, MOST DECODING IS DONE IN PARALLEL
• GIVES A SPEED ADVANTAGE
Op-Code Encoding, Huffman Codes