??? 11/13/06 17:10 Read: times |
#127887 - test bench Responding to: ???'s previous message |
Russ Cooper said:
Thanks, Jez. I think that's what I thought. When programming in C, if I write a function like this:
int Add(int a, int b) { return a + b; } then I can also write a throw-away function like this to test Add() in isolation from all the rest of my functions: void main() { printf("3 + 5 = %dn", Add(3, 5)); } If I understand you correctly, this second function is vaguely equivalent to your "test bench", and by the time I finally get it to print out "3 + 5 = 8", I have a fair degree of confidence that both the test bench and the function under test (FUT) are correct. Correct? Very vaguely equivalent. A proper test bench will compare the response to the given stimulus to the known correct value and tell you if you fail. (This way, you don't have to search through a lot of waveforms looking for the failure.) So, to use your C example, void main() { int x = 3; int y = 5; int expected_sum = 8; int Add_result; Add_result = Add(x,y); if (Add_result != expected_sum) printf("failure! Add_result %d didn't match expected %d\n", Add_result, expected_sum); } Again, the beauty of this is that you're told when you fail, not that you've passed a million tests. -a |