Question

A processor has 64 registers and uses 16-bit instruction format. It has two types of instructions: I-type and R-type. Each I-type instruction contains an opcode, a register name, and a 4-bit immediate value. Each R-type instruction contains an opcode and two register names. If there are 8 distinct I-type opcodes, then the maximum number of distinct R-type opcodes is _______.

Official answer and solution
Official answer
14
From
Official GATE 2020 answer key

Solution

Use the expanding opcode technique to find the maximum number of R-type opcodes.

Instruction format details:

  • Total instruction length = 16 bits.
  • Number of registers = 64   ⟹  \implies register address field = log⁡264=6\log_2 64 = 6 bits.
  • I-type instruction format: Opcode, 1 register (6 bits), 4-bit immediate.
    • Total operand bits = 6+4=106 + 4 = 10 bits.
    • Opcode bits for I-type = 16−10=616 - 10 = 6 bits.
  • R-type instruction format: Opcode, 2 registers (6+6=126 + 6 = 12 bits).
    • Opcode bits for R-type = 16−12=416 - 12 = 4 bits.

Expanding opcode relationship:

  • The R-type opcode is 4 bits long, supporting up to 24=162^4 = 16 bit patterns.
  • Let xx be the number of patterns allocated to R-type instructions.
  • The remaining 16−x16 - x 4-bit patterns can be expanded by 2 additional bits (6−4=26 - 4 = 2) to form 6-bit I-type opcodes.
  • Total possible I-type opcodes = (16−x)×22=(16−x)×4(16 - x) \times 2^2 = (16 - x) \times 4.

Solve for xx:

(16−x)×4=8  ⟹  16−x=2  ⟹  x=14(16 - x) \times 4 = 8 \implies 16 - x = 2 \implies x = 14

Therefore, the maximum number of distinct R-type opcodes is 14.

Final answer

14

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2020 Computer Science and Information Technology (CS)
Question
54 of 65, printed as CS Q.44
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.