A new algorithm for diagnosis-oriented automatic test pattern generation