module core_tb_imem #( parameter ADDR_WIDTH = 32 ) ( input logic clk, // Fetch Interface input logic [31:0] if_imem_addr_IF, // Decode Interface output logic [31:0] imem_id_instr_ID ); int assembly_file; int status_file; int error_file; string error_message_file; logic [7:0] imem [0:(1<<(ADDR_WIDTH))-1]; // Fill up memory using the $fopen and $fread syscalls initial begin assembly_file = $fopen("../../../core/testcode/riscv_arithmetic_basic_test_0.bin", "rb"); status_file = $fread( imem, assembly_file ); if (status_file == 0) begin $ferror( assembly_file, error_message_file ); $error("File I/O Error %s", error_message_file); end $display("Memory Contents Initialized"); end // Memory reads, TODO: Should we add a RMASK always_ff @ (posedge clk) begin imem_id_instr_ID[7:0] <= imem[if_imem_addr_IF[ADDR_WIDTH-1:0]+0]; // 4 bytes read into a single word in RISC-V imem_id_instr_ID[15:8] <= imem[if_imem_addr_IF[ADDR_WIDTH-1:0]+1]; // 4 bytes read into a single word in RISC-V imem_id_instr_ID[23:16] <= imem[if_imem_addr_IF[ADDR_WIDTH-1:0]+2]; // 4 bytes read into a single word in RISC-V imem_id_instr_ID[31:24] <= imem[if_imem_addr_IF[ADDR_WIDTH-1:0]+3]; // 4 bytes read into a single word in RISC-V end endmodule