Verilog generate/genvar in an always block

前端 未结 6 907
鱼传尺愫
鱼传尺愫 2020-12-01 08:19

I\'m trying to get a module to pass the syntax check in ISE 12.4, and it gives me an error I don\'t understand. First a code snippet:

parameter ROWBITS = 4;
         


        
6条回答
  •  醉酒成梦
    2020-12-01 08:49

    If you do not mind having to compile/generate the file then you could use a pre processing technique. This gives you the power of the generate but results in a clean Verilog file which is often easier to debug and leads to less simulator issues.

    I use RubyIt to generate verilog files from templates using ERB (Embedded Ruby).

    parameter ROWBITS = <%= ROWBITS %> ;
    always @(posedge sysclk) begin
      <% (0...ROWBITS).each do |addr| -%>
        temp[<%= addr %>] <= 1'b0;
      <% end -%>
    end
    

    Generating the module_name.v file with :

    $ ruby_it --parameter ROWBITS=4 --outpath ./ --file ./module_name.rv
    

    The generated module_name.v

    parameter ROWBITS = 4 ;
    always @(posedge sysclk) begin
      temp[0] <= 1'b0;
      temp[1] <= 1'b0;
      temp[2] <= 1'b0;
      temp[3] <= 1'b0;
    end
    

提交回复
热议问题