RE: EXTERNAL: [vhdl-200x] VHDL ternary operation

From: Jones, Andy D <andy.d.jones@lmco.com>
Date: Thu Mar 28 2013 - 07:40:21 PDT
Daniel,

"pass" when fault else "fail" is NOT an expression. It is the RHS of a conditional assignment statement. Such a RHS may contain expressions, but expressions may not contain a conditional assignment RHS.

Since conditional assignments can be open-ended, in effect meaning that the assignment does not occur if no "when" expression evaluates as true, its use as an expression is not possible.

To solve your immediate problem, you could write a function that takes a boolean argument and returns "pass" or "fail" strings, or you could create a constant array of two strings, indexed by boolean, e.g. (true => "fail", false => "pass"). Then you could include the function call or constant in your report expression.

Andy

From: owner-vhdl-200x@eda.org [mailto:owner-vhdl-200x@eda.org] On Behalf Of Daniel Kho
Sent: Thursday, March 28, 2013 4:19 AM
To: vhdl-200x@eda.org
Subject: EXTERNAL: [vhdl-200x] VHDL ternary operation

Hi all,
I'm wondering if the current revision supports something like the following?

report to_hstring(index) & ", " & ("pass" when fault else "fail") & lf & nul;
where "index" is an unsigned vector, and "fault" is a boolean.

The expression ("pass" when fault else "fail") can already be used directly in clocked processes, but I'm not too sure if the standard allows this to be used within report statements.
If there's a better way of writing which could produce the same effect, do share with me as well.

regards, daniel

--
This message has been scanned for viruses and
dangerous content by MailScanner<http://www.mailscanner.info/>, and is
believed to be clean.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu Mar 28 07:41:40 2013

This archive was generated by hypermail 2.1.8 : Thu Mar 28 2013 - 07:42:14 PDT