The best way to tell what engine you have is to remove the starter and look at the casting part number. That p/n should follow the form of CAE-6015-E, C6AE-6015-C, C8OE-6015-A or C8AE-6015-B if the engine is a 6 bolt 289CID. A 302CID will have a p/n of C8OE-6015-A. The date the block was cast is also there.
A short cut method would be to look at the actual engine assembly date stamped on the block near the distributor, see the picture. It will be in the format of 5H26Z, 5 = year; 1965; H = month, August; 26 = day; Z = inspector/assembly id. A 289 will be have a 5, 6 or 7 before June (letter F). Ford made 302CID engines from June 67 on and used either a 289 or 302 in 1968. A date stamp of 8Axx on would be a 302CID. The two engines are "almost" interchangeable.
A 351W has higher heads than a 289/302 because the head mounting surface was cast about 1/2 higher and Ford used an adapter plate/bar to mount the alternator. A 351W will fit in a 64-66 Mustang engine bay but it is tight around the exhaust and air cleaner.