slip a cog
To become mentally unbalanced, disturbed, or confused. Usually used humorously or facetiously. Sorry, I must have slipped a cog, because I have no idea what I was talking about just now. Grandpa, I think you've slipped a cog—I've never heard of that movie and I can't find it anywhere online!
slip a cog
Also, slip a gear or one's gears . Lose one's ability to reason soundly or make correct judgments, as in She must have slipped a cog or she would never have gone out barefoot in December, or What's the matter with him? Has he slipped his gears? These slangy usages allude to a mechanical failure owing to the cog of a gear or a gear failing to mesh. The first dates from about 1930, the variant from the 1960s.