3

我在 VHDL 中有一个非常简单的运算符问题。我尝试将一些输入与逻辑运算符进行比较,但收到错误消息...

entity test is
 port (
  paddr              : in  std_logic_vector(15 downto 0);
  psel                : in  std_logic;
  penable              : in  std_logic;
  pwrite              : in  std_logic
 );  
end entity test;

signal wrfifo_full       : std_logic; 

process (paddr, psel, penable, pwrite, wrfifo_full) is
begin
  if (((paddr(8 downto 2) = "1000000")) and (psel and penable) and (pwrite and not(wrfifo_full))) then
    dt_fifo_wr_i <= '1';
  else
    dt_fifo_wr_i <= '0';
  end if;

结束进程;

不幸的是,我收到以下错误消息:

if (((paddr(8 downto 2) = "1000000")) and (psel and penable) and (pwrite and not(wrfifo_full))) then | ncvhdl_p: *E,OPTYMM (hdl/vhdl/test.vhd,523|43): 运算符参数类型不匹配 87[4.3.3.2] 93[4.3.2.2] [7.2]

反正看到问题了吗?

干杯

4

2 回答 2

7

psel、penable、pwrite 和 wrfifo_full 都是 std_logic。

在 vhdl 中,要按照您的方式编写测试,它们需要是布尔值。

而是编写代码,以便将它们的值与 1 或零进行比较。

(paddr(8 downto 2) = "1000000"     and 
 psel   = '1' and penable     ='1' and 
 pwrite = '1' and wrfifo_full = '0')
于 2010-10-26T10:33:47.693 回答
5

正如乔治所说,您当前必须将所有标准逻辑转换为布尔值。

然而,在 VHDL-2008 中,有一个新的条件运算符 ( ??) 隐式应用于诸如您的语句,这意味着它们将按您希望的方式工作。您必须在您的编译器上启用 VHDL-2008 支持(或向您的供应商抱怨以与时俱进:)

这本书很好地阅读了 VHDL2008 为我们提供的所有新位:

VHDL-2008 只是新东西

第 4.4 节介绍了条件运算符

于 2010-10-26T10:52:43.640 回答