retagged by
28,561 views
24 votes
24 votes
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 _______.
retagged by

6 Answers

Best answer
49 votes
49 votes

Instruction Length: $16$ bits

To distinguish among $64$ registers, we need $\log_2(64) = 6$ bits

I-type instruction format:

$\begin{array} {|c|c|c|} \hline \text{Opcode} & \text{Register} & \text{Immediate Value} \\\hline  \end{array}$

R-type instruction format:

$\begin{array} {|c|c|c|} \hline \text{Opcode} & \text{Register} & \text{Register} \\\hline  \end{array}$

Maximum possible encodings  $= 2^{16}$ 

It is given that there are $8$ I-type instructions. Let's assume the maximum R-type instructions to be $x$.

Therefore, $(8\times 2^{6} \times 2^{4}) + (x \times 2^6 \times 2^6) = 2^{16}$

$\implies x = 16-2 = 14$

edited by
9 votes
9 votes
Here in the question, they mention that the processor follows the fixed-length instruction format and the length of every instruction is 16 bit.

No. of Registers = 64. So, No of bits requires for register identification is 6

I Type : OPCODE | 6bit | 4 bit      [6-bit register and 4-bit immdate]

So Opcode : 16-(6+4)=6 bit             

R Type : OPCODE | 6bit | 6 bit     [6-bit register and 6-bit register]

So Opcode : 16-(6+6)=4 bit

 

Now, We have to use expand opcode technique. In this technique, we have to start with instruction which contains fewer bits for the opcode. R Type contains 4-bit opcode so we start with R type instruction.

Suppose there is X number of R type instruction.

So $2^{4}$ - X opcode remains after all opcode assignment of R type instructions.

So maximum [ $2^{4}$ - X ] x 2 instructions possible for I type.

That's why,

 [ $2^{4}$ - X ] x 2 = 8

 $2^{4}$ - X=4

X=16-4

X=14
7 votes
7 votes

We have total 64 registers: bits required for representation of 64 registers=6 bits

Given: 16-bit instruction format.

I-type instruction format:

Oppose Register

Immediate Value

6 bits   6 bits    4 bits

So total possible opcodes for I-type instruction are 2^6= 64 opcodes.

Out of 64 opcodes, we utilise 8 opcodes for I-type instruction, so we have 56 remaining opcodes.

 

R-type instruction format:

Opcodes Register Register
  4 bits   6 bits   6 bits

 

Consider:

Now, if my R-type instruction had 4 bit opcode and I type instruction had 6 bit opcode, then we would be utilizing two extra bits for opcodes. So total possible opcodes for I-type would have been 2^4( All possible combination of 4 bit opcode) * 2^2( All possible combinations of 2 extra bits used)

 

Now here, we had 6 bit opcode for I-type instruction and R-type instruction has 4 bit opcode, that is we utilised two bit from opcode in instruction format. Our remaining number of instructions are 56 and all possible combinations of 2 bits are 4. So we do opposite of the above mentioned scenario i.e. divide by 4 

So possible opcodes for R-type instruction= 56/4

So answer would be 14.

4 votes
4 votes

I-type 

6-bit opcode 6-bit register 4-bit immediate

R-type

4-bit opcode 6-bit register 6-bit register

•Now in opcode expand technique we start with 

the instruction which have lesser bit in opcode so R-type.

•we have 4 bit for opcode in R -type therefore we can say that there are 16 different opcodes are possible but if we do that then there is a problem

•because we have 6 bit opcode in I-type therefore out of 6 we used 4 for R-type and now we left with only 2 bits therefore possible opcodes for I-type is 4 but we have been already told that there are 8 I-type opcodes.

•which implies that out of 16 opcode of R-type there are some combination which is not used 

•  therefore  “16- X ”is the combination which is not used and“ x” is the number of R-type opcode

• as we are using operand expanding

Therefore 16-x(the number of not used combination)*4(the number of combination possible with 2 bits in I-type)=8(the number of I-type opcodes)

• (16-x)*4=8

•x=14

correct me if I'm wrong.

Answer:

Related questions