||A multi-layer semi-implicit spherical spectral method for simulating core convection is described. The fully compressible three-dimensional hydrodynamic equations with rotation and energy generation are solved. Multi-layer scheme is employed to overcome the CFL problem arising from the shrinking grid size in the physical space near the center of the sphere. With this scheme, the code demonstrates the ability of using reasonable large time steps for integration all over the sphere. The time step is only restricted by the CFL condition associated with the subsonic fluid motions. The code is parallelized; with 12 processors the speed up factor is about 9. With this code, I have performed numerical simulations of core convection in stars, core convection and upward overshooting with rotation in stars, and effects of solid core size on planetary convection. In the simulation of core convection in stars, it is found that: (1)rotation tends to hinder the turbulent convection and drive meridional circulation; (2)kinetic energy has substantial impact on energy transportation and cannot be neglected; (3) with certain rotation rate, columnar structure of time averaged zonal velocity is observed, and single cell meridional circulation is formed. In the simulation of core convection and upward overshooting, it is found that: (1)the granular cells merge, split and self-destruct from time to time; (2)the zonal wind is prograde in the inner region and retrograde in the outer region at lower Co (Coriolis number), while the direction of zonal wind reverses at higher Co; (3)columnar structure of angular velocity contour profiles appears in the faster rotating cases. (4)the extent of overshooting increases as rotation rate increases; (5)single cell meridional circulation gives way to multiple cells circulation when Taylor-Proudman balance is significant. (6)external meridional circulations are developed in the radiative layer at high Co. In the simulation of effects of solid core size on planetary convection, it is found that: (1)the speed of surface prograde zonal jet increases as solid core size ratio χ increases from 0 to 0.35, while decreases as χ increases to 0.75. (2)Columnar effect is important when solid core size is large.