No...Been there already. The only way to change engine model is to change everything electrical, including the PCM, along with it.
I tried putting an M54 motor in my '99 323i and much to my dismay after install, no start. Long story short, I would have had to change a lot more than just the motor. So, I found a real low mileage M52 back in and it runs smooth as silk to this day.
__________________ Officer: "I see you set the table for four." Groucho Marx: "That's nothing--I set my alarm clock for eight."