gpt4 book ai didi

select - VHDL:多值选择

转载 作者:行者123 更新时间:2023-12-04 20:47:12 24 4
gpt4 key购买 nike

我有以下代码(它编码了一些按下的按钮):

with buttons select
tmp <= "000" when x"1",
"001" when x"2",
"010" when x"4",
"011" when x"8",
"100" when others;
code <= input(1 downto 0);
error <= input(2);

我试图在不使用 tmp 的情况下重写它信号。是否可以?以下不起作用:
with buttons select
error & code <= "000" when x"1",
"001" when x"2",
"010" when x"4",
"011" when x"8",
"100" when others;

最佳答案

您可以使用案例而不是选择:

my_process_name : process(buttons)
begin
case buttons is
when x"1" =>
error <= '0';
code <= "00";
when x"2" =>
error <= '0';
code <= "01";
when x"4" =>
error <= '0';
code <= "10";
when x"8" =>
error <= '0';
code <= "11";
when others =>
error <= '1';
code <= "00";
end case;
end process;

关于select - VHDL:多值选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15314463/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com