Does Verilog support short circuit assessment?

If I have an if statement:

if(risingEdge && cnt == 3'b111)
begin
  ...
end

Will it be checked on cnt if the raiseEdge value is incorrect?

Does it even matter inside HDL?

+3
source share
2 answers

For modeling, it is undefined as to whether short-circuited expressions are evaluated or not. In the example above, this does not matter, but if you have a function call on the right side, you may run into problems with undefined side effects.

See Gotcha # 52 in "Verilog and SystemVerilog Gotchas: 101 Common Coding Errors and How to Avoid Them" by Stuart Sutherland and Don Mills.

+6
source

, HDL, , , . - . , SystemVerilog:

if(risingEdge && cnt++ == 3'b111)
begin
  ...
end

Verilog ( SV) - verilog, , . , .

R, , , ( , Gotchas). , , SystemVerilog, , . Verilog , , SV disambiguates , , ( ++, Java ..). . 11.3.5 IEEE-1800-2009, . , SV , , SV.

+2

Source: https://habr.com/ru/post/1754137/


All Articles