split out p.i_valid logic into separate function, use in combpipe as well