change log2 to consider log2(1) == 0
use non-blocking assignments in testbench