Integration of ferroelectric nonvolatile memories