2017-12-11 18 views
0
module NOR31_1x1(Y,A); 
input [31:0] A; 
output Y; 

wire [29:0] norWire; 

    nor nor1(norWire[0], A[0], A[1]); 
     nor nor2(norWire[1], norWire[0], A[2]); 
    nor nor3(norWire[2], norWire[1], A[3]); 
    nor nor4(norWire[3], norWire[2], A[4]); 
    nor nor5(norWire[4], norWire[3], A[5]); 
    nor nor6(norWire[5], norWire[4], A[6]); 
    nor nor7(norWire[6], norWire[5], A[7]); 
    nor nor8(norWire[7], norWire[6], A[8]); 
    nor nor9(norWire[8], norWire[7], A[9]); 
    nor nor10(norWire[9], norWire[8], A[10]); 
    nor nor11(norWire[10], norWire[9], A[11]); 
    nor nor12(norWire[11], norWire[10], A[12]); 
    nor nor13(norWire[12], norWire[11], A[13]); 
    nor nor14(norWire[13], norWire[12], A[14]); 
    nor nor15(norWire[14], norWire[13], A[15]); 
    nor nor16(norWire[15], norWire[14], A[16]); 
    nor nor17(norWire[16], norWire[15], A[17]); 
    nor nor18(norWire[17], norWire[16], A[18]); 
    nor nor19(norWire[18], norWire[17], A[19]); 
    nor nor20(norWire[19], norWire[18], A[20]); 
    nor nor21(norWire[20], norWire[19], A[21]); 
    nor nor22(norWire[21], norWire[20], A[22]); 
    nor nor23(norWire[22], norWire[21], A[23]); 
    nor nor24(norWire[23], norWire[22], A[24]); 
    nor nor25(norWire[24], norWire[23], A[25]); 
    nor nor26(norWire[25], norWire[24], A[26]); 
    nor nor27(norWire[26], norWire[25], A[27]); 
    nor nor28(norWire[27], norWire[26], A[28]); 
    nor nor29(norWire[28], norWire[27], A[29]); 
    nor nor30(norWire[29], norWire[28], A[30]); 
     nor result(Y, norWire[29], A[31]); 
endmodule 

をテストするので、私はゼロフラグがで設定されているかどうかをテストするために、上記のコードを書いたり、別のに対して、各ビット、ロジックが正しいようですが、結果がゼロの場合は1を返し続けます任意の入力にかかわらずフラグ。テストするためにシミュレーションを実行しましたが、まだ値を設定していないにもかかわらず、norWireにはすでに値が入っているようです。私はこの問題をデバッグする助けを得ることができますか?私は、VerilogとModelSimシミュレータを初めて使用しているため、これをデバッグするのに苦労しています。のVerilog、こんにちはゼロフラグため

+0

この場合正しい論理は何でしょうか?私は、入力の各ビットについても、ゼロでないかどうかを判断するでしょう。ゼロ以外のビットが1つある場合、結果は0を返します。 – KhoaVo

+2

'A'のすべてのビットが' 0 'のときに 'Y'を' 1'にしたいとします。そうであれば、 'assign Y =〜(| A);のようなデータフローモデリングを使うとよりクリーンなアプローチになります。これは 'A 'のすべてのビットをORしてから、それを否定して' Y'に代入します。 – sharvil111

答えて

1

問題を説明するためにこれを3ビットに制限しましょう。私たちは、あなたが表現しようとしている何ビットA、B、およびCにラベルを付ける場合は次のとおりです。

!(A | B | C) 

何が書いたことは次のとおりです。

1 NOR(の出力がで完了し
!(!(A | B) | C) 

最終的な否定)が次の段階に送られています。

「or」と「not」のプリミティブを慎重に使用すると、そこに移動できます。

+0

私はそれぞれのビットを使用してみましたが、結果を否定しました。どちらも動作しません。 – KhoaVo

+0

@KhoaVo私はあなたに保証します。注意してください。もう1つ、または現在のゲートよりもゲートが必要です。 –