FOAM: Searching for Hardware-Optimal SPN Structures and