We study the relation between Donaldson-Thomas theory of Calabi-Yau threefolds and a six-dimensional topological Yang-Mills theory. Our main example is the topological U (N ) gauge theory on flat space in its Coulomb branch. To evaluate its partition function we use equivariant localization techniques on its noncommutative deformation. As a result the gauge theory localizes on noncommutative instantons which can be classified in terms of N -coloured three-dimensional Young diagrams. We give to these noncommutative instantons a geometrical description in terms of certain stable framed coherent sheaves on projective space by using a higher-dimensional generalization of the ADHM formalism. From this formalism we construct a topological matrix quantum mechanics which computes an index of BPS states and provides an alternative approach to the six-dimensional gauge theory.