Re: [問題] 4-bit的加法器
※ 引述《papa2958 (噹噹是藍 妳是白)》之銘言:
: module FA1(S,Cout,A,B,C);
: output S,Cout;
: input A,B,C;
: assign {Cout,S}=A+B+C;
: endmodule
: module FA4(S,C4,A,B,C0);
: input [3:0]A,B;
: input C0;
: output [3:0]S;
: output C4;
: wire C1,C2,C3;
: FA1 U0(S[0],C1,A[0],B[0],C0);
: FA1 U1(S[1],C2,A[1],B[1],C1);
: FA1 U2(S[2],C3,A[2],B[2],C2);
: FA1 U3(S[3],C4,A[3],B[3],C3);
: endmodule
: --------------------------------------
: module testbench;
: wire S,Cout;
: reg A,B;
: FA4 ot(S,Cout,A,B,C);
: initial
: begin
: #10 A=10;B=10;C=1;
: #10 A=13;B=20;
: #10 A=15;B=30;
: #10 A=05;B=40;
: #10 A=07;B=50;
: #10 A=190;B=60;C=0;
: #10 A=18;B=190;
: #10 A=33;B=200;
: #10 A=25;B=660;
: #10 A=16;B=330;
: #10 A=19;B=220;
: #10 A=03;B=110;
: end
: endmodule
: 這是我用modelsim寫的 波型都有跑出來 但是不知道為什麼波型圖上
: 沒有顯示出數值 不知道是不是哪裡顯示數值的設定被我關掉了
ModelSim只有vector(多bit的訊號)才會顯示數值在波形圖上。
你私下寄給我的螢幕擷圖你有沒有發現你的testbench的A, B, S訊號只有1 bit?
那是因為你在testbench沒有宣告它們的長度,預設值就是1 bit。也就是這兩行:
wire S,Cout;
reg A,B;
應該改成:
wire [3:0] S;
wire Cout;
reg [3:0] A,B;
: 麻煩知道的人告訴我一下 謝謝!!
--
西方三聖:http://p8.p.pixnet.net/albums/userpics/8/3/553683/1193661731.jpg

《佛說阿彌陀經》http://web.cc.ncu.edu.tw/~93501025/amtf.doc
十一面觀音咒:http://file.buda.idv.tw/music/DBZFY04.mp3
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.220.219
討論串 (同標題文章)