Verilog ALU操作选择中的组合回路

Verilog ALU操作选择中的组合回路,verilog,cpu,alu,Verilog,Cpu,Alu,我正在修改一个CPU设计以在iCE40和FPGA上运行,特别是修改ALU以利用硬件DSP块。我已将DSP块配置为异步加法器/减法器,并希望能够通过更改加法器模块的输入来选择是否对每条指令进行加法或减法。由于ALU在始终块中运行case语句,因此当前实现导致组合循环,由于时序分析失败而阻止合成: 在dsp_添加_sub.v中: // behaves as a subtractor if 'sub' is 1; module dsp_add_sub(input1, input2, sub, out)

我正在修改一个CPU设计以在iCE40和FPGA上运行,特别是修改ALU以利用硬件DSP块。我已将DSP块配置为异步加法器/减法器,并希望能够通过更改加法器模块的输入来选择是否对每条指令进行加法或减法。由于ALU在
始终
块中运行
case
语句,因此当前实现导致组合循环,由于时序分析失败而阻止合成:

在dsp_添加_sub.v中:

// behaves as a subtractor if 'sub' is 1;
module dsp_add_sub(input1, input2, sub, out);
    input [31:0] input1;
    input [31:0] input2;
    input sub;

    output [31:0] out;
    
    (...)
在alu.v中:

module alu(ALUctl, A, B, ALUOut, ...);
    input [6:0] ALUctl;
    input [31:0] A;
    input [31:0] B;
    output reg [31:0] ALUOut;

    reg dsp_sub;
    reg [31:0] dsp_out;
    dsp_add_sub Add_Sub(A, B, dsp_sub, dsp_out);

    always @(ALUctl, A, B) begin
        case  (ALUctl[3:0])
            add_op: begin
                dsp_sub = 1'b0;
                ALUOut = dsp_out;
            end

            sub_op: begin
                dsp_sub = 0'b0;
                ALUOut = dsp_out;
            end
            (...)
        endcase
    end

我的理解是,在
始终
块外定义
dsp\u sub
并在块内分配给它会创建一个推断锁存器,yosys必须将其作为iCE40中的组合循环来实现。我怎样才能绕过这个问题,在
始终
块中选择加法或减法运算?

基本CPU设计使用A+B和A-B,但我正在合成的特定芯片具有特殊的硬件块,可以配置为加法器/减法器,以使这些运算更快,消耗更少的逻辑单元。我用一个做加法器,一个做减法器,但是我想用一个做选择行,因为它们不是同时使用的