  Ab initio random structure searching (AIRSS) and density functional theory
methods are used to predict structures of calcium and magnesium carbonate
(CaCO$_3$ and MgCO$_3$) at high pressures. We find a previously unknown
CaCO$_3$ structure which is more stable than the aragonite and "post aragonite"
phases in the range 32--48 GPa. At pressures from 67 GPa to well over 100 GPa
the most stable phase is a previously unknown CaCO$_3$ structure of the
pyroxene type with fourfold coordinated carbon atoms. We also predict a stable
structure of MgCO$_3$ in the range 85--101 GPa. Our results lead to a revision
of the phase diagram of CaCO$_3$ over more than half the pressure range
encountered within the Earth's mantle, and smaller changes to the phase diagram
of MgCO$_3$. We predict CaCO$_3$ to be more stable than MgCO$_3$ in the Earth's
mantle above 100 GPa, and that CO$_2$ is not a thermodynamically stable
compound under deep mantle conditions. Our results have significant
implications for understanding the Earth's deep carbon cycle.
