IEEE 200X Fast Track Change Proposal ID: FT-10A Proposer: Jim Lewis, jim@synthworks.com Status: Proposed Proposed: - Analyzed: Date Resolved: Date Enhancement Summary: Conditional assignment constructs for sequential statement and initialization Related issues: Relevant LRM section: Enhancement Detail: ---------------------------- Current text: if (FP = '1') then NextState <= FLASH ; else NextState <= IDLE ; end if ; Enhancement (for signal or variable) assignment: NextState <= FLASH when (FP = '1') else IDLE ; Use as a conditional expression: -- Asynchronous Reset (compatible with 1076-2002 AReg <= '0' when nReset = '1' else A when rising_edge(Clk) ; -- Synchronous Reset, requires ternary intrepretation and parentheses AReg <= ('0' when nReset = '1' else A) when rising_edge(Clk) ; Use as initialization (for constants, variable, signal): Signal A : integer := 7 when GEN_VAL = 1 else 15 ; The following two must be equivalent (backward compatibility): Y <= A and B when S='1' else C and D ; Y <= (A and B) when S = '1' else (C and D) ; The following always requires parentheses: Y <= A and (B when S = '1' else C) and D ; The following two must be equivalent (backward compatibility): Y <= '1' WHEN en='1' ELSE 'Z' after 5 ns; Y <= ('1' after 0 ns) when en='1' else ('Z' after 5 ns) ; The following always requires parentheses: Y <= ('1' when en = '1' else 'Z') after 5 ns ; Concerns (with any implementation): Y <= (A when S1='1' else B) when S2='1' else C ; ^^^^^^^^^^^^^^^^^^^^ This can be either a conditional_expression or conditional_waveforms. Does it matter and how does it get applied? Analysis: ---------------------------- Modifications to 1076-2002 Modify the BNF in section 7 as follows: expression ::= conditional_expression conditional_expression ::= {logical when condition else} logical [when condition] logical ::= relation { and relation } | relation { or relation } | relation { xor relation } | relation [ nand relation ] | relation [ nor relation ] | relation { xnor relation } Add section to clause 7: 7.6 Conditional Expressions A conditional expression selects one or none of the enclosed expressions to be assigned to the target. The target is permitted to be a variable, signal, or default expression of a constant, variable, or signal. For selection of the expression to be assigned to the target, the conditions specified after when are evaluated in succession until one evaluates to TRUE or all conditions are evaluated and yield FALSE. If one condition evaluates to TRUE, then the corresponding expression is evaulated and assigned to the target; otherwise, the value unaffected is assigned to the target. In the case of a default expression, the assignment of the value unaffected is the same as not having a default expression. Example: -- Use in a default expression of constant, variable, or signal: Signal A : integer := 7 when GEN_VAL = 1 else 15 ; -- Use with variable or signal assignment: State := FLASH when (FP = '1') else IDLE ; -- Use concurrently same as previously used conditional signal assignment -- creates register with asynchronous reset AReg <= '0' when nReset = '1' else A when rising_edge(Clk) ; -- Use concurrently with parentheses to force outer expression -- to be evaulated first to create register with synchronous reset: AReg <= ('0' when nReset = '1' else A) when rising_edge(Clk) ; Modify BNF in section 8.4 to: signal_assignment_statement ::= [ label : ] target <= [ delay_mechanism ] conditional_waveforms ; conditional_waveforms ::= {waveform when condition else} waveform [when condition] waveform ::= waveform_element { , waveform_element } | unaffected | (conditional_waveforms) Modify BNF in section 8.4.1 to: waveform_element ::= logical [ after time_expression ] | null [ after time_expression ] Add note to 8.4.1: Note: due to the BNF rules in this section, if a conditional_expression (vs conditional_waveforms) is used in a signal assignment, it must have parentheses around it: Y <= ('1' when en = '1' else 'Z') after 5 ns ; Add the following paragraphs from 9.5.1 to 8.4: For a given conditional signal assignment, there is an equivalent process statement corresponding to it as defined for any concurrent signal assignment statement. If the conditional signal assignment is of the form target <= options waveform1 when condition1 else waveform2 when condition2 else • • • waveformN–1 when conditionN–1 else waveformN when conditionN; then the signal transform in the corresponding process statement is of the form if condition1 then wave_transform1 elsif condition2 then wave_transform2 • • • elsif conditionN–1 then wave_transformN–1 elsif conditionN then wave_transformN end if ; If the conditional waveform is only a single waveform, the signal transform in the corresponding process statement is of the form wave_transform For any waveform, there is a corresponding wave transform. If the waveform is of the form waveform_element1, waveform_element2, ..., waveform_elementN then the wave transform in the corresponding process statement is of the form target <= [ delay_mechanism ] waveform_element1, waveform_element2, ..., waveform_elementN; If the waveform is of the form unaffected then the wave transform in the corresponding process statement is of the form null; In this example, the .nal null causes the driver to be unchanged, rather than disconnected. (This is the null statement—not a null waveform element). The characteristics of the waveforms and conditions in the conditional assignment statement must be such that the if statement in the equivalent process statement is a legal statement. Delete section: 9.5.1 Conditional signal assignments Resolution: ---------------------------- [To be performed by the 200X Fast Track Working Group]