1

私の課題は、単純な 2 から 4 のデコーダーをコーディングし、考えられる結果と波形を表示することです。

コンパイラとして Icarus Verilog (iVerilog) と一緒に gEDA スイートを使用し、波形には GTKWave を使用しています。

Verilog でのコーディングや gEDA スイートでの作業は初めてです。グーグルから、このデザインフローに従う必要があるようです:

  1. 実装したいデザインについて考えます。私の場合、デコーダー
  2. VHDL/Verilog でデザインを実装します。
  3. VHDL/Verilog でテストベンチを実装します。
  4. iVerilog を使用してデザイン ファイルとテストベンチ ファイルをコンパイルする
  5. テストベンチと .vcd ダンプ ファイルを使用して、GTKWave を使用して波形を表示します。

テストベンチ ファイルがコンパイルされず、理由がわかりません。いくつかのバリエーションを試しましたが、エラーが発生し続けます。どんな助けでも大歓迎です。ありがとうございました。

ここに私のデザインファイルコードがあります:

// 2 to 4 Decoder
// File Name: decoder.v

module decoder(X,Y,E,Z);
    input X,Y,E;
    output [0:3]Z;
    wire [0:3]Z;
    wire X1, Y1;

    not
        inv1(X1,X),
        inv2(Y1,Y);
    and
        and1(Z[0],X1,Y1,E),
        and2(Z[1],Y1,X,E),
        and3(Z[2],Y,X1,E),
        and4(Z[3],X,Y,E);
endmodule

ここに私のテストベンチコードがあります:

module decoder_tb;
    input X,Y,E;
    output [0:3]Z;
    //wire [0:3]Z;
    //wire X1, Y1;  

    // should create .vcd dump file for GTKWave
    initial
        begin
            $dumpfile("decoder.vcd");
            $dumpvars();    
        end

    decoder decode(X,Y,E,Z);
    initial 
        begin
            $display($time,"<< Z[0]=%d   Z[1]=%d   Z[2]=%d   Z[3]=%d >>", Z[0] , Z[1] , Z[2] , Z[3] );  
        end 

    initial 
        begin 
         #0
         X = 0; Y = 0; E = 1; 
         #5 
         X = 0; Y = 1; E = 1;
         #10 
         X = 1; Y = 0; E = 1;
         #15 
         X = 1; Y = 1; E = 1;
        end 
endmodule

私が使用している端末のコマンドは次のとおりです。

iverilog -o decoder.vvp decoder.v decoder_tb.v
gtkwave decoder.vcd

編集:正確なエラーメッセージは次のとおりです

aj@aj:~/verilogCode$ iverilog -o decoder.vvp decoder.v decoder_tb.v
decoder_tb.v:26: error: X is not a valid l-value in decoder_tb.
decoder_tb.v:6:      : X is declared here as wire.
decoder_tb.v:26: error: Y is not a valid l-value in decoder_tb.
decoder_tb.v:6:      : Y is declared here as wire.
decoder_tb.v:26: error: E is not a valid l-value in decoder_tb.
decoder_tb.v:6:      : E is declared here as wire.
decoder_tb.v:28: error: X is not a valid l-value in decoder_tb.
decoder_tb.v:6:      : X is declared here as wire.
decoder_tb.v:28: error: Y is not a valid l-value in decoder_tb.
decoder_tb.v:6:      : Y is declared here as wire.
decoder_tb.v:28: error: E is not a valid l-value in decoder_tb.
decoder_tb.v:6:      : E is declared here as wire.
decoder_tb.v:30: error: X is not a valid l-value in decoder_tb.
decoder_tb.v:6:      : X is declared here as wire.
decoder_tb.v:30: error: Y is not a valid l-value in decoder_tb.
decoder_tb.v:6:      : Y is declared here as wire.
decoder_tb.v:30: error: E is not a valid l-value in decoder_tb.
decoder_tb.v:6:      : E is declared here as wire.
decoder_tb.v:32: error: X is not a valid l-value in decoder_tb.
decoder_tb.v:6:      : X is declared here as wire.
decoder_tb.v:32: error: Y is not a valid l-value in decoder_tb.
decoder_tb.v:6:      : Y is declared here as wire.
decoder_tb.v:32: error: E is not a valid l-value in decoder_tb.
decoder_tb.v:6:      : E is declared here as wire.
12 error(s) during elaboration.
4

1 に答える 1

1

テストベンチで、とに変更inputします。これにより、コンパイル エラーが修正されます (ただし、gEDA または iVerilog は使用していません)。regoutputwire

module decoder_tb;
    reg X,Y,E;
    wire [0:3]Z;

この場合、私のシミュレーターはあなたのものよりもはるかに意味のあるエラーメッセージを出しました:

識別子「X」はポート リストに表示されません。

于 2014-11-25T13:19:32.703 に答える