下面是使用 IF 块的 VHDL 代码。在最后一个“elsif”中,“my_choice”的值被分配给“ch4”。然后执行“else”块,因为不满足任何条件。但是,“my_choice”是否有可能获得除 (ch1,ch2,ch3,ch4) 之外的其他值,例如高阻抗(或其他任何值)?如果是这样,我该如何避免这种情况?由于这个赋值可以改变代码的操作。
entity entity_name
port
.....
.....
end entity_name;
architecture bhvr of entity_name
type choices is (ch1, ch2, ch3, ch4);
signal my_choice,next_choice : choices;
begin
process(clk, reset)
begin
if reset='1' tehn
--------reset
else
my_choice<=next_choice;
end if;
end process;
process(my_choice)
begin
if my_choice = ch1 then
next_choice <= ch2;
elsif my_choice = ch2 then
next_choice <= ch3;
elsif my_choice = ch3 then
next_choice <= ch4;
else ------------------------------------coming to ch4
---- task for ch4
end process;
end architecture;