Verilog generate/genvar in an always block

前端 未结 6 888
鱼传尺愫
鱼传尺愫 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:54

    To put it simply, you don't use generate inside an always process, you use generate to create a parametrized process or instantiate particular modules, where you can combine if-else or case. So you can move this generate and crea a particular process or an instantiation e.g.,

    module #(
    parameter XLEN = 64,
    parameter USEIP = 0
    )
    (
     input clk,
    input rstn,
    input [XLEN-1:0] opA,
    input [XLEN-1:0] opB,
    input [XLEN-1:0] opR,
    input en
    );
    
    generate 
    case(USEIP)
    0:begin
    always @(posedge clk or negedge rstn)
    begin
    if(!rstn)
    begin
     opR <= '{default:0};
    end
    else
    begin
    if(en)
     opR <= opA+opB;
    else
    opR <= '{default:0};
    end
    end
    end
    1:begin
      superAdder #(.XLEN(XLEN)) _adder(.clk(clk),.rstm(rstn), .opA(opA), .opB(opB), .opR(opR), .en(en));
    end
    endcase
    
    endmodule
    

提交回复
热议问题