-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIF.v
67 lines (54 loc) · 1.33 KB
/
IF.v
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
`include "lib/defines.vh"
module IF(
input wire clk,
input wire rst,
input wire [`StallBus-1:0] stall,
input wire flush,
input wire [31:0] new_pc,
input wire [`BR_WD-1:0] br_bus,
output wire [`IF_TO_ID_WD-1:0] if_to_id_bus,
output wire inst_sram_en,
output wire [3:0] inst_sram_wen,
output wire [31:0] inst_sram_addr,
output wire [31:0] inst_sram_wdata
);
reg [31:0] pc_reg;
reg ce_reg;
wire [31:0] next_pc;
wire br_e;
wire [31:0] br_addr;
assign {
br_e,
br_addr
} = br_bus;
always @ (posedge clk) begin
if (rst) begin
pc_reg <= 32'hbfbf_fffc;
end
else if (stall[0]==`NoStop) begin
pc_reg <= next_pc;
end
end
always @ (posedge clk) begin
if (rst) begin
ce_reg <= 1'b0;
end
else if (br_e) begin
ce_reg <= 1'b1;
end
else if (stall[0]==`NoStop) begin
ce_reg <= 1'b1;
end
end
assign next_pc = //flush ? new_pc :
br_e ? br_addr :
pc_reg + 32'h4;
assign inst_sram_en = ce_reg;
assign inst_sram_wen = 4'b0;
assign inst_sram_addr = pc_reg;
assign inst_sram_wdata = 32'b0;
assign if_to_id_bus = {
ce_reg,
pc_reg
};
endmodule