I have written verilog code for a non-restoring square root algorithm which is synthesisable. My senior says that it now requires a self checking testbench. I know that there is an operator $sqrt in verilog, which is applicable to real numbers. I am dealing with binary bits.
So what can I do to create a self checking testbench for this maths function?
If your algortihm gets both the square root and the remainder, you can do a TB that performs the inverse operation, that is:
Given
N, your algorithm getsq(integer square root ofN) andr(integer remainder)So for correctness, your TB must check that
q*q+requalsNfor everyNwithin the range defined by the number of bitsNhas