Curious to know how the car knows the MPG it's getting. Is it from the PCM?

I was wondering if I could mod it to read instant MPG, and if anyone has done it before. Did a search with no luck.