TWiki
>
P1076 Web
>
Vhdl2019CollectedRequirements
>
ConditionalExpressions
>
TopLCS2016_036
(revision 23) (raw view)
Edit
Attach
---+ Language Change Specification for Conditional Expressions and/or Operators <span data-mce-mark="1" style="background-color: transparent;">Proposal</span> ---++ <table border="1" cellpadding="0" cellspacing="0" id="table1" rules="all"> <tbody> <tr> <td bgcolor="#ffffff" valign="top"> *LCS Number:* </td> <td bgcolor="#ffffff" valign="top">LCS-2016-036</td> </tr> <tr> <td bgcolor="#edf4f9" valign="top"> *Version:* </td> <td bgcolor="#edf4f9" valign="top">1</td> </tr> <tr> <td bgcolor="#ffffff" valign="top"> *Date:* </td> <td bgcolor="#ffffff" valign="top">24-Oct-2016</td> </tr> <tr> <td bgcolor="#edf4f9" valign="top"> *Status:* </td> <td bgcolor="#edf4f9" valign="top"> </td> </tr> <tr> <td bgcolor="#ffffff" valign="top"> *Author:* </td> <td bgcolor="#ffffff" valign="top">Kevin Jennings</td> </tr> <tr> <td bgcolor="#edf4f9" valign="top"> *Email:* </td> <td bgcolor="#edf4f9" valign="top"><a href="http://www.eda-twiki.org/cgi-bin/view.cgi/Main/KevinJennings" target="_top">KevinJennings</a></td> </tr> <tr> <td bgcolor="#ffffff" valign="top"> *Source Doc:* </td> <td bgcolor="#ffffff" valign="top"> ConditionalExpressions </td> </tr> <tr> <td bgcolor="#edf4f9" valign="top"> *Summary:* </td> <td bgcolor="#edf4f9" valign="top">Allow for conditional expressions in a declaration</td> </tr> </tbody> </table> ---+++ Voting Results: Cast your votes here Yes: 1 %USERSIG{MortenZilmer - 2016-12-11}% 1 <p> </p> <p> </p> No: 1 <span data-mce-mark="1">%USERSIG{ThomasPreusser - 2016-12-15}%</span> - see below, also consider [[LCS2016_036a][LCS-2016-036a]] 1 <span data-mce-mark="1">%USERSIG{Main.RyanHinton - 2016-12-19}%</span> ver 1 1 <span data-mce-mark="1">%USERSIG{Main.FarrellOstler - 2017-01-18}%</span> ver 1 1 <span data-mce-mark="1">%USERSIG{PatrickLehmann - 2017-01-19}%</span> - ver 1 - [[LCS2016_036a][LCS-2016-036a]] seams to be a better solution for the proposal. 1 <span data-mce-mark="1">%USERSIG{KevinJennings - 2017-1-18}%</span> - Ver 1, switching vote to 36a, 'when' does fit in better with the historical language than 'if'. 1 <span data-mce-mark="1">%USERSIG{MartinZabel - 2017-01-19}%</span> - ver 1 - also prefer [[LCS2016_036a][LCS-2016-036a]]. 1 %USERSIG{LievenLemiengre - 2017-01-27}% 1 %USERSIG{HendrikEeckhaut - 2017-01-27}% Abstain: 1 <span data-mce-mark="1">%USERSIG{Main.MartinThompson - 2016-12-12}%</span> <p> </p> ---+++ <span data-mce-mark="1"><a name="Details_of_Language_Change"></span><span data-mce-mark="1"></a></span><span data-mce-mark="1"><a name="Details_of_Language_Change"></span><span data-mce-mark="1"></a></span>Details_of_Language_Change ---++++ <span data-mce-mark="1"><a name="LRM_6_7_Attribute_declarations"></span><span data-mce-mark="1"></a></span><span data-mce-mark="1"><a name="LRM_6_5_6_3_Port_Clauses"></span><span data-mce-mark="1"></a></span>LRM Section 9.1 Expressions General and Annex C - Syntax Summary ---+++++ <span data-mce-mark="1"><a name="Page_92_second_paragraph"></span><span data-mce-mark="1"></a></span><span data-mce-mark="1"><a name="page_80_last_paragraph"></span><span data-mce-mark="1"></a></span>Page 117 top and page 486 top Changes are shown in %RED%red font%ENDCOLOR%. expression ::=<br />condition_operator primary<br />%RED%| logical_expression if expression else logical_expression%ENDCOLOR%<br />| logical_expression -- <a href="http://www.eda-twiki.org/cgi-bin/view.cgi/Main/KevinJennings" target="_top"><img alt="" height="24" src="%PUBURL%/Main/UserProfileHeader/default-user-profile.jpg" /> Kevin Jennings - 2016-10-24</a> ---++ <span data-mce-mark="1"><a name="Comments"></span><span data-mce-mark="1"></a></span><span data-mce-mark="1"><a name="Comments"></span><span data-mce-mark="1"></a></span>Comments <span data-mce-mark="1"><form action="http://www.eda-twiki.org/cgi-bin/save.cgi/P1076/LCS2016_019" enctype="multipart/form-data" id="above0" method="post" name="above0"></span> <span data-mce-mark="1"><textarea cols="80" name="comment" rows="5"></span><span data-mce-mark="1"></textarea></span> <span data-mce-mark="1"></form></span> ---+ The syntax is unreadable as soon as conditions are nested: a if b if c else d else e -- <span data-mce-mark="1">%BUBBLESIG{TristanGingold - 2016-11-06}%</span> Please, use the existing *conditional_expressions* syntax (i.e. *when*) so as to use consistent forms throughout the language. It is true that this syntax currently allows the expression to terminate without an unconditional fallback value. You might consider to exclude this case. However, I think it is even useful. Assume the fallback is missing and no conditional value is selected. If the associated constant, signal, attribute, ... initialization is then simply defined to be ignored, many of the use cases that are presented to justify conditional compilation would actually be taken care of in a much more VHDL-like manner. -- <span data-mce-mark="1">%BUBBLESIG{ThomasPreusser - 2016-11-21}%</span> @Thomas, parsing if ... else is a better solution for the parser. The when ... else syntax allows e.g. waveforms. Using if ... else restricts the possible parser branches to logical_expressions. -- <span data-mce-mark="1">%BUBBLESIG{PatrickLehmann - 2016-12-09}%</span> It appears this syntax doesn't allow choosing between three or more options. I would prefer the existing when ... else syntax (without waveforms) or importing the Ada if ... elsif ... else ... syntax. If we borrow from Ada, we may as well bring along the case expression form as well. -- <span data-mce-mark="1">%BUBBLESIG{RyanHinton - 2016-12-13}%</span> Reply to my own issue: three or more options are possible by using a parenthesized expression after the =else=. -- <span data-mce-mark="1">%BUBBLESIG{RyanHinton - 2016-12-14}%</span> @Patrick, I do not see how the name of the keyword (*if* or *when*) within the same grammatical structure would effect the parser. Even if it would, introducing another syntax for an essentially existing concept is not helpful to the language. It can only be justified if expanding the current scope of the concept is impossible. -- <span data-mce-mark="1">%BUBBLESIG{ThomasPreusser - 2016-12-15}%</span> Note that the current LCS introduces a new general version of conditional expressions. The announced goal for conditionals in declarations is a mere side effect. It will also introduce a strange coexistence of alternatives when being combined with the existing conditional variable and signal assignments. *y <= x0 if c0 else x1 when c1 else x2;* is valid with any other choice of combining <b>if</b>s and<b> when</b>s. They are<b> not</b> all semantically equivalent. -- <span data-mce-mark="1">%BUBBLESIG{ThomasPreusser - 2016-12-16}%</span> I note that the proposal grammar (and above), results in requiring parentheses when doing multiple if's statements: constant A1 : integer := 1 if gVal1 else 2 (if gVal2 else 3) ; However the following two are equivalent (the first being Tristan's example: constant A2 : integer := 1 if gVal1 if gVal2 else gVal3 else 3 ; constant A3 : integer := 1 if gVal1 (if gVal2 else gVal3) else 3 ; I think we need to rewrite the BNF to allow A1 without parens as can currently be done with when else. And then check for ambiguity as mixing when else and if else an be exciting. I am thinking we need to add the term if_expression a the root of the BNF: if_expression ::= expression if expression else if_expression Then in primary change expression to if_expression: primary :: . . . | (if_expression) . . . -- <span data-mce-mark="1">%BUBBLESIG{JimLewis - 2016-12-17}%</span> Introducing first-class conditional expressions to VHDL can be built on two established concepts: 1 Generalize the existing *when-else* construct known from conditional signal and variable assignments. 1 Adopt the *if* expressions introduced by ADA 2012. <p> </p> <p> </p> <p> </p> <p> </p> The current LCS is a strange crossover that squeezes the new *if* expressions into the structure of the established VHDL *when* constructs. I would really prefer choosing a clean solution following exactly one of the precedents. ADA's conditional *if* and *case* expressions could certainly be adopted directly without introducing a new syntax for them. -- <span data-mce-mark="1">%BUBBLESIG{ThomasPreusser - 2016-12-18}%</span><span data-mce-mark="1"> %COMMENT%</span>
Edit
|
Attach
|
P
rint version
|
H
istory
:
r24
<
r23
<
r22
<
r21
<
r20
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r1 - 2017-04-02 - 16:09:37 -
TWikiGuest
P1076
Log In
or
Register
P1076 Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
Webs
Main
P1076
Ballots
LCS2016_080
P10761
P1647
P16661
P1685
P1734
P1735
P1778
P1800
P1801
Sandbox
TWiki
VIP
VerilogAMS
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback