In: Electrical Engineering
Example:
A 3-address computer has 40 instructions, 16 Registers, and 256KB memory. Assume each instruction has three operands. Two registers and the third operand is a direct address location of a memory. Find minimum size of PC, MAR, MDR, IR.
Solution:
OPCODE R1, R2, address
OPCODE is 6 bits since 2^6>40
Register field is 4 bits since 2^4 =16
Memory field is 18 bits since 2^18=256K
Instruction length =6+4+4+18=32 bits
MDR=32 bits
IR=32 bits
MAR=18
PC=18
Please explain
We'll analyse the solution line by line.
OPCODE R1, R2, address: As given in the question.
OPCODE is 6 bits since 2^6>40: We need bits so that we can select our complete 40 sets of opcodes for the different operation. Thus, our bits should be at least 40. Consequently, we need minimum 6 bits address.
Register field is 4 bits since 2^4 =16: Our computer has 16 different registers which can be selected, thus we need minimum 4 bits to select 16 different registers.
Memory field is 18 bits since 2^18=256K: Generally, we assume memory organization to be byte-addressable which has also been done here i.e every segment is of one byte and there are total 256K segments. Now, to select 256*1024 different locations we need 2^18 = {256*1024 } bits.
Instruction length =6+4+4+18=32 bits: Thus, our total instruction length becomes 6(opcode) + 2*4(two register bits) + 18(memory address).
MDR=32 bits: Memory data register(MDR) stores the word length of data being transferred. Thus it is 4bytes(1 word in modern architecture) or 32 bits.
IR = 32 bits: it holds the current instruction being executed thus it is equal to instruction length = 32 bits.
MAR = 18bits Memory address register(MAR) stores the memory address which is 18 bits in length as discussed.
PC=18 bits It denotes the point where our computer is, in its program sequence. Also known as PROGRAM COUNTER. Our code is stored in memory thus the program counter will point to a memory address which is 18 bits in length.