I agree with the others, both cities give you enough for one day. Heidelberg appears to be a "must" for US tourists whereas Trier is a "must" for Chinese tourists (not because of the Romans but because Karl Marx was born in Trier).
You can easily do Trier and Luxemburg (44 minutes by train) and you can do Heidelberg and spend a day in the vinyards at the banks of the Rhine.
One remark regarding German universities: Heidelberg is not the "oldest German university" but the "oldest German university on todays territory of the Federal Republic of Germany" and was founded in 1386. The oldest German university was - believe it or not - in Praque (1348), followed by Vienna (1365). All three cities were part of the German Empire of those days (by the way: ruled by an Emperor belonging to the Luxembourg family during those days - some kind of EU in the 14th century).