-
Notifications
You must be signed in to change notification settings - Fork 2
/
fetch.sv
60 lines (50 loc) · 1.04 KB
/
fetch.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
module fetch #(
parameter DATA_WIDTH = 32
)(
input logic clk,
input logic reset,
input logic enable,
input logic PCSrcE,
input logic JALRinstrE,
input logic [DATA_WIDTH-1:0]ALUResultE,
input logic [DATA_WIDTH-1:0] PCTargetE,
output logic [DATA_WIDTH-1:0] instrF,
output logic [DATA_WIDTH-1:0] PCPlus4F,
output logic [DATA_WIDTH-1:0] PCF
);
PC counter(
.clk(clk),
.reset(reset),
.enable(enable),
.ALUResultE(ALUResultE),
.PCTargetE(PCTargetE),
.PCSrcE(PCSrcE),
.JALRinstr(JALRinstrE),
.PCPlus4F(PCPlus4F),
.PCF(PCF)
);
logic [DATA_WIDTH-1:0] memInstr;
inst_mem memory(
.A(PCF),
.RD(memInstr)
);
logic hit;
logic [DATA_WIDTH-1:0] cacheInstr;
/*direct_mapped cache (
.clk(clk),
.address(PCF),
.datain(memInstr),
.WE(~hit),
.hit(hit),
.dataout(cacheInstr)
);*/
Nway_assos cache (
.clk(clk),
.address(PCF),
.datain(memInstr),
.WE(~hit),
.hit(hit),
.dataout(cacheInstr)
);
assign instrF = hit ? cacheInstr : memInstr;
endmodule