-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp_i_cache.sv
78 lines (67 loc) · 2.07 KB
/
temp_i_cache.sv
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
`timescale 1ns / 1ps
`include "riscv_core.svh"
module temp_i_cache#(
parameter DEPTH = 512,
parameter LINE_SIZE = 2
)(
input clk, reset,
input [`ADDR_WIDTH-1:0] read_addr [2],
input read_addr_valid [2],
input ext_stall, ext_flush,
input [`ADDR_WIDTH-1:0] fetch_addr,
input fetch_addr_valid,
input [31:0] fetched_data,
output logic [31:0] read_instr [2],
output logic valid_read [2],
output logic miss [2],
output logic int_stall,
output logic [`ADDR_WIDTH-1:0] prev_read_addr [2]
);
assign int_stall = ext_stall || fetch_addr_valid;
assign miss[0] = 0;
assign miss[1] = 0;
//logic [31:0] mem [1028];
genvar i;
generate
for(i = 0; i < 2; i++) begin
always_ff @(posedge clk) begin
if(reset || ext_flush) begin
valid_read[i] <= 0;
//read_instr[i] <= 'h23;
prev_read_addr[i] <= 0;
end else if(~ext_stall) begin
if(read_addr_valid[i]) begin
valid_read[i] <= read_addr_valid[i];
//read_instr[i] <= mem[read_addr[i]/4];
prev_read_addr[i] <= read_addr[i];
end else begin
valid_read[i] <= 0;
//read_instr[i] <= 'h23;
prev_read_addr[i] <= 0;
end
end
end
end
endgenerate
logic [31:0] dout [2];
logic [9:0] addr [2];
logic we [2];
logic [31:0] din [2];
always_comb begin
addr[0] = fetch_addr_valid ? fetch_addr[9:0] : read_addr[0];
addr[1] = fetch_addr_valid ? 0 : read_addr[1];
we[0] = fetch_addr_valid;
we[1] = 0;
din[0] = fetched_data;
din[1] = 0;
end
bram_block #(.DEPTH(1024)) CACHE(
.clk,
.addr,
.we,
.din,
.dout
);
assign read_instr[0] = dout[0];
assign read_instr[1] = dout[1];
endmodule