I have been working on a auto-reversing system based around a PIC18F1220. All code was written in C and so far it seems to be working well. I'm planning to use this on my layout in addition to the DCC mainline to run a tram/metro train back and fourth on a single line. Here are a couple of quick demo videos:
So, it looks like the PIC is just triggering a relay. I don't understand the reason for using the PIC, if that's all I was doing I would just use a latching relay and have the switch at each end of the run trigger the relay. A better solution would be to drive an H-Bridge with a PWM signal, that way you could ramp the speed down and up when reversing, and even put a delay in at each end. That would look much better and be easier on the drivetrain than the sudden reversal of flipping a relay.
Since posting this I have added a 2x4 jumper block to implement delay. The PIC gives me complete flexibility in the design.