A learning rule of neural networks via simultaneous perturbation and its hardware implementation