How do you plan to solve it?
module minmax4_task (
input [7:0] v0,
input [7:0] v1,
input [7:0] v2,
input [7:0] v3,
output reg [7:0] min_val,
output reg [7:0] max_val
);
// --------- Corrected task ----------
task minmax4;
input [7:0] a, b, c, d;
output [7:0] min_o;
output [7:0] max_o;
reg [7:0] min01, max01;
reg [7:0] min23, max23;
begin
// Pairwise compare (a,b)
// Set max01 as the larger of a and b
max01 = (a > b) ? a : b;
// Set min01 as the smaller of a and b
min01 = (a > b) ? b : a;
// Pairwise compare (c,d)
// Set max23 as the larger of c and d
max23 = (c > d) ? c : d;
// Set min23 as the smaller of c and d
min23 = (c > d) ? d : c;
// Final reduce across pairs
// Set max_o as the larger of max01 and max23
max_o = (max01 > max23) ? max01 : max23;
// Set min_o as the smaller of min01 and min23
min_o = (min01 < min23) ? min01 : min23; // Fixed: should use < for min
end
endtask
// -------------------------------------------------------
// Call the task and assign outputs
reg [7:0] tmin, tmax;
always @(*) begin
minmax4(v0, v1, v2, v3, tmin, tmax); // Fixed: v0 not vo
min_val = tmin;
max_val = tmax;
end
endmodule