The construction of the CNF formula is the essence of the Cook Levin theorem. The theorem itself is quite involved, but in the past people have presented that as their P4 project. You can do a quick google search for that and find it.
The fact that the formula is polynomial in terms of f(n), is the key aspect of that. The theorem shows that the solving a given problem instance using its NTM is equivalent to the formula being satisfiable. Thus, CSAT is NP-hard.