title: Verilog - increment local parameter in generate block
body: <p>I'm getting an error in my Verilog generate block, on the line where it says j = j+1; stating `j is an unknown type'</p>
  
  <pre><code>genvar i;
  generate
      localparam integer j = 0;
      for (i = 0; i &lt; BUFFER; i=i+1) begin
          if((i%DATA_WIDTH) &lt; (KERNEL_SIZE-1)) begin
              assign o_input_matrix[((j+1)*DATA_WIDTH)-1:j*DATA_WIDTH] = 
  buffer[((i+1)*DATA_WIDTH)-1:i*DATA_WIDTH];
              j = j+1;
          end
      end
  endgenerate
  </code></pre>
  
  <p>BUFFER, DATA_WIDTH, and KERNEL_SIZE are local parameters I have in my module.</p>
  
  <p>I've been looking at ways I could have a 2nd parameter in my generate block, I've found out that I can only use genvar variables in a for loop, so I couldnt make a 2nd genvar variable for j. </p>
  
  <p>I came across this question:
  <a href="https://stackoverflow.com/questions/9561762/incrementing-multiple-genvars-in-verilog-generate-statement?noredirect=1&amp;lq=1">Incrementing Multiple Genvars in Verilog Generate Statement</a> </p>
  
  <p>I tried basing my code of the 2nd answer, but my situation is slightly different because I'm only incrementing it in an if statement.</p>
  
  <p>Any help would be appreciated.</p>