A Framingham man has been sentenced to two years in prison after being convicted of sexually assaulting a child.