blob: 740be8a6b416ac396db05f5fae61e97df7deb71f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
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
|