IAE Academy

GATE 2024 CS2 Q.61: solution and answer

GATE 2024 · CS2Q.61 · 2 marks · NAT

A processor uses a 32-bit instruction format and supports byte-addressable memory access. The ISA of the processor has 150 distinct instructions. The instructions are equally divided into two types, namely R-type and I-type, whose formats are shown below.

R-type Instruction Format (32 bits total, fields left to right):
| OPCODE | UNUSED | DST Register | SRC Register1 | SRC Register 2 |

I-type Instruction Format (32 bits total, fields left to right):
| OPCODE | DST Register | SRC Register | # Immediate value/address |

In the OPCODE, 1 bit is used to distinguish between I-type and R-type instructions and the remaining bits indicate the operation. The processor has 50 architectural registers, and all register fields in the instructions are of equal size.

Let be the number of bits used to encode the UNUSED field, be the number of bits used to encode the OPCODE field, and be the number of bits used to encode the immediate value/address field. The value of is ______ (answer in integer).

GATE 2024 CS2 question 61: Two instruction-format diagrams, each a horizontal table of boxes summing to 32 bits total width (widths not drawn to…Tap to open full size
Figure from the GATE 2024 CS2 paper. It is part of the question.
Figure description

Two instruction-format diagrams, each a horizontal table of boxes summing to 32 bits total width (widths not drawn to scale, no bit counts marked on the image itself). R-type row (5 boxes, left to right): OPCODE, UNUSED, DST Register, SRC Register1, SRC Register 2. I-type row (4 boxes, left to right): OPCODE, DST Register, SRC Register, # Immediate value/address.

Answer and solution

ANSWER

X + 2Y + Z = 6 + 16 + 12 = 34

Official answer: 34Source: Official answer key, GATE 2024 CS2 (IISc Bengaluru)

  1. Register field size: with 50 architectural registers, each register field needs bits. Since and , each register field (DST, SRC, SRC1, SRC2) is 6 bits.

  2. Instruction split: 150 distinct instructions divided equally into R-type and I-type gives 75 instructions of each type.

  3. OPCODE size : 1 bit of the OPCODE distinguishes R-type from I-type; the remaining bits must encode the operation within a given type, i.e. address 75 distinct operations. We need . Since and , , so .

  4. R-type field sum: .

  5. I-type field sum: .

  6. Compute the answer: .

KEY IDEA

Each register field must hold bits. The OPCODE's Y bits split into 1 type-bit plus operation bits, which must distinguish the 75 instructions within EACH type (not all 150 together), so . The remaining bits in each 32-bit format go to UNUSED (R-type) or the immediate field (I-type).

WATCH OUT FOR

Assuming the OPCODE size only needs to distinguish 150 total instructions (giving Y=8 anyway by coincidence here, but conceptually wrong) or forgetting that the 1 type-bit is already included inside Y, causing double-counting; also using ceil(log2(150))=8 directly on the whole opcode without splitting off the type bit, and separately mis-sizing register fields as ceil(log2(50))=5 or 6 without checking 2^5=32<50.

From the GATE 2024 CS2 paper. Every question of this paper · Download the full paper · All 11 Instructions & addressing questions, with notes

More Instructions & addressing questions