print (count, "vectors passed")
-def run_edge_cases(dut, count, op):
+def run_edge_cases(dut, count, op, maxcount=1000, num_loops=1000):
#edge cases
- stimulus_a = [0x8000000000000000 for i in range(1000)]
- stimulus_b = [randint(0, 1<<64) for i in range(1000)]
+ stimulus_a = [0x8000000000000000 for i in range(maxcount)]
+ stimulus_b = [randint(0, 1<<64) for i in range(maxcount)]
yield from run_test(dut, stimulus_a, stimulus_b, op)
count += len(stimulus_a)
print (count, "vectors passed")
- stimulus_a = [0x0000000000000000 for i in range(1000)]
- stimulus_b = [randint(0, 1<<64) for i in range(1000)]
+ stimulus_a = [0x0000000000000000 for i in range(maxcount)]
+ stimulus_b = [randint(0, 1<<64) for i in range(maxcount)]
yield from run_test(dut, stimulus_a, stimulus_b, op)
count += len(stimulus_a)
print (count, "vectors passed")
- stimulus_b = [0x8000000000000000 for i in range(1000)]
- stimulus_a = [randint(0, 1<<64) for i in range(1000)]
+ stimulus_b = [0x8000000000000000 for i in range(maxcount)]
+ stimulus_a = [randint(0, 1<<64) for i in range(maxcount)]
yield from run_test(dut, stimulus_a, stimulus_b, op)
count += len(stimulus_a)
print (count, "vectors passed")
- stimulus_b = [0x0000000000000000 for i in range(1000)]
- stimulus_a = [randint(0, 1<<64) for i in range(1000)]
+ stimulus_b = [0x0000000000000000 for i in range(maxcount)]
+ stimulus_a = [randint(0, 1<<64) for i in range(maxcount)]
yield from run_test(dut, stimulus_a, stimulus_b, op)
count += len(stimulus_a)
print (count, "vectors passed")
- stimulus_a = [0x7FF8000000000000 for i in range(1000)]
- stimulus_b = [randint(0, 1<<64) for i in range(1000)]
+ stimulus_a = [0x7FF8000000000000 for i in range(maxcount)]
+ stimulus_b = [randint(0, 1<<64) for i in range(maxcount)]
yield from run_test(dut, stimulus_a, stimulus_b, op)
count += len(stimulus_a)
print (count, "vectors passed")
- stimulus_a = [0xFFF8000000000000 for i in range(1000)]
- stimulus_b = [randint(0, 1<<64) for i in range(1000)]
+ stimulus_a = [0xFFF8000000000000 for i in range(maxcount)]
+ stimulus_b = [randint(0, 1<<64) for i in range(maxcount)]
yield from run_test(dut, stimulus_a, stimulus_b, op)
count += len(stimulus_a)
print (count, "vectors passed")
- stimulus_b = [0x7FF8000000000000 for i in range(1000)]
- stimulus_a = [randint(0, 1<<64) for i in range(1000)]
+ stimulus_b = [0x7FF8000000000000 for i in range(maxcount)]
+ stimulus_a = [randint(0, 1<<64) for i in range(maxcount)]
yield from run_test(dut, stimulus_a, stimulus_b, op)
count += len(stimulus_a)
print (count, "vectors passed")
- stimulus_b = [0xFFF8000000000000 for i in range(1000)]
- stimulus_a = [randint(0, 1<<64) for i in range(1000)]
+ stimulus_b = [0xFFF8000000000000 for i in range(maxcount)]
+ stimulus_a = [randint(0, 1<<64) for i in range(maxcount)]
yield from run_test(dut, stimulus_a, stimulus_b, op)
count += len(stimulus_a)
print (count, "vectors passed")
- stimulus_a = [0x7FF0000000000000 for i in range(1000)]
- stimulus_b = [randint(0, 1<<64) for i in range(1000)]
+ stimulus_a = [0x7FF0000000000000 for i in range(maxcount)]
+ stimulus_b = [randint(0, 1<<64) for i in range(maxcount)]
yield from run_test(dut, stimulus_a, stimulus_b, op)
count += len(stimulus_a)
print (count, "vectors passed")
- stimulus_a = [0xFFF0000000000000 for i in range(1000)]
- stimulus_b = [randint(0, 1<<64) for i in range(1000)]
+ stimulus_a = [0xFFF0000000000000 for i in range(maxcount)]
+ stimulus_b = [randint(0, 1<<64) for i in range(maxcount)]
yield from run_test(dut, stimulus_a, stimulus_b, op)
count += len(stimulus_a)
print (count, "vectors passed")
- stimulus_b = [0x7FF0000000000000 for i in range(1000)]
- stimulus_a = [randint(0, 1<<64) for i in range(1000)]
+ stimulus_b = [0x7FF0000000000000 for i in range(maxcount)]
+ stimulus_a = [randint(0, 1<<64) for i in range(maxcount)]
yield from run_test(dut, stimulus_a, stimulus_b, op)
count += len(stimulus_a)
print (count, "vectors passed")
- stimulus_b = [0xFFF0000000000000 for i in range(1000)]
- stimulus_a = [randint(0, 1<<64) for i in range(1000)]
+ stimulus_b = [0xFFF0000000000000 for i in range(maxcount)]
+ stimulus_a = [randint(0, 1<<64) for i in range(maxcount)]
yield from run_test(dut, stimulus_a, stimulus_b, op)
count += len(stimulus_a)
print (count, "vectors passed")
#seed(0)
- for i in range(100000):
- stimulus_a = [randint(0, 1<<64) for i in range(1000)]
- stimulus_b = [randint(0, 1<<64) for i in range(1000)]
+ for i in range(num_loops):
+ stimulus_a = [randint(0, 1<<64) for i in range(maxcount)]
+ stimulus_b = [randint(0, 1<<64) for i in range(maxcount)]
yield from run_test(dut, stimulus_a, stimulus_b, op)
- count += 1000
+ count += maxcount
print (count, "random vectors passed")
yield from run_test(dut, stimulus_a, stimulus_b, op, get_case_fn)
yield from run_test(dut, stimulus_b, stimulus_a, op, get_case_fn)
-def run_cases(dut, count, op, fixed_num, num_entries, get_case_fn):
+def run_cases(dut, count, op, fixed_num, maxcount, get_case_fn):
if isinstance(fixed_num, int):
- stimulus_a = [fixed_num for i in range(num_entries)]
+ stimulus_a = [fixed_num for i in range(maxcount)]
report = hex(fixed_num)
else:
stimulus_a = fixed_num
report = "random"
- stimulus_b = [randint(0, 1<<32) for i in range(num_entries)]
+ stimulus_b = [randint(0, 1<<32) for i in range(maxcount)]
yield from run_test_2(dut, stimulus_a, stimulus_b, op, get_case_fn)
count += len(stimulus_a)
print (count, "vectors passed 2^32", report)
# non-canonical NaNs.
stimulus_b = [set_exponent(randint(0, 1<<32), 128) \
- for i in range(num_entries)]
+ for i in range(maxcount)]
yield from run_test_2(dut, stimulus_a, stimulus_b, op, get_case_fn)
count += len(stimulus_a)
print (count, "vectors passed Non-Canonical NaN", report)
# -127
stimulus_b = [set_exponent(randint(0, 1<<32), -127) \
- for i in range(num_entries)]
+ for i in range(maxcount)]
yield from run_test_2(dut, stimulus_a, stimulus_b, op, get_case_fn)
count += len(stimulus_a)
print (count, "vectors passed exp=-127", report)
# nearly zero
stimulus_b = [set_exponent(randint(0, 1<<32), -126) \
- for i in range(num_entries)]
+ for i in range(maxcount)]
yield from run_test_2(dut, stimulus_a, stimulus_b, op, get_case_fn)
count += len(stimulus_a)
print (count, "vectors passed exp=-126", report)
# nearly inf
stimulus_b = [set_exponent(randint(0, 1<<32), 127) \
- for i in range(num_entries)]
+ for i in range(maxcount)]
yield from run_test_2(dut, stimulus_a, stimulus_b, op, get_case_fn)
count += len(stimulus_a)
print (count, "vectors passed exp=127", report)
return count
-def run_edge_cases(dut, count, op, get_case_fn):
+def run_edge_cases(dut, count, op, get_case_fn, maxcount=10, num_loops=1000):
#edge cases
for testme in corner_cases:
- count = yield from run_cases(dut, count, op, testme, 10, get_case_fn)
+ count = yield from run_cases(dut, count, op, testme,
+ maxcount, get_case_fn)
- for i in range(100000):
- stimulus_a = [randint(0, 1<<32) for i in range(10)]
+ for i in range(num_loops):
+ stimulus_a = [randint(0, 1<<32) for i in range(maxcount)]
count = yield from run_cases(dut, count, op, stimulus_a, 10,
get_case_fn)
return count
run_edge_cases, run_corner_cases)
-def tbench(dut):
+def tbench(dut, maxcount, num_loops):
yield from check_case(dut, 0x40000000, 0x40000000, 0x40800000)
yield from check_case(dut, 0x41400000, 0x40A00000, 0x42700000)
print (count, "vectors passed")
yield from run_corner_cases(dut, count, mul, get_case)
- yield from run_edge_cases(dut, count, mul, get_case)
+ yield from run_edge_cases(dut, count, mul, get_case, maxcount, num_loops)
-def test1():
+def test1(maxcount=10, num_loops=5):
dut = FPMUL(width=32)
- run_simulation(dut, tbench(dut), vcd_name="test_mul.vcd")
+ run_simulation(dut, tbench(dut, maxcount, num_loops),
+ vcd_name="test_mul.vcd")
if __name__ == '__main__':
- test1()
+ test1(maxcount=1000, num_loops=1000)