总结的问题在底部。
我正在分析和研究现有的 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。
所以,首先如果上面代码中的语句不起作用。
我的问题是 elsif 怎么样。
'X' 不是 '1',所以 'X' 包含在 elsif 情况中?
简而言之。
if (reset_i ='1') then
(A)
elsif(rising_edge(clk_i)) then
(B)
end if;
代码 (B) 仅在 reset_i = '0' 时有效吗?
或者当 reset_i ='X' 时也能工作?
谢谢
最佳答案
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'
时才为真。就是这样。 'X'
只是一个不同的、任意的符号。关于vhdl - std_logic : ='X' 的操作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56927382/