  Electronic structures of carbides with the rocksalt structure were calculated
by full potential electronic codes solving the Kohn-Sham equation. Bonding
characters were analyzed by constructing tight-binding Hamiltonian based on
maximally-localized Wannier functions. It was found that the cations in these
compounds act as an electron provider and the frame is formed by the carbon
atoms. The electronic states in the vicinity of the Fermi level are mainly from
the p-orbitals of C. Pressure and doping are two efficient ways to tune the
magnetic and electronic properties of these compounds. It turns out that a spin
gapless semiconductor can be obtained by applying hydrostatic pressure up to
tens of gigaPascal. Higher pressure induced an insulator to metal transition
because of band broadening. Compounds of IA group (Na, K, Rb, Cs) were magnetic
semiconductor at ambient conditions. Alloying with IIA elements decrease the
magnetic moment according to the law of $3-x$, where $x$ is the relative atomic
ratio of the IIA elements to the IA ones. The behaviors of the compounds under
the pressure and the doping effects can be understood by a rigid band model.
