First-principles study of heavily B-doped silicon