Circuit and algorithm design to enable edge intelligence