summaryrefslogtreecommitdiff
path: root/rtl/core/fetch/fetch.sv
blob: 9b21dd2057ea63aeb49e23534d115a4eaea8c7af (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
31
32
33
34
35
`include "core/uarch.sv"

module core_fetch
#(parameter PREFETCH_ORDER=2)
(
	input  logic       clk,
	                   stall,
	                   flush,
	                   fetched,
	input  logic[31:0] fetch_data,

	output logic       fetch,
	output logic[31:0] insn,
	output logic[29:0] insn_pc,
	                   addr
);

	logic[29:0] next_pc;

	core_prefetch #(.ORDER(PREFETCH_ORDER)) prefetch
	(
		.*
	);

	always_ff @(posedge clk)
		if(flush)
			addr <= next_pc;
		else if(fetched)
			addr <= addr + 1;

	initial begin
		addr = 0;
	end

endmodule