BPI code for FPGA implementation