// METHODS void deadCheckMod() { // Kill any unused modules // V3LinkCells has a graph that is capable of this too, but we need to do it // after we've done all the generate blocks for (bool retry=true; retry; ) { retry=false; AstNodeModule* nextmodp; for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp; modp=nextmodp) { nextmodp = modp->nextp()->castNodeModule(); if (modp->level()>2 && modp->user1()==0 && !modp->internal()) { // > 2 because L1 is the wrapper, L2 is the top user module UINFO(4," Dead module "<<modp<<endl); // And its children may now be killable too; correct counts // Recurse, as cells may not be directly under the module but in a generate DeadModVisitor visitor(modp); modp->unlinkFrBack()->deleteTree(); VL_DANGLING(modp); retry = true; } } } }