1

モジュールに整数値を渡そうとしていますが、IFステートメントがパラメーターで機能しません。次のエラーがスローされます。私はVerilogを初めて使用するので、これを機能させる方法がわかりません。

Error (10200): Verilog HDL Conditional Statement error at clock_divider.v(17): 
cannot match operand(s) in the condition to the corresponding edges in the enclosing
event control of the always construct

clock_divider.v モジュール

module clock_divider (clockHandler, clk, rst_n, clk_o);

parameter DIV_CONST = 10000000 ;  // 1 second
parameter DIV_CONST_faster = 10000000 / 5;
input clockHandler;
input clk;
input rst_n;

output reg clk_o;

reg [31:0] div;
reg en;
integer div_helper = 0;

always @ (posedge clk or negedge rst_n)
begin
    if(clockHandler == 0)
    begin div_helper = DIV_CONST;
    end

    else
    begin div_helper = DIV_CONST_faster;
    end

    if (!rst_n)
    begin div <= 0;
          en <= 0;
    end

    else
    begin
        if (div == div_helper)
        begin div <= 0;
              en <= 1;
        end

        else
        begin div <= div + 1;
              en <= 0;
        end
    end
end

always @ (posedge clk or negedge rst_n)
begin
if (!rst_n)
begin
    clk_o <= 1'b0;
end
else if (en)
    clk_o <= ~clk_o;
end

endmodule

main.v モジュール

reg clockHandler = 1;

// 7-seg display mux
always @ (*)
begin
    case (SW[2:0])
        3'b000: hexdata <= 16'h0188;
        3'b001: hexdata <= register_A ;
        3'b010: hexdata <= program_counter ;
        3'b011: hexdata <= instruction_register ;
        3'b100: hexdata <= memory_data_register_out ;
        3'b111: hexdata <= out;   
        default: hexdata <= 16'h0188;
    endcase

    if(SW[8] == 1)
    begin
      clockHandler = 1;
    end
    else
    begin
      clockHandler = 0;
    end
end

HexDigit d0(HEX0,hexdata[3:0]);
HexDigit d1(HEX1,hexdata[7:4]);
HexDigit d2(HEX2,hexdata[11:8]);
HexDigit d3(HEX3,hexdata[15:12]);


clock_divider clk1Hzfrom50MHz (
                clockHandler,
                CLOCK_50,
                KEY[3],
                clk_1Hz
                );
4

4 に答える 4

4

if(reset)非同期リセットを使用している場合、verilog の always ブロックの最初のステートメントは用語でなければならないというのが私の理解です。

したがって、フロップ構造は常に次のようになります。

always @ (posedge clk or negedge rst_n) begin
   if(~rst_n) begin
       ...reset statements...
   end else begin
       ...all other statements...
   end
end

したがって、リセットの実行には関係ないため、if(clockHandler==0)ブロックをステートメント内に移動する必要があります。else個別の組み合わせの always ブロックに移動することをお勧めします。これは、always ブロック内にブロッキング ステートメントと非ブロッキング ステートメントを混在させることは、自分が何をしているのかを本当に理解している場合を除き、一般的には良い考えではないためです。あなたの場合でも大丈夫だと思います。

于 2013-06-03T03:48:22.073 に答える
0

これはコンパイル エラーまたは合成エラーですか? 同じコードを使用して、正常にコンパイルされるかどうかを確認しましたが、エラーが発生しました。また、「=」ではなく同期ブロック内で「<=」を使用することをお勧めします

于 2013-06-05T07:01:12.410 に答える