문제

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 gets q (integer square root of N) and r (integer remainder)

So for correctness, your TB must check that q*q+r equals N for every N within the range defined by the number of bits N has

다른 팁

Instead of trying to precompute the desired answer, just pick random binary integers in the correct range and square them. Feed the squared value to your square root algorithm and then verify that the original randomly chosen binary value pops out.

A self-checking test bench doesn't necessarily need to use random inputs or be exhaustive, it just needs to verify the results and tell you whether the design under test has passed or failed. You shouldn't need to check any values manually or look at any traces in the simulator.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top