gpt4 book ai didi

VHDL 中的案例陈述

转载 作者:行者123 更新时间:2023-12-01 02:57:01 24 4
gpt4 key购买 nike

在 VHDL 中编程时,可以在 case 语句中使用变量吗?此变量将被其中一种情况修改

IE。

case task is

when 1 =>

when 2 =>

when number =>

这个可以吗?

最佳答案

用于模拟还是合成?

无论哪种方式,来自 documentation :

The choices must be constants of the same discrete type as the expression.



使用 if测试 number , 任何一个:
if task=number then
...
else
case task is
when 1 => ...
when 2 => ...
when others => ...
end case;
end if;

或者
case task is
when 1 => ...
when 2 => ...
when others =>
if task=number then
...
else
...
end if;
end case;

您的选择取决于您是否想要 if task=number 的结果测试或 when ... =>测试有优先权? (例如,假设无论出于何种原因 number=1 ,您是否希望 when 1 =>if task=number 最终提供您的结果?)

在微不足道的情况下 case语句合成为多路复用器; if语句综合为一个比较器和两输入多路复用器。一个喂给另一个。

关于VHDL 中的案例陈述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2597281/

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