2 from random
import randint
3 from random
import seed
4 from operator
import truediv
6 from nmigen
import Module
, Signal
7 from nmigen
.compat
.sim
import run_simulation
9 from nmigen_div_experiment
import FPDIV
11 from unit_test_single
import (get_mantissa
, get_exponent
, get_sign
, is_nan
,
12 is_inf
, is_pos_inf
, is_neg_inf
,
13 match
, get_case
, check_case
, run_test
,
18 yield from check_case(dut
, 0x2b017, 0xff3807ab, 0x80000000)
19 yield from check_case(dut
, 0x40000000, 0x3F800000, 0x40000000)
20 yield from check_case(dut
, 0x3F800000, 0x40000000, 0x3F000000)
21 yield from check_case(dut
, 0x3F800000, 0x40400000, 0x3EAAAAAB)
22 yield from check_case(dut
, 0x40400000, 0x41F80000, 0x3DC6318C)
23 yield from check_case(dut
, 0x41F9EB4D, 0x429A4C70, 0x3ECF52B2)
24 yield from check_case(dut
, 0x7F7FFFFE, 0x70033181, 0x4EF9C4C8)
25 yield from check_case(dut
, 0x7F7FFFFE, 0x70000001, 0x4EFFFFFC)
26 yield from check_case(dut
, 0x7F7FFCFF, 0x70200201, 0x4ECCC7D5)
27 yield from check_case(dut
, 0x70200201, 0x7F7FFCFF, 0x302003E2)
32 stimulus_a
= [0xbf9b1e94, 0x34082401, 0x5e8ef81, 0x5c75da81, 0x2b017]
33 stimulus_b
= [0xc038ed3a, 0xb328cd45, 0x114f3db, 0x2f642a39, 0xff3807ab]
34 yield from run_test(dut
, stimulus_a
, stimulus_b
, truediv
)
35 count
+= len(stimulus_a
)
36 print (count
, "vectors passed")
39 from itertools
import permutations
40 stimulus_a
= [i
[0] for i
in permutations([0x80000000, 0x00000000, 0x7f800000, 0xff800000, 0x7fc00000, 0xffc00000], 2)]
41 stimulus_b
= [i
[1] for i
in permutations([0x80000000, 0x00000000, 0x7f800000, 0xff800000, 0x7fc00000, 0xffc00000], 2)]
42 yield from run_test(dut
, stimulus_a
, stimulus_b
, truediv
)
43 count
+= len(stimulus_a
)
44 print (count
, "vectors passed")
46 yield from run_edge_cases(dut
, count
, truediv
)
49 if __name__
== '__main__':
51 run_simulation(dut
, testbench(dut
), vcd_name
="test_div.vcd")