1
0
Fork 0
2023-fpga-computer/src/sap2/flags.v

37 lines
680 B
Coq
Raw Permalink Normal View History

2023-01-15 21:57:23 +00:00
module flags(
input clk,
input rst,
2023-01-15 21:57:23 +00:00
input[7:0] a,
input[7:0] b,
input[7:0] c,
input load_a,
input load_b,
input load_c,
output[1:0] out
);
localparam FLAG_Z = 1;
localparam FLAG_S = 0;
reg[1:0] flags;
2023-01-15 21:57:23 +00:00
always @(negedge clk, posedge rst) begin
if (rst) begin
flags <= 2'b0;
end else if (load_a) begin
flags[FLAG_Z] <= (a == 0) ? 1'b1 : 1'b0;
flags[FLAG_S] <= (a[7] == 1) ? 1'b1 : 1'b0;
2023-01-15 21:57:23 +00:00
end else if (load_b) begin
flags[FLAG_Z] <= (b == 0) ? 1'b1 : 1'b0;
flags[FLAG_S] <= (b[7] == 1) ? 1'b1 : 1'b0;
2023-01-15 21:57:23 +00:00
end else if (load_c) begin
flags[FLAG_Z] <= (c == 0) ? 1'b1 : 1'b0;
flags[FLAG_S] <= (c[7] == 1) ? 1'b1 : 1'b0;
2023-01-15 21:57:23 +00:00
end
end
assign out = flags;
2023-01-15 21:57:23 +00:00
endmodule