Unfortunately, I have had some first hand experience of this issue which was only rectified by the intervention of a third party. (I'll try to keep this objective but I have strong opinions, so some of them may bleed through.)
This is going to be quite a long post I'm afraid but the summation is simple:
Who says things are going badly? Speak to your boss. If they're the person judging you, they must have criteria.
Are you being judged fairly. Not just within your team but within the company as a whole.
How badly are things going, really? Is this a minor problem or something that you really need to deal with immediately.
Speak to someone. Not a co-worker but someone who understands your environment and will be honest with you. I would recommend someone senior in another area of the business. It's critical, absolutely critical that you make the conversation objective. It cannot be seen as criticism of your current boss, or an attempt to go over his/her head. That would be Very Bad.
Now the long version...
You need to initially determine:
- Where things are going wrong
- How badly they're going
- What can be done, in the short term, to get things back on track
..then:
- Why things are going wrong
- How you can resolve the situation permanently
It's important to bear in mind the fact that people don't change all that drastically, over time. Whilst you can make a huge change very quickly, this change will be hard to maintain. You need to be realistic about the situation and your ability to resolve it whilst also being aware that -you- haven't changed much from the person that was previously doing so well.
Where things are going wrong
Are you failing to meet objectives?
If so, are the objectives realistic? Unrealistic goals and deadlines are common and very divisive.
Are you being expected to work in a way that doesn't suit you or are you working in a way that is not supported by your colleagues and/or boss?
How badly are things going
Everyone has ups and downs. When things are going badly, it can become self-perpetuating and you can make additional bad decisions due to poor morale or by the inclination to over-reach in an attempt to salvage things.
It may be that things aren't as bad as you fear.
What can be done in the short term
It's useful to start performing adequately, quickly. It takes the heat off you and will give you the time and space needed to make long term changes. It's horrible to work in an environment where it feels that you're not doing your job correctly.
Speak to your boss. Agree (and document) an approach for the next month or two. Keep it simple, don't admit to every small sin you think you've committed. Get your boss to say "If this is done, I'm happy". Stick to that formula, get some time to clear your head.
Why things are going wrong
This is the hardest issue to resolve but often the simplest to diagnose.
Is the work too hard?
Is there too much of it?
Do you and your boss have different methods of working? (that was my problem)
Have you lost motivation?
Are you slacking off?
How you can resolve the situation permanently
This, obviously, depends on the problem. Remember, you've not become useless overnight. Leaving the company is the ultimate last resort, so don't look at that until things become intolerable.
With a bit of luck, you will be able to address and resolve the problem by having an objective discussion with your boss. It's also worth considering whether you need to bring in an intermediary. The company I worked for had a system of Personal Managers who handled the pastoral care of their employees, something which I initially was dubious of. In the end, it saved my career. :)
Address the problem directly, assuming that the fault may or my not be with you. If you're a professional, you owe it to your company to provide them with the service that they're paying for but making yourself miserable doing it is a false economy.
Good luck!