Optimizing the use of different memory types on modern FPGAs