File size: 747 Bytes
2166d7e | 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 | // ROW_MAX: streaming maximum of signed 32-bit values. 'clear' restarts the scan.
module fa_row_max (
input logic clk,
input logic rst_n,
input logic clear,
input logic in_valid,
input logic signed [31:0] in_val,
output logic signed [31:0] max_val
);
logic has;
always_ff @(posedge clk or negedge rst_n) begin
if (!rst_n) begin
has <= 1'b0;
max_val <= '0;
end else if (clear) begin
has <= 1'b0;
max_val <= '0;
end else if (in_valid) begin
if (!has || in_val > max_val) max_val <= in_val;
has <= 1'b1;
end
end
endmodule : fa_row_max
|