1

次のプロトタイプを使用して、単純なプログラム カウンター加算器を実装しています。

module program_counter(input        enable_count,
                       input        enable_overwrite,
                       input[31:0]  overwrite_value,
                       output[31:0] out);

Icarus Verilog でシミュレートすると、上書きが無効になり、カウントが有効になる最初のティックで無限ループが発生するため、PC 加算器の出力 (PC + 4) が内部レジスタに供給されます。

この問題を、D フリップフロップを 1 ビット レジスタとして使用する基本的なコードに単純化しました。

module register(input in, input set, output out);

    wire not_in;
    wire q0;
    wire not_q0;
    wire not_q;

    nand (q0, in, set);

    not  (not_in, in);
    nand (not_q0, not_in, set);

    nand (out, q0, not_q);
    nand (not_q, not_q0, out);

endmodule

module test;

    reg  clock;
    reg  in;
    wire out;
    wire not_out;

    xor (x_out, out, 1);                // add
    or  (muxed_out, x_out, in);         // mux

    register r(muxed_out, clock, out);

    initial
    begin
        $dumpfile("test.vcd");
        $dumpvars(0, test);

        $display("\tclock,\tin,\tout");
        $monitor("\t%b,\t%x,\t%b",
                 clock, in, out);

        #0 assign in = 1;               // erase register
        #0 assign clock = 1;

        #1 assign in = 0;
        #1 assign clock = 0;

        #2 assign clock = 1;
        #3 assign clock = 0;
        #4 assign clock = 1;
    end

endmodule

シミュレーションがスタックした後、VCD 出力は状態の変化を示しません。

私の推測では、特定の目盛りで、加算器は常に異なる値を供給している (継続的に加算している) ため、安定していないため、シミュレーターは値が修正されるのを待ってスタックします。

このデザインは正しいですか (つまり、合成でき、動作するはずです)。

4

1 に答える 1