2023-01-15 21:57:23 +00:00
|
|
|
module flags(
|
|
|
|
input clk,
|
2023-02-17 03:25:05 +00:00
|
|
|
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;
|
|
|
|
|
2023-02-17 03:25:05 +00:00
|
|
|
reg[1:0] flags;
|
2023-01-15 21:57:23 +00:00
|
|
|
|
2023-02-17 03:25:05 +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
|
2023-02-17 03:25:05 +00:00
|
|
|
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
|
2023-02-17 03:25:05 +00:00
|
|
|
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
|
|
|
|
|
2023-02-17 03:25:05 +00:00
|
|
|
assign out = flags;
|
2023-01-15 21:57:23 +00:00
|
|
|
|
|
|
|
endmodule
|
|
|
|
|