30 lines
1.1 KiB
Verilog
30 lines
1.1 KiB
Verilog
`timescale 1ns / 1ps
|
|
|
|
module InstructionMemory (
|
|
input [31:0] address,
|
|
output reg [31:0] instruction
|
|
);
|
|
|
|
always @(*) begin
|
|
case (address[31:2])
|
|
20'd0: instruction <= 32'h20110001; // addi $s1, $zero, 1
|
|
20'd1: instruction <= 32'h00000000;
|
|
20'd2: instruction <= 32'h00000000;
|
|
20'd3: instruction <= 32'h00000000;
|
|
20'd4: instruction <= 32'h00000000;
|
|
20'd5: instruction <= 32'h0c000007; // jal func
|
|
// end:
|
|
20'd6: instruction <= 32'h08000006; // j end
|
|
// func:
|
|
20'd7: instruction <= 32'h20120002; // addi $s2, $zero, 2
|
|
20'd8: instruction <= 32'h00000000;
|
|
20'd9: instruction <= 32'h00000000;
|
|
20'd10: instruction <= 32'h00000000;
|
|
20'd11: instruction <= 32'h00000000;
|
|
20'd12: instruction <= 32'h03e00008; // jr $ra
|
|
default: instruction <= 32'h00000000;
|
|
endcase
|
|
end
|
|
|
|
endmodule
|