-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpc_module.v
49 lines (45 loc) · 1007 Bytes
/
pc_module.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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 13:46:28 12/04/2015
// Design Name:
// Module Name: pc_module
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//a
//////////////////////////////////////////////////////////////////////////////////
module pc_module(
input clk, //clock
input rst,
input wire[5:0] control,
/* Branch */
input branch_flag,
input wire[31:0] branch_target,
output reg[31:0] pc,
output reg ce
);
always @ (posedge clk) begin
if (rst == 1)
ce <= 0;
else
ce <= 1;
end
always @ (posedge clk) begin
if (ce == 0)
pc <= 0;
else if (branch_flag == 1)
pc <= branch_target;
else if (control[0] == 0)
pc <= pc + 4;
end
endmodule