retagged by
23,967 views
66 votes
66 votes
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{- byte}$ instruction format. There are four categories of instructions: $\text{Type-1, Type-2, Type-3},$ and $\text{Type-4. Type-1}$ category consists of four instructions, each with $3$ integer register operands $\text{(3Rs). Type-2}$ category consists of eight instructions, each with $2$ floating point register operands $\text{(2Fs). Type-3}$ category consists of fourteen instructions, each with one integer register operand and one floating point register operand $\text{(1R+1F). Type-4}$ category consists of $\text{N}$ instructions, each with a floating point register operand $\text{(1F)}.$

The maximum value of $\text{N}$ is _________.
retagged by

7 Answers

Best answer
96 votes
96 votes
We have $\text{2-byte}$ instruction format. So, total number of instruction encodings $=2^{16}$

PS: This is not the number of different instructions but different encodings; a single instruction can have different encodings when the address part differs.

No. of bits taken by an integer operand $(16$ possible integer registers$) =\log_2 16 = 4.$

No. of bits taken by a floating point operand $(64$ possible floating point registers$) =\log_2 64 = 6.$

No. of encodings consumed by Type $1$ instructions $=4 \times 2^{3 \times 4} = 2^{14}.$

No. of encodings consumed by Type $2$ instructions $=8 \times 2^{2 \times 6} = 2^{15}.$

No. of encodings consumed by Type $3$ instructions $=14 \times 2^{(4+6)} = 14336.$

No. of encodings left for Type $4 =2^{16} - (2^{14}+2^{15}+14336) = 2048.$

No. of different instructions of Type $4 = \frac{2048}{64} = 32.$
edited by
116 votes
116 votes

Answer: 32 Instructions


Explanation:

Given,

16 Integer registers. So, we need $4$ bits to address any one of them.

64 Floating point registers. This requires $6$ bits to uniquely identify them.

Each instruction is $16$ bits long.

Type 1 Instructions: 

4 instructions, each with 3 integer operands. 

The 3 integers, each requires $4$ bits. So, $4*3$ bits for operands. We are left with $16 - 12 = 4$ bits.

With $4$ bits, $2^4 = 16$ opcodes are possible. Out of these we used $4$ opcodes. i.e $2$ bits. Let's say first two bits are fixed to $00$ and next two bits are used for $4$ different Type1 instructions.

$00\ 00\ ...$

$00\ 01\ ...$

$00\ 10\ ...$

$00\ 11\ ...$

Type 2 Instructions: 

$8$ instructions, each with $2$ floating point register operands. 

Here we need $6*2$ bits for operands, and remaining $16 - 12 = 4$ bits are left for opcodes.

So using these 4 bits, we need to get $8$ opcodes.

Here we can't use $00\ ...$ for any opcode since it will not distinguish Type 2 from Type 1. So, we are left with $12$ opcodes. And we are going to use  $8$ out of these $12$ for type 2 instructions.

$01\ 00\ ...$

$01\ 01\ ...$

$01\ 10\ ...$

$01\ 11\ ...$

$10\ 00\ ...$

$10\ 01\ ...$

$10\ 10\ ...$

$10\ 11\ ...$

Type 3 Instructions: 

$14$ instructions, with $1$ integer and $1$ floating type operand.

$4 + 6 = 10$ bits required for opcodes, remaining $16 - 10 = 6$ bits available for use in opcode.

The only valid combination left for this first $2$ bits is $11\ ...$. Rest have been used in Type1 and Type2 instructions.

So, we are left with $4$ bits for opcodes. With these $4$ bits we can have $2^4 = 16$ opcodes, out of which $14$ are required. So, we use all except last two opcodes:

$11\ 00\ 00\ ...$

$11\  ...$

$11\ 11\ 01\ ...$

These two opcodes are still left unassigned.

$11\ 11\ 10\ ...$

$11\ 11\ 11\ ...$

Type 4 Instructions: 

$\mathbf{N}$ instructions, each with $1$ floating point operand.

We have $16 - 6 = 10$ bits for opcode. Out of $10$ bits, first $6$ bits can be either one of the two left opcodes(above). And any combination for remaining $4$ bits.

So we have $2 * 2^4$ opcodes. So, $\mathbf{N = 32}$. 

19 votes
19 votes

16-bit instruction
16-instruction register---4-bit
64 floating point  register--6-bit

1.Type 1.

4 Instruction each with 3-integer register.

Total binary no. consumed=4*2^12=2^14

2.Type 2.

8 Instruction each with 2-floating point register.

Total binary no. consumed=8*2^12=2^15

3.Type 3

4 Instruction each with one integer and one floating point register.

Total binary no. consumed =14*2^10=14*2^10

4.Type  4

N instruction each with one floating point register

Total binary no. consumed=N*2^6=N*2^6

Total binary no. avaiable=Total binary no. consumed by instructions to get max value of N

2^16=2^14+2^15+14*2^10+N*2^6

N=32

1 votes
1 votes

following answer is wrong ...it should be 256...In type2 there are 2 floating point register which will eat up 2^12 combination and answer will be 256

edited by
Answer:

Related questions