HD-BIST: a hierarchical framework for BIST scheduling and diagnosis in SOCs