Unreachable code analysis is a static analysis technique used to identify and report code that cannot be executed under any possible circumstances during the runtime of a program. This type of code is typically a result of human error or programming mistakes, such as dead code or redundant code.

Unreachable code analysis tools are typically integrated into programming environments and IDEs, and can be used during development to improve the quality of code by identifying and removing unnecessary code. This can help to reduce code complexity and improve overall performance, as well as prevent potential security vulnerabilities or other issues that may arise from code that is not executed.

Example


always @(posedge clk) begin
  if (reset) begin
    a <= 0;
    b <= 0;
  end
  else begin
    a <= a + 1;
    b <= b + 1;
  end
  c <= c + 1;
end

In this code, the statement c <= c + 1; is unreachable because it is outside of the else block, and will always execute regardless of the value of reset. This can lead to unexpected behavior in the design, as c will always increment even during reset, which may not be desirable. Unreachable code analysis can help detect such issues and ensure the code is more efficient and error-free.

Unreachable code has the potential to bring down overall verification code coverage because of the dead code that cannot be hit with any kind of input stimuli. There are several industry tools from major EDA vendors like Synopsys, Cadence and Mentor that are available for RTL analysis that can help detect and reduce unreachable code.

As a part of optimization for future designs, such dead code should be fixed so that the effort to run, analyze and review dead code can be avoided for future design revisions.