summaryrefslogtreecommitdiff
path: root/rtl/core/control/branch.sv
blob: 59a4f54a1f7bc3fdfea46f236750b315fb328f14 (plain)
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
`include "core/uarch.sv"

module core_control_branch
(
	input  logic       clk,

	input  insn_decode dec,

	input  ctrl_cycle  next_cycle,
	input  logic       issue,
	input  ptr         next_pc_visible,

	output logic       branch,
	output ptr         branch_target
);

	always_ff @(posedge clk) begin
		branch <= 0;
		if(next_cycle == ISSUE && issue) begin
			branch <= dec.ctrl.branch;
			branch_target <= next_pc_visible + dec.branch.offset;
		end
	end

	initial begin
		branch = 1;
		branch_target = {$bits(branch_target){1'b0}};
	end

endmodule