Age of consent

I'm kind of confused on what age of consent is? I always thought that that was the age that it was legal to have sex at.. For example, the age of consent in Tennessee is 18. Does that mean that it's illegal to have sex unless you're 18, or that it's illegal for an adult to have sex with someone unless they're 18 or older? I know many girls that have been 15, 16, or 17 and have gotten pregnant. Would they get in trouble with the law for having sex because it's illegal to have sex before you're 18? Or is it only illegal if they're under 18 and are having sex with someone that's older than 18? I'm just very confused on what age of consent means. I'm 16 and I've messed around with my boyfriend a lot but he's never penetrated me, but I don't wanna wait until I'm 18. If I had sex now at 16 would that be illegal?