summaryrefslogtreecommitdiff
path: root/rtl/core/psr.sv
blob: 2c0d48fc31bc0580d9a3e423e2c6f59867751326 (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
`include "core/uarch.sv"

module core_psr
(
	input  logic     clk,
	                 update_flags,
	                 alu_v_valid,
	input  psr_flags alu_flags,

	output psr_flags flags,
	                 next_flags
);

	always_comb begin
		next_flags = flags;

		if(update_flags) begin
			next_flags = alu_flags;
			if(~alu_v_valid)
				next_flags.v = flags.v;
		end
	end

	always_ff @(posedge clk)
		flags <= next_flags;

	initial flags = 4'b0000;

endmodule