VHDL有三元运算符吗?
我喜欢三元运算符vs if子句的整洁VHDL有三元运算符吗?,vhdl,ternary-operator,Vhdl,Ternary Operator,我喜欢三元运算符vs if子句的整洁 vhdl中是否存在此运算符?我的搜索结果恰恰相反。我还签出了when语句,但它不是运算符,我也希望能够在进程中使用它…不是您从C/C++中知道的那种,但您可以使用: destination <= signal1 when condition else signal2; destination否。它是为VHDL-2008讨论的,但没有进入。你有两个选择。如果您的工具支持VHDL-2008,则现在支持条件赋值作为顺序语句(它们以前只是并发的),因此您可以
vhdl中是否存在此运算符?我的搜索结果恰恰相反。我还签出了when语句,但它不是运算符,我也希望能够在进程中使用它…不是您从C/C++中知道的那种,但您可以使用:
destination <= signal1 when condition else signal2;
destination否。它是为VHDL-2008讨论的,但没有进入。你有两个选择。如果您的工具支持VHDL-2008,则现在支持条件赋值作为顺序语句(它们以前只是并发的),因此您可以编写如下内容:
process(clock)
begin
if rising_edge(clock) then
q <= '0' when reset else d; -- ie. much like q <= reset? '0':d;
end if;
end process;
进程(时钟)
开始
如果上升沿(时钟),则
在我的实用程序包中,我有这两个函数。对我来说,它们非常方便
function ternu(cond : boolean; res_true, res_false : unsigned) return unsigned is
begin
if cond then return res_true;
else return res_false;
end if;
end function;
function terni(cond : boolean; res_true, res_false : integer) return integer is
begin
if cond then return res_true;
else return res_false;
end if;
end function;
如何添加多个when/else子句?我似乎无法让(cond when x else y)+(cond when z else w)
工作;不要在Xilinx Vivado中使用它。ISIM模拟器在2019.2版之前不支持此构造!难以置信的