Clara Rabello
Clara Rabello

Reputation: 13

vhdl case...is and with...select

I'm trying to write something on VHDL, but it's not working. Here's part of my code:

case currentState is
    when ST000 =>
        with A select nextState <=
            ST025 when "01",
            ST050 when "10",
            ST000 when "11",
            currentState when others;
    when ST001 => ...
    when others => ...
end case;

It says there's a problem in these lines, like this: Line 62. parse error, unexpected WITH. Why is this with unexpected? Is it wrong to mix these two syntaxes, case...is and with...select, together?

Upvotes: 1

Views: 1301

Answers (1)

user1155120
user1155120

Reputation:

Unless otherwise notes, reference are from IEEE Std 1076-2008, IEEE VHDL Language Reference Manual.

10. Sequential statements

10.1 General

The various forms of sequential statements are described in this clause. Sequential statements are used to define algorithms for the execution of a subprogram or process; they execute in the order in which they appear.

10.9 Case statement

A case statement selects for execution one of a number of alternative sequences of statements; the chosen alternative is defined by the value of an expression.

A sequence of statements indicates sequential statements.

10.5.4 Selected signal assignments

The selected signal assignment represents an equivalent case statement that assigns values to signals or that forces or releases signals.

However...

Annex E
(informative)
Changes from IEEE Std 1076-2002

...
Clause 10

— 10.5: Addition of force and release assignment; addition of simple, conditional and selected signal assignment.

In revisions of the VHDL standard earlier than -2008 selected signal assignments were only available as concurrent signal assignment statements (See 11.6 Concurrent signal assignment statements, or found in Clause/Chapter 9 Concurrent Statements, subsection 9.5.2 Selected signal assignment in earlier revisions of the VHDL standard).

Note that when inconvenient or lacking support for this -2008 feature you can substitute a case statement:

case currentState is
    when ST000 =>
        case A is
            when "01" =>
                nextState <= ST025;
            when "10" =>
                nextState <= ST050;
            when "11" =>
                nextState <= ST000;
            when others =>
                nextState <= CurrentState;
        end case;
    when ST001 => ...
    when others => ...
end case;

Upvotes: 1

Related Questions