Processing in memory architecture for neural networks and on-chip learning acceleration