std_logic:='X'的操作

时间:2019-07-08 01:30:52

标签: vhdl

问题摘要位于底部。

我正在分析和研究现有的VHDL代码。 在此代码中,端口reset_i已初始化为'X',如下面的代码所示。

entity ADC_fsm is
Port ( clk_i                :   in  std_logic := 'X';
       reset_i              :   in  std_logic := 'X';
       di_req_i             :   in  std_logic := 'X';
       wr_ack_i             :   in  std_logic := 'X';
       spi_ssel_i           :   in  std_logic := 'X';
       reg_enable_i         :   in  std_logic := 'X';
       reg_data_i           :   in  std_logic_vector(23 downto 0);
       adc_data_i           :   in  std_logic_vector(11 downto 0);
       bitslip_o            :   out std_logic;
       sync_done_o          :   out std_logic; 
       wr_en_o              :   out std_logic;
       spi_data_o           :   out std_logic_vector(23 downto 0) := (others => '0')
      );
end ADC_fsm;

此端口(reset_i)未与其他外部端口或信号连接。

在下一个代码中,

begin
process(clk_i, reset_i)
    begin
        if (reset_i = '1') then
            wr_en_o       <= '0';
            sync_done_o   <= '0';
            bitslip_o     <= '0';
            spi_data_o    <= (others => '0');

        s_delay_count     <= 0;
        s_write_indicator <= 0;

            state       <= ready;

        elsif rising_edge(clk_i) then

        wr_en_o       <= '0';
            sync_done_o   <= '0';
            bitslip_o     <= '0';

我知道'X'既不是1也不是0。 因此,首先上述代码中的if语句不起作用。

我的问题是elsif。

'X'不是'1',所以elsif情况下包括了'X'?

简而言之。

if (reset_i ='1') then
(A)
elsif(rising_edge(clk_i)) then
(B)
end if;

代码(B)仅在reset_i ='0'时有效吗? 还是在reset_i ='X'时也可以工作?

谢谢

1 个答案:

答案 0 :(得分:5)

类型std_logic是具有9个值的枚举类型,并具有以下9个值:

'U','X','0','1','Z','W','L','H','-'

每个值只是一个不同的任意符号。所以,线

if reset_i ='1' then            -- the brackets are not required
当且仅当reset_i等于'1'时,

为true。而已。 'X'只是一个不同的任意符号。

相关问题