Esterel Technologies

Does SCADE generate dead code?

No, SCADE code generators do not create dead code neither generates code for the dead branches it detects.

All SCADE code generators respect the following principles:

  • code is generated only for the part of the model that contributes to the computation of the root node outputs. Therefore, a dead branch in the SCADE model will be pointed out by SCADE Code Generator, which will not produce code for this branch.
  • SCADE Code Generators do not add dead code to the specification

of the SCADE model.

Example of a dead branch detected by SCADE Code generator:

dead branch

In this example, local variable AorB is never consumed: SCADE Code Generator won't generate code for AorB.

But if a SCADE model contains (in its part that contributes to the root node outputs) portions that cannot be activated, the generated code will stick to the specification and contain code that cannot be activated either.

Example: if ( (x <3) and (x > 5) )

It is widely agreed that elimination of such dead code is not feasible in the general case but only in trivial cases such as the example mentioned above: in such cases, we have dead code because we have pieces of dead specification ...

In order to solve such potential problems, the following approach, involving Design Verifier (and a bit of effort), can be proposed: for each boolean that is a condition of an if/case or when/condact, analyze both properties "this variable is always true" and "this variable is always false". If one of these properties turns to be valid, it signifies that the associated condition is always true (resp. always false), and that the SCADE model actually contains dead specification.

With the actual version of Design Verifier, one can only do that locally to each module, and should add artificial outputs, but that would detect the kind of trivial example given above.

© 1999–2008 Esterel Technologies, Inc. All rights reserved.