Flip-N-Write: a simple deterministic technique to improve PRAM write performance, energy and endurance