在VHDL编程中,您可以在case语句中使用变量吗?这个变量将会被其中一个case修改。
例如:
例如:
case task is
when 1 =>
when 2 =>
when number =>
这个可以吗?
case task is
when 1 =>
when 2 =>
when number =>
这个可以吗?
模拟还是综合?
无论哪种方式,根据文档:
选择必须是与表达式相同的离散类型的常量。
使用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
语句会合成为比较器和两个输入的多路复用器。其中一个输入馈入另一个。