3
\$\begingroup\$

From times to times I see different code examples that have " ... else Null" strings in if-statements and it's something I don't get. I've learned and I stick to the idea that the best way to model nothing is write no code. But is there any difference in these aproaches? if not then why do people write this "else null"?

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Are you talking specifically about if-then-else structures or also switch cases with when others => null; ? \$\endgroup\$
    – DonFusili
    Commented Jun 14, 2018 at 11:30
  • \$\begingroup\$ Please provide one or more concrete code examples you would like explained. Null can be used in several different ways in VHDL. \$\endgroup\$
    – Lincoln
    Commented Jun 14, 2018 at 12:55
  • 6
    \$\begingroup\$ Basically QA. else null; means I didn't just forget this bit, there really is nothing to do here;. As VHDL tends to be used in high integrity applications and some customers insist on critically reviewing every line of code, it really is the simplest and cheapest way to do the job. \$\endgroup\$
    – user16324
    Commented Jun 14, 2018 at 12:56
  • 1
    \$\begingroup\$ Apart from the good answer about QA, it may be to be able to place a breakpoint on that line in a VHDL simulator. \$\endgroup\$
    – Grabul
    Commented Jun 14, 2018 at 20:48
  • \$\begingroup\$ (A null statement can be labelled, see the answer referencing 10.14 in the standard. However neither breakpoints nor simulator user interactivity are defined in IEEE Std 1076-2008.) \$\endgroup\$
    – user8352
    Commented Jun 15, 2018 at 0:23

1 Answer 1

3
\$\begingroup\$

As @BrianDrummond stated... From IEEE 1076:

10.14 Null statement

A null statement performs no action.

null_statement ::= [ label : ] null ;

The execution of the null statement has no effect other than to pass on to the next statement.

NOTE—The null statement can be used to specify explicitly that no action is to be performed when certain conditions are true, although it is never mandatory for this (or any other) purpose. This is particularly useful in conjunction with the case statement, in which all possible values of the case expression shall be covered by choices; for certain choices, it may be that no action is required

\$\endgroup\$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.