forked from cyLi-Tiger/Multi-Cycle-CPU-42
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPC.v
52 lines (46 loc) · 1.2 KB
/
PC.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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 2019/12/23 16:47:49
// Design Name:
// Module Name: PC
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module PC(Result,Clk,Reset,Address,stall,stallstall); //En=1可以写,stall=0没有发生lw数据冒险
input Clk;//时钟
input Reset;//是否重置地址。0-初始化PC,否则接受新地址
input[31:0] Result;
input stall,stallstall;
output reg[31:0] Address;
wire En;
assign En=(~stall)&(~stallstall);
initial begin
Address <= 32'h00003000;
end
always @(posedge Clk or negedge Reset)
begin
if(En==1)
begin
if (!Reset) //如果为0则初始化PC,否则接受新地址
begin
Address <= 32'h000003000;
end
else
begin
Address = Result;
end
end
end
endmodule