I'm implementing MIPS processor using Verilog.
input [31:0] address;
output [31:0] instruction;
reg [31:0] instruction_memory [255:0];
assign instruction = instruction_memory[address[9:2]];
This is an almost complete body of Instruction Memory module.
The thing I cannot understand is why we refer to the instruction in memory using address[9:2]. I mean, why [9:2] ?
I've found an answer, but I cannot understand it. It says:
What bits select the first 256 words? [9:2]!
Can you, please, explain me this detail in some other, more understandable way?
Thank you.
Best Answer
Because MIPS instructions are all 32 bits in length, bits 0 and 1 don't hold any meaning. Therefore instead of looking at
[7:0]
of the address it looks at[9:2]
, which is the translation for instructions.