50 lines
1001 B
Verilog
50 lines
1001 B
Verilog
`timescale 1ns / 1ps
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
// Company: nope
|
|
// Engineer: Jose
|
|
//
|
|
// Create Date: 02/20/2026 09:21:52 AM
|
|
// Design Name: Instruction Memory
|
|
// Module Name: imem
|
|
// Project Name: riscv-ac
|
|
// Target Devices: Artix 7
|
|
// Tool Versions: 2025.2
|
|
// Description: Stores instructions
|
|
//
|
|
// Dependencies:
|
|
//
|
|
// Revision: 1.0
|
|
// Revision 0.01 - File Created
|
|
// Additional Comments:
|
|
//
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
module imem(
|
|
input clk,
|
|
input [31:0] address,
|
|
input we,
|
|
input [31:0] write_data,
|
|
input [7:0] write_addr,
|
|
output [31:0] instruction
|
|
);
|
|
|
|
reg [31:0] memory[0:255];
|
|
reg [31:0] ir;
|
|
|
|
integer i;
|
|
initial begin
|
|
for (i = 0; i < 256; i = i + 1) begin
|
|
memory[i] = 32'b0;
|
|
end
|
|
end
|
|
|
|
always @(posedge clk) begin
|
|
if(we)
|
|
memory[write_addr] <= write_data;
|
|
ir <= memory[address[9:2]];
|
|
end
|
|
|
|
assign instruction = ir;
|
|
|
|
endmodule
|