This is a post that relates to C programming rather than hardware development, for a change.
Two things I'm a big fan of when developing software is designing with assertions (e.g.
assert(index >= 0); in C) and Unit Testing (Unit Testing Wikipedia article).
Assertions is available in VHDL as well. I motivate their use in the post Assertions - extending their use and much of that will be valid also in a software context.
This post will describe the way I use to integrate the C
assert(...) statements into the test routines utilizing a Unit Testing Framework. I use the CUnit framework but the method will work with any framework.