If statement VHDL中的并发If语句

If statement VHDL中的并发If语句,if-statement,concurrency,vhdl,If Statement,Concurrency,Vhdl,我正在编写代码,用于同时将一个信号与多个信号进行比较 以下是一个例子: process (CLK, reset) if reset = '0' then data <= (others => '0'); elsif rising_edge (CLK) then if A = B then data <= data OR "0001"; else data <= data AND "1110"; end if;

我正在编写代码,用于同时将一个信号与多个信号进行比较

以下是一个例子:

process (CLK, reset)
if reset = '0' then
    data <= (others => '0');
elsif rising_edge (CLK) then 
    if A = B then
         data <= data OR "0001";
    else data <= data AND "1110";
    end if;

    if A = C then
        data <= data OR "0010";
    else data <= data AND "1101";
    end if;

    if A = D then
        data <= data OR "0100";
    else data <= data AND "1011";
    end if;

    if A = E then
        data <= data OR "1000";
    else data <= data AND "0111";
    end if;
end if;
end process;
过程(时钟、复位)
如果重置='0',则
数据“0”);
elsif上升沿(CLK)则
如果A=B,则

data您正在尝试用一种不需要的语言编写C! 在C语言中,您不能访问单个位,只能访问字节和更大的单位,因此C程序员必须使用和/或,即&来设置或清除位

在VHDL中,您可以寻址单词的各个位,并编写

if A = B then
     data(0) <= '1';
else 
     data(0) <= '0';
end if;
然后我就可以写了

process (CLK, reset)
begin
   if reset = '0' then
      data <= (others => false);
   elsif rising_edge (CLK) then 
      data <= (A = E) & (A = D) & (A = C) & (A = B);
   end if;
end process;

现在,
数据的单个赋值将包含所有单独的修改。然而,它可能会合成出比最佳解决方案大得多的东西。

你的方法可行!谢谢。让我好奇的是,是不是因为我的方法导致了扇入,从而优化了较低的3位?
process (CLK, reset)
begin
   if reset = '0' then
      data <= (others => false);
   elsif rising_edge (CLK) then 
      data <= (A = E) & (A = D) & (A = C) & (A = B);
   end if;
end process;
process (CLK, reset)
    variable data_int : whatever; -- same type as data
begin
if reset = '0' then
    data <= (others => '0');
elsif rising_edge (CLK) then 
    data_int := data;
    if A = B then
         data_int := data_int OR "0001";
    else data_int := data_int AND "1110";
    end if;
    ...
    if A = E then
         data_int := data_int OR "1000";
    else data_int := data_int AND "0111";
    end if;

    data <= data_int;

end if;
end process;