A mix-grained architecture for improving HLS-generated controllers on FPGAs