![](/img/trans.png)
[英]VHDL equal operator: different behavior for std_logic and std_ulogic
[英]Bad operand types 'std_ulogic' and 'string(1 to 1)' from vhdl
我在第 13 行和第 27 行的代碼中有這個錯誤,在 vhdl 上,有人知道哪里出了問題嗎?
LIBRARY IEEE;
USE ieee.std_logic_1164.all;
entity POLI is
port(A,B: in std_logic_vector(2 downto 0);
x,y: in std_logic;
S: out std_logic_vector(6 downto 0));
end POLI;
architecture codigo of POLI is
begin
process(x) begin
if (x="1") then
S(0)<=((A(0)and(not A(1))and A(2))or((not A(0))and A(1)and A(2)));
S(1)<=((not A(0))and A(1)and (not A(2)));
S(2)<=((not A(0))and (not A(2)));
S(3)<=(((not A(0))and (not A(1))and (not A(2)))or ((not A(0))and A(1)and A(2)));
S(4)<=(A(0)and (not A(1))and (not A(2)));
S(5)<=(A(0)and (not A(1))and (not A(2)));
S(6)<=(((not A(0))and A(1))or((not A(0))and A(2)));
else
S<="0000000";
end if;
end process;
process(y) begin
if (y="1") then
S(1)<=(((not B(0))and (not B(2)))or((not b(0))and(not B(1))));
S(2)<=((not B(0))and(not B(2)));
S(4)<=(((not B(1))and B(0))or((not B(1))and B(2)));
S(5)<=(B(0)and(not B(1)));
S(6)<=(((not B(0))and B(1)));
else
S<="-------";
end if;
end process;
end codigo;
我在其他電腦和編譯器上試過,都遇到了同樣的問題
你有if x="1" then
and if y = "1" then
""
在 VHDL 中表示字符串(或位串文字) x
和y
都是std_logic
,因此不是數組類型。 在這種情況下,您應該使用'
,因為這是std_logic
用於其值的字符引用。
因此你應該寫。
if x = '1' then
....
if y = '1' then
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.