• retagged by
46,131 views
66 66 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 _______.

9 Answers

Best answer
94 94 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 9 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.

6 6 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.

2 2 votes
Ans is 14

We add total no of used addresses ( I type and R type)

 

(8×2^6×2^4)+(x×2^6×2^6)=2^16 { as 2^16 is the total encoding }

by solving we get x = 14
1 1 vote

 

Let there are x instructions of type-R 

R-type instruction format

Opcode(4 bits)

Register (6bits)

Register(6bits)

 

Thus, from 2^4 (=16) instructions "x" instructions are of type-R and left over 4 bit instructions are

(2^4)-x 

 

Now, for type-I instruction format

I-type instruction format

Opcode(6 bits)

Register(6 bits)

Immediate value (4bits)

 

 

In Opcode field we assume as 4bits+2bits i.e., 4bit instructions for I-type are taken form left over 4 bit instructions

i.e. (2^4)-x 

I-type instruction format

                   Opcode                                                      Register                                           Immediate value

     4bits

      2bits

                           6bits

           4bits

 

As per question there are 8 instructions of I-type

=> ((2^4)-x) * (2^2) = 8

(2^4)-x = 8/4

16 - x = 2

x = 14

Therefore there are 14 instructions of R-type  

Answer:
Position:
Show:

Related questions

61 61 votes
5 answers 5 answers
25.3k
25.3k views
Arjun asked Feb 12, 2020
25,329 views
Consider a double hashing scheme in which the primary hash function is $h_1(k)= k \text{ mod } 23$, and the secondary hash function is $h_2(k)=1+(k \text{ mod } 19)$. Ass...
107 107 votes
8 answers 8 answers
43.2k
43.2k views
gatecse asked Feb 14, 2018
43,230 views
A processor has $16$ integer registers $\text{(R0, R1}, \ldots ,\text{ R15)}$ and $64$ floating point registers $\text{(F0, F1}, \ldots , \text{F63)}.$ It uses a $2\text{...
108 108 votes
8 answers 8 answers
33.7k
33.7k views
Akash Kanase asked Feb 12, 2016
33,656 views
Consider a processor with $64$ registers and an instruction set of size twelve. Each instruction has five distinct fields, namely, opcode, two source register identifiers...