0
我是一個vhdl newbie.i爲只用AND和OR門的全加器寫了編碼。我創建了一個測試臺來測試我的代碼,並將它配置爲激發A,B和Cin的八種邏輯組合。當我運行模擬波形是正確的輸入,但總結出(H在我的情況)顯示只是「U」。任何想法請。VHDL全加器測試臺輸出U
library ieee;
use ieee.std_logic_1164.all;
--This program describes behaviour of a full adder constructed using
-- AND and OR gates. It employs component method which describes behaviour of
--AND,OR and NOT gates and use them to build the final object
--Entity description of the full adder
entity full_add is
port (a,b,c:IN BIT; h:OUT BIT);
end entity full_add;
--Description the 3 input And Gate
entity And2 is
port (j,k,l:in BIT; m:out BIT);
end entity And2;
architecture ex1 of And2 is
begin
m <= (j AND k AND l);
end architecture ex1;
--Description of the four input OR gate
entity Or2 is
port (d,e,f,g:IN BIT; h:OUT BIT);
end entity Or2;
architecture ex1 of Or2 is
begin
h <= (d or e or f or g);
end architecture ex1;
--Description of the NOT gate
entity Not1 is
port(x:in BIT; y:out BIT);
end entity Not1;
architecture ex1 of Not1 is
begin
y <= not x;
end architecture ex1;
--Components and wiring description
architecture netlist of full_add is
signal s,u,v,s2,u2,v2,w2:BIT;
begin
g1:entity WORK.Not1(ex1) port map(a,s);
g2:entity WORK.Not1(ex1) port map(b,u);
g3:entity WORK.Not1(ex1) port map(c,v);
g4:entity WORK.And2(ex1) port map(s,u,c,s2);
g5:entity WORK.And2(ex1) port map(s,b,v,u2);
g6:entity WORK.And2(ex1) port map(a,u,v,v2);
g7:entity WORK.And2(ex1) port map(a,b,v,w2);
g8:entity WORK.Or2(ex1) port map (s2,u2,v2,w2,h);
end architecture netlist;
如何讓一個完整的加法器只有一個輸出?我認爲一個完整的加法器有一個總和和一個進位? – GregHNZ
請張貼測試臺,因爲這樣可以複製您的問題,從而更容易進行調試。順便說一句。你不需要創建一個模塊來獲得'not operation';所以g1可以寫成's <=不是a'等。 –
Morten關於「不」的觀點是有效的,但同樣適用於「和」和「或」。我認爲這裏的重點是學習結構化編碼,而不是優化解決方案。 –