【发布时间】:2014-05-07 09:03:42
【问题描述】:
我不明白我应该怎么做。
这是我的代码:
use ieee.std_logic_1164.all;
use ieee.numeric_std.all ;
use ieee.std_logic_signed .all ;
entity M is
port(
clk : in std_logic ;
rst : in std_logic ;
data : in std_logic_vector(1 downto 0);
CD : in std_logic_vector(3 downto 0);
s : out std_logic_vector (1 downto 0));
end entity ;
architecture beh of M is
signal com :std_logic_vector(3 downto 0);
begin
code :process(clk,rst)
begin
if (rst='1') then
(others=>'0')<=data;
--data<='0' !!! ;
(others=>'0')<=CD;
--"0000"<=CD ;
s <=(others=>'0');
else
for i in 0 to 3 loop
if (clk'event and clk='1')then
--for i in 0 to 3 loop
com(i)<= not(CD(i)xor(data) ) ;
--s<=not(CD(i) xor (data));
end if ;
end loop ;
end if ;
end process ;
s<=com(i) ;
end architecture ;
这是我的问题:
错误 (10476):M.vhd(39) 处的 VHDL 错误:标识符“数据”的类型确实 不同意将其用作“std_ulogic”类型
【问题讨论】:
-
如何异或 1 位和 2 位?
data是一个 2 位宽的向量。 -
这里的问题并不是严格意义上的
xoring 2 bits with 1 bit(VHDL-2008 支持)——它将结果分配给 1 位切片。诚然,两者都可能不是预期的...... -
@user3611379:您对 xor 语句的意图是什么?正如 N8TRO 所暗示的那样,您正在尝试对一个 2 位向量进行异或运算(我上面的评论旨在指出,如果您使用 VHDL-2008,这是严格合法的,而不是它是正确的 根据您的意图)。您要执行的操作是什么?
标签: vhdl