title: Width independent functions
body: <p>Is it possible to write a function that can detect the input data width automatically? For example, consider the parity function below:
  </p>
  
  <pre><code>function parity;
    input [31:0] data;
    parity = ^ data;
  endfunction
  </code></pre>
  
  <p>When <code>parity(data)</code> is called, the input data should be limited to 32 bits.</p>
  
  <p>Alternatively, one could write a macro, such as  <code>`PARITY(data)</code> in which the system function <code>$bits</code> can detect the width of data and make the macro width-independent. Is it possible to have the same flexibility for functions?</p>
  
  <p>Edit: I need my code to be synthesizable.</p>