-
Notifications
You must be signed in to change notification settings - Fork 1
/
pc_reg.v
35 lines (30 loc) · 830 Bytes
/
pc_reg.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
`include "defines.v"
module pc_reg(input wire clk,
input wire rst,
input wire branch_flag_i,
input wire [`RegBus] branch_target_address_i,
output reg [`InstAddrBus] pc,
output reg ce);
always @(posedge clk) begin
if (ce == `ChipDisable) begin
pc <= 32'h00000000;
end
else begin
/*????????????????????????????????????????????????+4*/
if (branch_flag_i == `Branch) begin
pc <= branch_target_address_i;
end
else begin
pc <= pc+4'h4;
end
end
end
always @(posedge clk) begin
/*reset????????????????*/
if (rst == `RstEnable) begin
ce <= `ChipDisable;
end else begin
ce <= `ChipEnable;
end
end
endmodule