VHDL是否具有三元运算符? [英] Does VHDL have a ternary operator?

查看:96
本文介绍了VHDL是否具有三元运算符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢三元运算符和if子句的简洁性。

I love the neatness of the ternary operator vs if clauses.

该运算符是否存在于vhdl中?我的搜索恰恰相反。我还检查了when语句,但它不是运算符,我也希望能够在流程中使用它。

Does this operator exist in vhdl? My search was to the contrary. I also checked the when statement out, but it's not an operator, and I want to be able to use it in processes, too...

推荐答案

否在VHDL-2008上进行了讨论,但没有参与。您有几种选择。如果您的工具支持VHDL-2008,则条件支持现在可以作为顺序语句(它们以前只是并发的)而受支持,因此您可以编写以下内容:

No. It was discussed for VHDL-2008, but didn't get in. You've got a couple of options. If your tools support VHDL-2008, conditional assignments are now supported as sequential statements (they were previously just concurrent), so you can write something like:

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;

如果您还没有2008年,只需编写一个函数( q < ; = sel(reset,'0',d))。不过,您必须针对每种感兴趣的类型编写它。

If you haven't got 2008, just write a function (q <= sel(reset, '0', d)). You have to write it for every type you're interested in, though.

这篇关于VHDL是否具有三元运算符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆