0
\$\begingroup\$

Is there a difference between the two? I would expect maybe the first has delayed evaluation of conditions?

if(A='1') then

if(B='1') then

end if;
end if;

Over 

If(A='1' AND B='1') then

end if;



```
\$\endgroup\$
6
  • 2
    \$\begingroup\$ It seems like the compiler would/should optimize both cases to same code. \$\endgroup\$ – relayman357 Aug 31 '20 at 14:54
  • \$\begingroup\$ Worrying about writing optimum machine code is an efficient way of programming. Write code that is easier for you and others to understand. \$\endgroup\$ – StainlessSteelRat Aug 31 '20 at 15:15
  • 1
    \$\begingroup\$ None in terms of output. Potentially some in terms of clarity and readability. Both styles can happily lose the parentheses. Occasionally, some in terms of synthesis : look at your synth tool's style guide. Some synthesis tools may not like cramming a lot of other stuff into if rising_edge(clock) and ... while others may be fine with it. \$\endgroup\$ – Brian Drummond Aug 31 '20 at 15:20
  • \$\begingroup\$ nested style makes it easier to add statements before, or after, the second if statement \$\endgroup\$ – jsotola Aug 31 '20 at 17:08
  • \$\begingroup\$ If i add statement before and after the 2nd if statement will all statements still be execute in zero time? \$\endgroup\$ – Yanukova Yester Aug 31 '20 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.