Is there a function which returns the largest value in systemverilog? like max() in c++?

There is no built-in function to compare two numbers and return the largest. There is a max method for arrays that returns the largest element in the array.

You should use the let statement instead of a function to handle values of any type.

let max(a,b) = (a > b) ? a : b;
1 Like