title: Calling Function in Verilog
body: <p>When I called the function, it can not enter the <code>if</code> block , every time it can enter <code>else</code> block. And every time returns  <code>4'b1111</code> from function.
  I try to print <code>[3:0] data</code>. It gives me "xxxx".
  How can I fix this problem.</p>
  
  <pre><code>module workout(DATA1, OPCODE , OUTPUT);
  
  input [7:0] DATA1;
  
  input [3:0] OPCODE;
  
  output reg [7:0] OUTPUT;
  
  initial OUTPUT = func_call(DATA1);
  
  
  function [3:0] func_call;
  input [3:0]data;
  begin
  
  if(data[3:0] == 4'b0001)    
          func_call= 4'b0011;
  else 
          func_call= 4'b1111;
  
  endfunction
  </code></pre>