How can we read two digital inputs simultaneously from ATxMega128?
Hassan's answer is not quite accurate. If you really want to read both inputs at the same time, you can do that so long as they both reside on the same port.

uint8_t sample = PORTD.IN;
uint8_t bit3   = (sample &gt;&gt; 3) &amp; 1;
uint8_t bit7   = (sample &gt;&gt; 7) &amp; 1;


Now you can be asured that bit3 and bit7 are from the same time sample. If you use PORTD.IN in multiple places, they are all distinct readings from the pins. Read the PORT.IN into a temporary variable and base your decisions on that sample.