2017-04-14 3 views
0

シミュレーションでは、 'a'はその値を変更しないため、その理由を知ることができません。 '実行(co)'は常にHiZとして出力され、 'sum'は少し奇妙な値を生成します。 'of(overflow)'の値も 誰もがこれで私を助けることができますか? 助けていただければ幸いです。 ありがとうございます。Verilogシミュレーションエラー

`timescale 100ps/1ps  
module RCA_tb; 
reg [7:0] a; 
reg [7:0] b; 
reg ci; 
wire [7:0] sum; 
wire co; 
wire of; //overflow 
integer i; 

RippleCA RCA(a,b,ci,sum,co,of); 

initial begin 

    a=0; 
    b=0; 
    ci=0; 

    end 



    initial begin // all possible cases 

    for(i=0; i<256; i=i+1) 


    #10 {a, b, ci} = i; 


    end 
endmodule 

module RippleCA(a,b,ci,sum,co,of); 
input [7:0] a; 
input [7:0] b; 
input ci; 
output [7:0] sum; 
output co; 
output of; 
wire[6:0] c; 
FullAdder a1(a[0],b[0],ci,sum[0],c[0]); 
FullAdder a2(a[1],b[1],c[0],sum[1],c[1]); 
FullAdder a3(a[2],b[2],c[1],sum[2],c[2]); 
FullAdder a4(a[3],b[3],c[2],sum[3],c[3]); 
FullAdder a5(a[4],b[4],c[3],sum[4],c[4]); 
FullAdder a6(a[5],b[5],c[4],sum[5],c[5]); 
FullAdder a7(a[6],b[6],c[5],sum[6],c[6]); 
FullAdder a8(a[7],b[7],c[6],sum[7],cout); 
xor x2(of,c[6],co); //overflow detection 
endmodule 
module FullAdder (
a,b,ci,sum,co 
); 
input a,b,ci; 
output sum,co; 
wire w1, w2, w3; 
xor x1(sum, a, b, ci); 
and a1(w1,a,b); 
and a2(w2,b,ci); 
and a3(w3,ci,a); 
or o1(co,w1,w2,w3); 
endmodule 

これは私のVerilogコードです。

enter image description here

enter image description here

+0

テストベンチの初期ブロックを1つにマージします。 – Laleh

+0

コメントありがとうございます。私のコードを編集してシミュレートしましたが、「ci」は#10ごとに変更されますが、その他の問題は同じままです。特に 'a'は変更されず、sumはxsを含む値を生成します。 – Jaeyeong

答えて

3

あなたは

reg [7:0] a; 
reg [7:0] b; 
reg ci; 

を宣言し、

{a, b, ci} = i; 

{a,b,ci}を割り当てる17ビット幅ですが、あなたは最高からiをカウントしています3210は8ビット幅で、この場合はaは常にゼロになります。 forループをfor(i=0; i<262144; i=i+1)に増やすと、それをテストできるはずです。

+0

わかりました。ありがとうございました!ほんとうにありがとう。 :) – Jaeyeong