-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiMem.sv
More file actions
22 lines (18 loc) · 774 Bytes
/
iMem.sv
File metadata and controls
22 lines (18 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* Instruction memory module will read a 64bit address (PC) and output the corresponding instruction */
module iMem (
input wire [63:0] address, // Address input
output reg [31:0] instruction // Instruction output
);
parameter WIDTH = 256;
reg [31:0] memory [0:WIDTH-1]; // Instruction memory array (stores <WIDTH> amount of 32-bit instructions)
/*
Initialize the instruction memory with some values in a file
initial begin
$readmemh("instructions.mem", memory); // Load hex instructions from a file, use $readmemb for binary
end
*/
// Output the instruction at the given address
always @(address) begin
instruction = memory[address[63:2]]; // Address is byte-aligned, so divide by 4
end
endmodule