2016-11-21 51 views
1

Truth table錯誤真值表VHDL

My code

我計算的卡諾圖,但我的代碼是不正確的。我得到錯誤:「D ='1'的錯誤C ='0'B ='1'A ='0'預計O ='1',收到O ='0'」。

我在哪裏犯錯?

library IEEE; 
use IEEE.std_logic_1164.all; 
entity truth_table is port( A,B,C,D : in std_logic; 
           O  : out std_logic); 
end truth_table; 

architecture behavior of truth_table isbegin 

O <= (((not A) and C and D) or ((not D) and B and C) or (A and (not C) and D) or (A and C and (not B))); 
end behavior; 
+0

您應該避免將代碼發佈爲鏈接圖像。代碼很好地顯示爲問題中的文本。 – Tome

+0

如果您的代碼沒有複製真值表,那是因爲您在K-map中發生了錯誤。你沒有顯示這個,所以我們不能說出你做錯了什麼!就我個人而言,我發現這一個更容易處理反向輸出,然後在最後反轉整個方程。這給了4個產品總和而不是6個。 –

+0

我的錯誤,反轉並不能減少產品的總和,但是如果這對於應用來說非常重要的話,它確實使用較少的門控輸入。 –

回答

0

你的信號「O」右邊的邏輯等式是錯了,它應該是:

O <= (((not D) and B and A) or ((not A) and C and B) or (D and (not B) and A) or (D and B and (not C))); 

http://www.32x8.com/var4.html和自己嘗試一下,但請注意,列的順序是不是相反在你的真相表中。

+0

我使用了相同的站點,但我沒有意識到列的順序是相反的,我總是得到錯誤的結果。 – Ninalol

+0

「不」在這裏擁有最高的運營商優先級。你不需要封閉的支撐物 - 例如「(不是D)」可以表示爲「不是D」。參見IEEE Std 1076-2008 9.2運營商,9.2.1概述,優先級遞增的運營商列表。 – user1155120