GATE CS 2024 Set 2 — Question 61

NAT+2 / -0MediumInstruction FormatsInstructions & Addressing ModesComputer Organization & Architecture

Computer Organization & Architecture → Instructions & Addressing Modes → Instruction Formats

Last updated

Question

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:
OPCODEUNUSEDDST RegisterSRC Register1SRC Register 2
I-type Instruction Format:
OPCODEDST RegisterSRC 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 XX be the number of bits used to encode the UNUSED field, YY be the number of bits used to encode the OPCODE field, and ZZ be the number of bits used to encode the immediate value/address field. The value of X+2Y+ZX + 2Y + Z is ________

Correct answer

34 to 34

Solution

1.Determine the number of bits for the OPCODE field (YY):
  • Total instructions = 150.
  • Instructions are equally divided: 75 R-type and 75 I-type.
  • 1 bit is used to distinguish between types (R-type vs I-type).
  • To represent 75 distinct operations within each type, we need log2(75)=7\lceil \log_2(75) \rceil = 7 bits.
  • Therefore, total bits for the OPCODE field, Y=1+7=8Y = 1 + 7 = 8 bits.
2. Determine the number of bits for register fields:
  • The processor has 50 architectural registers.
  • Bits required to uniquely identify each register = log2(50)=6\lceil \log_2(50) \rceil = 6 bits.
  • All register fields (DST, SRC1, SRC2, SRC) are of equal size, so each is 6 bits.
3. Determine the number of bits for the UNUSED field (XX) from the R-type format:
  • Total instruction length = 32 bits.
  • R-type format: OPCODE+UNUSED+DST Register+SRC Register1+SRC Register2=32\text{OPCODE} + \text{UNUSED} + \text{DST Register} + \text{SRC Register1} + \text{SRC Register2} = 32
  • 8+X+6+6+6=328 + X + 6 + 6 + 6 = 32
  • 26+X=32    X=626 + X = 32 \implies X = 6 bits.
4. Determine the number of bits for the immediate field (ZZ) from the I-type format:
  • I-type format: OPCODE+DST Register+SRC Register+Immediate=32\text{OPCODE} + \text{DST Register} + \text{SRC Register} + \text{Immediate} = 32
  • 8+6+6+Z=328 + 6 + 6 + Z = 32
  • 20+Z=32    Z=1220 + Z = 32 \implies Z = 12 bits.
5. Calculate the final value:
  • X+2Y+Z=6+2(8)+12=6+16+12=34X + 2Y + Z = 6 + 2(8) + 12 = 6 + 16 + 12 = 34.

More questions on Instructions & Addressing Modes

Practice GATE CS PYQs with adaptive difficulty

Timed practice, skill tracking, and AI explanations — free to start.

Start practicing free