add simulation fns based on num_rows
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 8 Jul 2019 09:40:25 +0000 (10:40 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 8 Jul 2019 09:40:25 +0000 (10:40 +0100)
src/ieee754/fpcommon/test/fpmux.py

index 601e5461aa8da31576aa6938f745888b7acf396e..273c80253fe9db0d78a3310de898d1042a3200c9 100644 (file)
@@ -10,7 +10,7 @@ from nmigen.compat.sim import run_simulation
 from nmigen.cli import verilog, rtlil
 
 
-class InputTest:
+class MuxInOut:
     def __init__(self, dut, width, fpkls, fpop, vals, single_op):
         self.dut = dut
         self.fpkls = fpkls
@@ -178,11 +178,9 @@ def runfp(dut, width, name, fpkls, fpop, single_op=False, n_vals=10, vals=None):
     if vals is None:
         vals = create_random(dut.num_rows, width, single_op, n_vals)
 
-    test = InputTest(dut, width, fpkls, fpop, vals, single_op)
-    run_simulation(dut, [test.rcv(1), test.rcv(0),
-                         test.rcv(3), test.rcv(2),
-                         test.send(0), test.send(1),
-                         test.send(3), test.send(2),
-                        ],
-                   vcd_name="%s.vcd" % name)
-
+    test = MuxInOut(dut, width, fpkls, fpop, vals, single_op)
+    fns = []
+    for i in range(dut.num_rows):
+        fns.append(test.rcv(i))
+        fns.append(test.send(i))
+    run_simulation(dut, fns, vcd_name="%s.vcd" % name)