Time for you to talk with your Doctor about this instead of here. Could be hardening of the arteries or several other things causing it. Your Doctor will know if you need tests or any prescriptions. Safest thing to do. I know it isn't easy to just start talking about this with your Doc but they understand and will help you out.
There are multiple things which can causes ED like physical issues,
psychological issues, poor diet, lack of exercise or bad masturbatory habits etc, but don't take it normally. It is very serious health condition. It is treated with Sildenafil Citrate medicine, as it is one of the best therapy for ED condition in men.