Do you want to unit test the driver for the FPGA, or do you want to unit test the protocol?
Because if you want to test both, it would already look like a (system) integration test to me.
Yes, it is possible to test the communications library in isolation. Make sure your communications protocol is not too interwoven with the device driver; this way you can test it in isolation.
My suggestion:
- unit test small parts; test them throroughly
- check what you want of the integration test; lots of data or stress test? make it orthogonal to the unit test
- if you mock up the hardware, make it very simple
The kind of errors which I would be interested in when testing the FPGA+communications library:
- is it handling the protocol according to specs?
- how does it behave on buffer overflow / underflow?
- is the interrupt handling working as expected?
- does it handle all rsx22 signals (break, parity, stop bits) correctly?
As for the simulation: I've had very good results running code within Matlab/Simulink (i.e. using TrueTime, a free plugin). Simulink can then be used to hook up to either hardware in the loop (HIL) or a model in the loop. Alternatively a software mockup could be used (but it is often hard to simulate asynchronous events which are sooo interesting if you're close-to-the-hardware; i.e. interrupt handlers)