2
\$\begingroup\$

In my ASIC book they are developing a state machine, and they have a statement like:

 Shift <= '1' when State = S else '0'; 

However in my project I have multiple states that have the same output being required to turn on so is it possible to write VHDL like this:

 Shift <= '1' when State = S OR State = E OR STATE = Q else '0'; 

Or do I have to assign Shift for each of my states?

asked Feb 12, 2014 at 12:01
\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

Yes that is doable

Shift <= '1' when ((State = S) OR (State = E) OR (STATE = Q))
 else '0'; 
answered Feb 12, 2014 at 12:18
\$\endgroup\$
3
  • \$\begingroup\$ The parentheses are unnecessary; the code in the question was already correct. \$\endgroup\$ Commented Feb 12, 2014 at 14:35
  • 1
    \$\begingroup\$ @BrianDrummond I think it's a good habit to parenthesize conditions in any "programming" language, it makes things much clearer. \$\endgroup\$ Commented Feb 12, 2014 at 14:48
  • 1
    \$\begingroup\$ @alexan_e: although some take the view that excessive parens are less clear... I would certainly remove the outer parens \$\endgroup\$ Commented Feb 12, 2014 at 16:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.