Yes it will fit.
but you will need to set the core voltage to 3V (5V default for 040) and CPU multiplier to 1X (0.5X default for 040 - unless the oscillator is lower than 50mhz).
Be sure your board can make those changes before you start any kind of project!