In this study we have constructed a mathematical model of a recently proposed functional model known to be responsible for inducing waking, NREMS and REMS. Simulation studies using this model reproduced sleep-wake patterns as reported in normal animals. The model helps to explain neural mechanism(s) that underlie the transitions between wake, NREMS and REMS as well as how both the homeostatic sleep-drive and the circadian rhythm shape the duration of each of these episodes. In particular, this mathematical model demonstrates and confirms that an underlying mechanism for REMS generation is pre-synaptic inhibition from substantia nigra onto the REM-off terminals that project on REM-on neurons, as has been recently proposed. The importance of orexinergic neurons in stabilizing the wake-sleep cycle is demonstrated by showing how even small changes in inputs to or from those neurons can have a large impact on the ensuing dynamics. The results from this model allow us to make predictions of the neural mechanisms of regulation and patho-physiology of REMS.