title: Non-static loop limit exceeded
body: <p>I want to implement the K&amp;R algorithm for hamming weight calculation of 256 bit vector. I have written my code in vhdl as:</p>
  
  <pre><code>entity counter_loop is
      Port ( dataIn : in  STD_LOGIC_VECTOR (255 downto 0);
                dataOut : out STD_LOGIC_VECTOR (8 downto 0);
             threshold : in  STD_LOGIC_VECTOR (8 downto 0);
             clk : in  STD_LOGIC;
             flag : out  STD_LOGIC);
  end counter_loop;
  
  architecture Behavioral of counter_loop is
      signal val : STD_LOGIC_VECTOR (255 downto 0) := X"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
  begin
      process (clk)
          variable count : STD_LOGIC_VECTOR (8 downto 0):= "000000000";       
      begin
          flag &lt;= '0';
          val &lt;= dataIn;
          --if(clk'event and clk = '1') then 
              while (val &gt; 0) loop
                  count := count+1;
                  val &lt;= (val and (val-1));
                  if (count &gt; threshold) then
                      flag &lt;= '1';
                  end if;
              end loop;
                  dataOut &lt;= count;
          --end if;
      end process;
  end Behavioral;
  </code></pre>
  
  <p>But, while synthesizing it using Xilinx, the error comes up as </p>
  
  <p>Line 53: Non-static loop limit exceeded</p>
  
  <p>Any clues please?</p>
  
  <p>P.S: Line 53 is - while (val > 0) loop</p>