0

Verilog で加算器のゲート レベルのコードを書きました。加算器の出力を以下に示します。ご覧のとおり、sum と cout は常に z です。どうしてか分かりません。不足しているものを確認できますか? 御時間ありがとうございます。

出力:

a = x、b = x、cin = x、summ = z、cout = z at time = 0

a = 0、b = 0、cin = 0、summ = z、cout = z at time = 10

a = 0、b = 1、cin = 0、summ = z、cout = z at time = 20

a = 1、b = 0、cin = 0、summ = z、cout = z at time = 30

a = 1、b = 1、cin = 0、summ = z、cout = z at time = 40

a = 0、b = 0、cin = 1、summ = z、cout = z at time = 50

a = 0、b = 1、cin = 1、summ = z、cout = z at time = 60

a = 1、b = 0、cin = 1、summ = z、cout = z at time = 70

a = 1、b = 1、cin = 1、summ = z、cout = z at time = 80

module tb();  

reg a, b, cin; 
wire cout, summ;


FA_gatelevel gatelevel(.a(a), .b(b), .cin(cin), .summ(summ), .cout(cout));

initial begin  

    #10 a = 0; b = 0; cin = 0; 
    #10 a = 0; b = 1; cin = 0;
    #10 a = 1; b = 0; cin = 0;
    #10 a = 1; b = 1; cin = 0;
    #10 a = 0; b = 0; cin = 1;
    #10 a = 0; b = 1; cin = 1;
    #10 a = 1; b = 0; cin = 1;
    #10 a = 1; b = 1; cin = 1;

end


initial begin


$monitor("a = %0h, b = %0h, cin = %0h, sum = %0h, co = %0h at time = `%0t",a,b,cin,summ,cout,$time); // gate level

    #200 $finish;
end 

endmodule

.

module FA_gatelevel(a, b, cin, summ, cout);

input a,b,cin;
output summ,cout;

FA_co ins_co(.a(a), .b(b), .cin(cin), .cout(cout));
FA_sum ins_sum(.a(a), .b(b), .cin(cin), .summ(summ));

endmodule

.

module FA_co (a, b, cin, cout);

input a, b, cin;
output cout;
wire ab, bc, ca;

and g0 (a,b,ab);
and g1 (b,c,bc);
and g2 (c,a,ca);
or  g3 (ab,bc,ca,cout);

endmodule

.

module FA_sum(a, b, cin, summ);

input a, b, cin;
output  summ;

xor g0 (a,b,cin,summ);


endmodule
4

1 に答える 1

1

Verilog ゲート プリミティブに接続する場合、出力は常に最初の接続です。

于 2016-12-04T04:09:20.730 に答える