This invention relates to compounds that are agonists of the muscarinic M
1
receptor or M
1
and M
4
receptors and which are useful in the treatment of muscarinic M
1
or M
1
/M
4
receptor mediated diseases. Also provided are pharmaceutical compositions containing the compounds and the therapeutic uses of the compounds. Compounds provided are of formula
wherein Q
4
, Q
5
, R
5
, p, V, Q
1
, Q
2
, X
1
, X
2
and W are defined herein.