module abs8_func (
input signed [7:0] a,
output [7:0] abs
);
// ---------- Write function here----------
function [7:0]abs8;
input signed [7:0]x;
if(x[7] == 1'b1) begin
abs8 = ~x;
abs8 = abs8 + 1'b1;
end
else begin
abs8 = x;
end
// abs8 = (x < 0) ? -x : x;
endfunction
// Function called here
assign abs = abs8(a);
endmodule