The modes of oscillation and radiated acoustic fields of compressible flows over open cavities are investigated computationally. The compressible Navier-Stokes equations are solved for two-dimensional cavities with laminar boundary layers upstream. The high-order and high-resolution numerical schemes are used for the evaluation of spatial derivatives and the time integration. Physically correct numerical boundary conditions are implemented to produce time-accurate solutions in the whole computation domain. The computational domain is large enough to directly resolve a portion of the radiated acoutic field. The results show a transition from a shear layer mode, for shorter cavities and lower Mach numbers, to a wake mode for longer cavities and higher Mach numbers. The shear layer mode is well characterized by Rossiter modes and these oscillations lead to intense upstream acoustic radiation dominated by a single frequency. The wake mode is characterized instead by a large-scale vortex shedding. Acoustic radiation is more intense, with multiple frequencies present.