Esempio n. 1
0
    def test_one(self):
        packet = [2159820100L,  878477756, pow(2, 23)+1, 2, 3, 4]
        packets = [packet]*10
        data = range(1, 100)
        for packet in packets:
            data.extend(packet)
            data.extend(range(100, 110))

        buffer_length = 128
        defines = config.updated_defines(
            {'COMBINER_BUFFER_LENGTH': buffer_length,
             'LOG_COMBINER_BUFFER_LENGTH': logceil(buffer_length),
             'MAX_PACKET_LENGTH': pow(2, config.msg_length_width),
             })
        executable = buildutils.generate_icarus_executable(
            'message', 'message_stream_combiner_one', '-72', defines=defines)
        fpgaimage = buildutils.generate_B100_image(
            'message', 'message_stream_combiner_one', '-72', defines=defines)
        tb_icarus = TestBenchIcarusOuter(executable, in_raw=data)
        tb_b100 = TestBenchB100(fpgaimage, in_raw=data)

        for tb, steps in (
                (tb_icarus, 10000),
                (tb_b100, 100000), 
                ):
            tb.run(steps)
            self.assertEqual(len(data), len(tb.out_raw))
            for e, r in zip(data, tb.out_raw):
                self.assertEqual(e, r)
Esempio n. 2
0
 def test_one(self):
     """
     Tests passing debug messages back.
     """
     width = 32
     sendnth = 2
     max_val = pow(2, width-2)-1
     n_data = 10
     in_data = [random.randint(1, max_val) for i in range(n_data)]
     defines = config.updated_defines({})
     executable = buildutils.generate_icarus_executable(
         'message', 'debug', '-test', defines=defines)
     fpgaimage = buildutils.generate_B100_image(
         'message', 'debug', '-test', defines=defines)
     tb_icarus = TestBenchIcarusOuter(executable, in_raw=in_data,
                                      sendnth=sendnth)
     tb_b100 = TestBenchB100(fpgaimage, in_raw=in_data)
     for tb, steps in (
         #(tb_icarus, len(in_data)*sendnth*2+1000),
         (tb_b100, 100000), 
         ):
         tb.run(steps)
         r_samples, r_packets = msg_utils.stream_to_samples_and_packets(
             tb.out_raw, config.msg_length_width, width)
         print(in_data)
         print(r_samples)
         print(r_packets)
         self.assertEqual(len(in_data), len(r_samples))
         for e, r in zip(in_data, r_samples):
             self.assertEqual(e, r)
         e_even = [s for s in in_data if s%2==0]
         r_even = [p[1] for p in r_packets]
         self.assertEqual(len(e_even), len(r_even))
         for e, r in zip(e_even, r_even):
             self.assertEqual(e, r)
Esempio n. 3
0
    def test_one(self):
        packet = [2159820100L, 878477756, pow(2, 23) + 1, 2, 3, 4]
        packets = [packet] * 10
        data = range(1, 100)
        for packet in packets:
            data.extend(packet)
            data.extend(range(100, 110))

        buffer_length = 128
        defines = config.updated_defines({
            'COMBINER_BUFFER_LENGTH':
            buffer_length,
            'LOG_COMBINER_BUFFER_LENGTH':
            logceil(buffer_length),
            'MAX_PACKET_LENGTH':
            pow(2, config.msg_length_width),
        })
        executable = buildutils.generate_icarus_executable(
            'message', 'message_stream_combiner_one', '-72', defines=defines)
        fpgaimage = buildutils.generate_B100_image(
            'message', 'message_stream_combiner_one', '-72', defines=defines)
        tb_icarus = TestBenchIcarusOuter(executable, in_raw=data)
        tb_b100 = TestBenchB100(fpgaimage, in_raw=data)

        for tb, steps in (
            (tb_icarus, 10000),
            (tb_b100, 100000),
        ):
            tb.run(steps)
            self.assertEqual(len(data), len(tb.out_raw))
            for e, r in zip(data, tb.out_raw):
                self.assertEqual(e, r)
Esempio n. 4
0
 def test_one(self):
     """
     Test the multiply module.
     """
     sendnth = 2
     n_data = 1000
     in_samples = []
     expected = []
     # We send samples a + bj and expected returned 0 + abj.
     in_samples = [random.random()*2-1 + random.random()*2j-1j for i in range(n_data)]
     expected = [c.real*c.imag*1j for c in in_samples]
     steps_rqd = len(in_samples)*sendnth*2 + 100
     executable_inner = buildutils.generate_icarus_executable(
         'fpgamath', 'multiply_inner', '-test',)
     executable_outer = buildutils.generate_icarus_executable(
         'fpgamath', 'multiply', '-test',)
     fpgaimage = buildutils.generate_B100_image(
         'fpgamath', 'multiply', '-test')
     tb_icarus_inner = TestBenchIcarusInner(executable_inner, in_samples,
                                            sendnth=sendnth)
     tb_icarus_outer = TestBenchIcarusOuter(executable_outer, in_samples,
                                            sendnth=sendnth)
     tb_b100 = TestBenchB100(fpgaimage, in_samples)
     for tb, steps, check_ms in (
             (tb_icarus_inner, steps_rqd, True),
             (tb_icarus_outer, steps_rqd, False),
             (tb_b100, 100000, False), 
             ):
         tb.run(steps)
         # Confirm that our data is correct.
         self.assertEqual(len(tb.out_samples), len(expected))
         for r, e in zip(tb.out_samples, expected):
             self.assertAlmostEqual(e, r, 3)
Esempio n. 5
0
 def test_one(self):
     """
     Test the buffer_AA and buffer_BB module.
     """
     width = config.default_width
     sendnth = 1
     maxint = pow(2, width)-1
     buffer_length = 32
     n_data = 100
     data = [random.randint(1, maxint) for d in range(n_data)]
     # How many steps are required to simulate the data.
     steps_rqd = n_data * sendnth * 2 + 1000
     # Create, setup and simulate the test bench.
     defines = config.updated_defines(
         {'WIDTH': width,
          'BUFFER_LENGTH': buffer_length,
          'LOG_BUFFER_LENGTH': logceil(buffer_length),
          'WRITEERRORCODE': 666,
          'READERRORCODE': 777,
          })
     executableAA = buildutils.generate_icarus_executable(
         'flow', 'buffer_AA', '-test', defines=defines)
     fpgaimageAA = buildutils.generate_B100_image(
         'flow', 'buffer_AA', '-test', defines=defines)
     executableBB = buildutils.generate_icarus_executable(
         'flow', 'buffer_BB', '-test', defines=defines)
     fpgaimageBB = buildutils.generate_B100_image(
         'flow', 'buffer_BB', '-test', defines=defines)
     tb_icarusAA = TestBenchIcarusOuter(executableAA, in_raw=data,
                                      output_msgs=False)
     tb_b100AA = TestBenchB100(fpgaimageAA, in_raw=data, output_msgs=False)
     tb_icarusBB = TestBenchIcarusOuter(executableBB, in_raw=data,
                                      output_msgs=False)
     tb_b100BB = TestBenchB100(fpgaimageBB, in_raw=data, output_msgs=False)
     for tb, steps in (
             (tb_icarusAA, steps_rqd),
             (tb_b100AA, 100000), 
             (tb_icarusBB, steps_rqd),
             (tb_b100BB, 100000), 
             ):
         tb.run(steps)
         # Confirm that our data is correct.
         stream = None
         self.assertEqual(len(tb.out_raw), len(data))
         for r, e in zip(tb.out_raw, data):
             self.assertEqual(e, r)
Esempio n. 6
0
 def test_one(self):
     """
     Tests split module and message stream combiner together.
     """
     width = 32
     sendnth = 2
     max_packet_length = 10
     n_packets = 20
     data1 = []
     for i in range(n_packets):
         length = random.randint(0, max_packet_length)
         packet = msg_utils.generate_random_packet(length, config.msg_length_width,
                                         width)
         data1.extend(packet)
     max_val = pow(2, width-1)-1
     data2 = [random.randint(1, max_val) for i in range(len(data1))]
     i_data = []
     for d1, d2 in zip(data1, data2):
         i_data.append(d1)
         i_data.append(d2)
     a_data = data1 + data2
     padded_data = i_data + [0]*1000
     buffer_length = 128
     defines = config.updated_defines(
         {'COMBINER_BUFFER_LENGTH': buffer_length,
          'LOG_COMBINER_BUFFER_LENGTH': logceil(buffer_length),
          'MAX_PACKET_LENGTH': pow(2, config.msg_length_width),
          'ERRORCODE': 666,
          'WIDTH': width,
          })
     executable = buildutils.generate_icarus_executable(
         'message', 'splitcombiner', '-test', defines=defines)
     fpgaimage = buildutils.generate_B100_image(
         'message', 'splitcombiner', '-test', defines=defines)
     tb_icarus = TestBenchIcarusOuter(executable, in_raw=i_data,
                                      sendnth=sendnth)
     tb_b100 = TestBenchB100(fpgaimage, in_raw=padded_data)
     for tb, steps in (
             (tb_icarus, len(i_data)*sendnth*2+1000),
             (tb_b100, 100000), 
             ):
         tb.run(steps)
         e_samples, e_packets = msg_utils.stream_to_samples_and_packets(
             a_data, config.msg_length_width, width)
         r_samples, r_packets = msg_utils.stream_to_samples_and_packets(
             tb.out_raw, config.msg_length_width, width)
         # Remove 0's from samples.
         # The splitter can introduce 0's at beginning and end.
         r_samples = [r for r in r_samples if r != 0]
         self.assertEqual(len(e_samples), len(r_samples))
         for e, r in zip(e_samples, r_samples):
             self.assertEqual(e, r)
         # Confirm all the packets are equal.
         self.assertEqual(len(e_packets), len(r_packets))
         for ep, rp in zip(e_packets, r_packets):
             self.assertEqual(len(ep), len(rp))
             for e, r in zip(ep, rp):
                 self.assertEqual(e, r)
Esempio n. 7
0
 def test_combo(self):
     """
     Tests sample msg splitter and message stream combiner together.
     """
     top_packet_length = 64
     n_packets = 20
     width = 32
     prob_start = 0.1
     data, packets = msg_utils.generate_random_packets(
         top_packet_length,
         n_packets,
         config.msg_length_width,
         width,
         prob_start,
         self.rg,
         none_sample=False)
     padded_data = data
     buffer_length = 128
     defines = config.updated_defines({
         'COMBINER_BUFFER_LENGTH':
         buffer_length,
         'LOG_COMBINER_BUFFER_LENGTH':
         logceil(buffer_length),
         'MAX_PACKET_LENGTH':
         pow(2, config.msg_length_width),
     })
     executable = buildutils.generate_icarus_executable('message',
                                                        'combo',
                                                        '-test',
                                                        defines=defines)
     fpgaimage = buildutils.generate_B100_image('message',
                                                'combo',
                                                '-test',
                                                defines=defines)
     tb_icarus = TestBenchIcarusOuter(executable, in_raw=data)
     tb_b100 = TestBenchB100(fpgaimage, in_raw=padded_data)
     for tb, steps in (
         (tb_icarus, 10000),
         (tb_b100, 100000),
     ):
         tb.run(steps)
         e_samples, e_packets = msg_utils.stream_to_samples_and_packets(
             data, config.msg_length_width, width)
         r_samples, r_packets = msg_utils.stream_to_samples_and_packets(
             tb.out_raw, config.msg_length_width, width)
         # Confirm all the samples are equal.
         self.assertEqual(len(e_samples), len(r_samples))
         for e, r in zip(e_samples, r_samples):
             self.assertEqual(e, r)
         # Confirm all the packets are equal.
         self.assertEqual(len(e_packets), len(r_packets))
         for ep, rp in zip(e_packets, r_packets):
             self.assertEqual(len(ep), len(rp))
             for e, r in zip(ep, rp):
                 self.assertEqual(e, r)
Esempio n. 8
0
 def test_one(self):
     """
     Test the multiply_complex module.
     """
     sendnth = 2
     n_data = 1000
     in_samples = []
     expected = []
     xs = [
         random.random() * 2 - 1 + random.random() * 2j - 1j
         for i in range(n_data)
     ]
     ys = [
         random.random() * 2 - 1 + random.random() * 2j - 1j
         for i in range(n_data)
     ]
     for x, y in zip(xs, ys):
         in_samples.append(x)
         in_samples.append(y)
         z = x * y / 2
         # We divide by two since multiplying two complex numbers in range (-1,-1) to (1,1)
         # produces a result in range (-2, -2) to (2, 2).
         expected.append(z)
     steps_rqd = len(in_samples) * sendnth * 2 + 100
     executable_inner = buildutils.generate_icarus_executable(
         'fpgamath',
         'multiply_complex_inner',
         '-test',
     )
     executable_outer = buildutils.generate_icarus_executable(
         'fpgamath',
         'multiply_complex',
         '-test',
     )
     fpgaimage = buildutils.generate_B100_image('fpgamath',
                                                'multiply_complex', '-test')
     tb_icarus_inner = TestBenchIcarusInner(executable_inner,
                                            in_samples,
                                            sendnth=sendnth)
     tb_icarus_outer = TestBenchIcarusOuter(executable_outer,
                                            in_samples,
                                            sendnth=sendnth)
     tb_b100 = TestBenchB100(fpgaimage, in_samples)
     for tb, steps, check_ms in (
         (tb_icarus_inner, steps_rqd, True),
         (tb_icarus_outer, steps_rqd, False),
         (tb_b100, 100000, False),
     ):
         tb.run(steps)
         # Confirm that our data is correct.
         self.assertEqual(len(tb.out_samples), len(expected))
         for r, e in zip(tb.out_samples, expected):
             self.assertAlmostEqual(e, r, 3)
Esempio n. 9
0
 def test_one(self):
     """
     Test the filter module.
     """
     width = config.default_width
     sendnth = config.default_sendnth
     # Changing filter_length will require resynthesis.
     filter_length = 4
     taps = [random.random()*2-1 for i in range(filter_length)]
     total = sum([abs(t) for t in taps])
     taps = [t/total for t in taps]
     # Arguments used for producing verilog from templates.
     extraargs = {'summult_length': filter_length,}
     # Amount of data to send.
     n_data = 10
     # Define the input
     in_samples = [random.random()*2-1 + random.random()*2j-1j for i in range(n_data)]
     in_samples += [0]*(filter_length-1)
     steps_rqd = len(in_samples)*sendnth + 100
     # Define meta data
     mwidth = 1
     in_ms = [random.randint(0, pow(2,mwidth)-1) for d in in_samples]
     expected = convolve(in_samples, taps)
     steps_rqd = n_data * sendnth * 2 + 1000
     filter_id = 123
     # Create, setup and simulate the test bench.
     defines = config.updated_defines(
         {'WIDTH': width,
          'FILTER_LENGTH': filter_length,
          'FILTER_ID': filter_id,
          })
     executable_inner = buildutils.generate_icarus_executable(
         'flter', 'filter_inner', '-test', defines=defines, extraargs=extraargs)
     executable_outer = buildutils.generate_icarus_executable(
         'flter', 'filter', '-test', defines=defines, extraargs=extraargs)
     fpgaimage = buildutils.generate_B100_image(
         'flter', 'filter', '-test', defines=defines,
         extraargs=extraargs)
     start_msgs = taps_to_start_msgs(taps, defines['WIDTH']/2, filter_id)
     tb_icarus_inner = TestBenchIcarusInner(executable_inner, in_samples, in_ms, start_msgs)
     tb_icarus_outer = TestBenchIcarusOuter(executable_outer, in_samples, start_msgs)
     tb_b100 = TestBenchB100(fpgaimage, in_samples, start_msgs)
     for tb, steps in (
             (tb_icarus_inner, steps_rqd),
             (tb_icarus_outer, steps_rqd),
             (tb_b100, 100000), 
             ):
         tb.run(steps)
         # Confirm that our data is correct.
         self.assertEqual(len(tb.out_samples), len(expected))
         for r, e in zip(tb.out_samples, expected):
             self.assertAlmostEqual(e, r, 3)
Esempio n. 10
0
 def test_bits(self):
     """
     Tests the bits qa_wrapper.
     """
     width=32
     sendnth = 70
     max_sample = pow(2, width)-1
     n_samples = 2
     data = [self.rg.randint(1, max_sample) for i in range(n_samples)]
     defines = config.updated_defines(
         {
          'LOG_WIDTH': logceil(width),
          'ERRORCODE': 666,
          'WIDTH': width,
          'LOG_SENDNTH': 12,
          })
     executable = buildutils.generate_icarus_executable(
         'uhd', 'bits', '-test', defines=defines)
     fpgaimage = buildutils.generate_B100_image(
         'uhd', 'bits', '-test', defines=defines)
     tb_icarus = TestBenchIcarusOuter(executable, in_raw=data, sendnth=sendnth)
     tb_b100 = TestBenchB100(fpgaimage, in_raw=data)
     for tb, steps in (
         (tb_icarus, 5000),
         (tb_b100, 100000),
         ):
         tb.run(steps)
         start_pos = None
         for i, x in enumerate(tb.out_raw):
             if (x==width-1):
                 start_pos = i
                 break
         for i, x in reversed(zip(range(0, len(tb.out_raw)), tb.out_raw)):
             if (x==width-1):
                 stop_pos = i
                 break
         if start_pos is None:
             raise ValueError("{0} not found in output".format(width-1))
         out = tb.out_raw[start_pos: stop_pos + 2*width]
         bitted = [out[i*2*width+1:(i+1)*2*width+1:2] for i in range(len(out)/width/2)]
         poses = [out[i*2*width:(i+1)*2*width:2] for i in range(len(out)/width/2)]
         expected = [31-x for x in range(32)]
         for i, p in enumerate(poses):
             if (p != expected):
                 print(i)
                 print(p)
             self.assertEqual(p, expected)
         r_ints = [bits_to_int(bits) for bits in bitted]
         r_ints = [x for x in r_ints if x != 0]
         self.assertEqual(len(data), len(r_ints))
         for e, r in zip(data, r_ints):
             self.assertEqual(e, r)
Esempio n. 11
0
    def test_bits(self):
        width = 32
        maxint = pow(2, width)-1
        n_data = 10
        data = [random.randint(1, maxint) for d in range(n_data)]
        buffer_length = 128
        defines = config.updated_defines(
            {'COMBINER_BUFFER_LENGTH': buffer_length,
             'LOG_COMBINER_BUFFER_LENGTH': logceil(buffer_length),
             'MAX_PACKET_LENGTH': pow(2, config.msg_length_width),
             'WIDTH': width,
             'LOG_SENDNTH': 14,
             'LOG_WIDTH': logceil(width),
             'ERRORCODE': 666,
             })
        executable = buildutils.generate_icarus_executable(
            'message', 'message_stream_combiner_bits', '-test', defines=defines)
        fpgaimage = buildutils.generate_B100_image(
            'message', 'message_stream_combiner_bits', '-test', defines=defines)
        tb_icarus = TestBenchIcarusOuter(executable, in_raw=data, sendnth=70)
        tb_b100 = TestBenchB100(fpgaimage, in_raw=data)

        for tb, steps in (
                (tb_icarus, 10000),
                (tb_b100, 100000), 
                ):
            tb.run(steps)
            start_pos = None
            for i, x in enumerate(tb.out_raw):
                if (x==width-1):
                    start_pos = i
                    break
            for i, x in reversed(zip(range(0, len(tb.out_raw)), tb.out_raw)):
                if (x==width-1):
                    stop_pos = i
                    break
            if start_pos is None:
                raise ValueError("{0} not found in output".format(width-1))
            out = tb.out_raw[start_pos: stop_pos + 2*width]
            bitted = [out[i*2*width+1:(i+1)*2*width+1:2] for i in range(len(out)/width/2)]
            poses = [out[i*2*width:(i+1)*2*width:2] for i in range(len(out)/width/2)]
            expected = [31-x for x in range(32)]
            for i, p in enumerate(poses):
                self.assertEqual(p, expected)
            r_ints = [bits_to_int(bits) for bits in bitted]
            r_ints = [x for x in r_ints if x != 0]
            self.assertEqual(len(data), len(r_ints))
            for e, r in zip(data, r_ints):
                self.assertEqual(e, r)
Esempio n. 12
0
 def test_return_one(self):
     """
     Test the split module.
     """
     width = config.default_width
     sendnth = 4
     maxint = pow(2, width)-1
     n_data = 100
     n_streams = 2
     data = [random.randint(0, maxint) for d in range(n_data)]
     # Work out what the expected result is.
     # We don't know which stream will be returned.
     expected_data = data[::2]
     alt_expected_data = data[1::2]
     # How many steps are required to simulate the data.
     steps_rqd = n_data * sendnth * 2 + 1000
     # Create, setup and simulate the test bench.
     defines = config.updated_defines(
         {'WIDTH': width,
          })
     executable = buildutils.generate_icarus_executable(
         'flow', 'split_return_one', '-test', defines=defines)
     fpgaimage = buildutils.generate_B100_image(
         'flow', 'split_return_one', '-test', defines=defines)
     tb_icarus = TestBenchIcarusOuter(executable, in_raw=data,
                                      output_msgs=False)
     tb_b100 = TestBenchB100(fpgaimage, in_raw=data, output_msgs=False)
     for tb, steps in (
             (tb_icarus, steps_rqd),
             (tb_b100, 100000), 
             ):
         tb.run(steps)
         # Confirm that our data is correct.
         stream = None
         self.assertEqual(len(tb.out_raw), len(expected_data))
         for r, e, a in zip(tb.out_raw, expected_data, alt_expected_data):
             if stream is None:
                 if (r != e):
                     stream = 2
                 else:
                     stream = 1
             if stream == 1:
                 self.assertEqual(e, r)
             else:
                 self.assertEqual(a, r)
Esempio n. 13
0
 def test_one(self):
     """
     Test the multiply module.
     """
     sendnth = 2
     n_data = 1000
     in_samples = []
     expected = []
     # We send samples a + bj and expected returned 0 + abj.
     in_samples = [
         random.random() * 2 - 1 + random.random() * 2j - 1j
         for i in range(n_data)
     ]
     expected = [c.real * c.imag * 1j for c in in_samples]
     steps_rqd = len(in_samples) * sendnth * 2 + 100
     executable_inner = buildutils.generate_icarus_executable(
         'fpgamath',
         'multiply_inner',
         '-test',
     )
     executable_outer = buildutils.generate_icarus_executable(
         'fpgamath',
         'multiply',
         '-test',
     )
     fpgaimage = buildutils.generate_B100_image('fpgamath', 'multiply',
                                                '-test')
     tb_icarus_inner = TestBenchIcarusInner(executable_inner,
                                            in_samples,
                                            sendnth=sendnth)
     tb_icarus_outer = TestBenchIcarusOuter(executable_outer,
                                            in_samples,
                                            sendnth=sendnth)
     tb_b100 = TestBenchB100(fpgaimage, in_samples)
     for tb, steps, check_ms in (
         (tb_icarus_inner, steps_rqd, True),
         (tb_icarus_outer, steps_rqd, False),
         (tb_b100, 100000, False),
     ):
         tb.run(steps)
         # Confirm that our data is correct.
         self.assertEqual(len(tb.out_samples), len(expected))
         for r, e in zip(tb.out_samples, expected):
             self.assertAlmostEqual(e, r, 3)
Esempio n. 14
0
 def test_combo(self):
     """
     Tests sample msg splitter and message stream combiner together.
     """
     top_packet_length = 64
     n_packets = 20
     width = 32
     prob_start = 0.1
     data, packets = msg_utils.generate_random_packets(
         top_packet_length, n_packets, config.msg_length_width,
         width, prob_start, self.rg, none_sample=False)
     padded_data = data
     buffer_length = 128
     defines = config.updated_defines(
         {'COMBINER_BUFFER_LENGTH': buffer_length,
          'LOG_COMBINER_BUFFER_LENGTH': logceil(buffer_length),
          'MAX_PACKET_LENGTH': pow(2, config.msg_length_width),
          })
     executable = buildutils.generate_icarus_executable(
         'message', 'combo', '-test', defines=defines)
     fpgaimage = buildutils.generate_B100_image(
         'message', 'combo', '-test', defines=defines)
     tb_icarus = TestBenchIcarusOuter(executable, in_raw=data)
     tb_b100 = TestBenchB100(fpgaimage, in_raw=padded_data)
     for tb, steps in (
             (tb_icarus, 10000),
             (tb_b100, 100000), 
             ):
         tb.run(steps)
         e_samples, e_packets = msg_utils.stream_to_samples_and_packets(
             data, config.msg_length_width, width)
         r_samples, r_packets = msg_utils.stream_to_samples_and_packets(
             tb.out_raw, config.msg_length_width, width)
         # Confirm all the samples are equal.
         self.assertEqual(len(e_samples), len(r_samples))
         for e, r in zip(e_samples, r_samples):
             self.assertEqual(e, r)
         # Confirm all the packets are equal.
         self.assertEqual(len(e_packets), len(r_packets))
         for ep, rp in zip(e_packets, r_packets):
             self.assertEqual(len(ep), len(rp))
             for e, r in zip(ep, rp):
                 self.assertEqual(e, r)
Esempio n. 15
0
 def atest_null(self):
     """
     Tests the null qa_wrapper.
     """
     width = 32
     max_sample = pow(2, width - 2) - 1
     n_samples = 10
     data = [self.rg.randint(0, max_sample) for i in range(n_samples)]
     executable = buildutils.generate_icarus_executable(
         'uhd', 'null', '-test')
     fpgaimage = buildutils.generate_B100_image('uhd', 'null', '-test')
     tb_icarus = TestBenchIcarusOuter(executable, in_raw=data)
     tb_b100 = TestBenchB100(fpgaimage, in_raw=data)
     for tb, steps in (
         (tb_icarus, 5000),
         (tb_b100, 10000),
     ):
         tb.run(steps)
         self.assertEqual(len(data), len(tb.out_raw))
         for e, r in zip(data, tb.out_raw):
             self.assertEqual(e, r)
Esempio n. 16
0
 def atest_null(self):
     """
     Tests the null qa_wrapper.
     """
     width=32
     max_sample = pow(2, width-2)-1
     n_samples = 10
     data = [self.rg.randint(0, max_sample) for i in range(n_samples)]
     executable = buildutils.generate_icarus_executable(
         'uhd', 'null', '-test')
     fpgaimage = buildutils.generate_B100_image(
         'uhd', 'null', '-test')
     tb_icarus = TestBenchIcarusOuter(executable, in_raw=data)
     tb_b100 = TestBenchB100(fpgaimage, in_raw=data)
     for tb, steps in (
         (tb_icarus, 5000),
         (tb_b100, 10000),
         ):
         tb.run(steps)
         self.assertEqual(len(data), len(tb.out_raw))
         for e, r in zip(data, tb.out_raw):
             self.assertEqual(e, r)
Esempio n. 17
0
 def test_one(self):
     """
     Test the multiply_complex module.
     """
     sendnth = 2
     n_data = 1000
     in_samples = []
     expected = []
     xs = [random.random()*2-1 + random.random()*2j-1j for i in range(n_data)]
     ys = [random.random()*2-1 + random.random()*2j-1j for i in range(n_data)]
     for x, y in zip(xs, ys):
         in_samples.append(x)
         in_samples.append(y)
         z = x*y/2
         # We divide by two since multiplying two complex numbers in range (-1,-1) to (1,1)
         # produces a result in range (-2, -2) to (2, 2).
         expected.append(z)
     steps_rqd = len(in_samples)*sendnth*2 + 100
     executable_inner = buildutils.generate_icarus_executable(
         'fpgamath', 'multiply_complex_inner', '-test',)
     executable_outer = buildutils.generate_icarus_executable(
         'fpgamath', 'multiply_complex', '-test',)
     fpgaimage = buildutils.generate_B100_image(
         'fpgamath', 'multiply_complex', '-test')
     tb_icarus_inner = TestBenchIcarusInner(executable_inner, in_samples,
                                            sendnth=sendnth)
     tb_icarus_outer = TestBenchIcarusOuter(executable_outer, in_samples,
                                            sendnth=sendnth)
     tb_b100 = TestBenchB100(fpgaimage, in_samples)
     for tb, steps, check_ms in (
             (tb_icarus_inner, steps_rqd, True),
             (tb_icarus_outer, steps_rqd, False),
             (tb_b100, 100000, False), 
             ):
         tb.run(steps)
         # Confirm that our data is correct.
         self.assertEqual(len(tb.out_samples), len(expected))
         for r, e in zip(tb.out_samples, expected):
             self.assertAlmostEqual(e, r, 3)
Esempio n. 18
0
    def test_sample_msg_splitter_returns_msgs(self):
        """
        Tests the sample msg splitter.

        Just checks that the messages are correct.
        """
        # Then test qa_wrapper modules returning the messages.
        executable = buildutils.generate_icarus_executable(
            'message', 'sample_msg_splitter_returns_msgs', '-test')
        fpgaimage = buildutils.generate_B100_image(
            'message', 'sample_msg_splitter_returns_msgs', '-test')
        tb_icarus = TestBenchIcarusOuter(executable, in_raw=self.data)
        tb_b100 = TestBenchB100(fpgaimage, in_raw=self.data)
        for tb, steps in (
            (tb_icarus, 10000),
            (tb_b100, 1000), 
            ):
            tb.run(steps)
            samples, packets = msg_utils.stream_to_samples_and_packets(
                tb.out_raw, config.msg_length_width, self.width)
            self.assertEqual(len(samples), 0)
            first_index = None
            for i, p in enumerate(packets):
                if p != self.dummypacket:
                    first_index = i
                    break
            last_index = None
            for i, p in reversed(list(enumerate(packets))):
                if p != self.dummypacket:
                    last_index = i+1
                    break
            if first_index is None:
                raise StandardError("No packets found")
            packets = packets[first_index: last_index]
            self.assertEqual(len(packets), len(self.packets))
            for e, r in zip(packets, self.packets):
                self.assertEqual(len(e), len(r))
                for ee, rr in zip(e, r):
                    self.assertEqual(ee, rr)
Esempio n. 19
0
 def test_one(self):
     """
     Tests passing debug messages back.
     """
     width = 32
     sendnth = 2
     max_val = pow(2, width - 2) - 1
     n_data = 10
     in_data = [random.randint(1, max_val) for i in range(n_data)]
     defines = config.updated_defines({})
     executable = buildutils.generate_icarus_executable('message',
                                                        'debug',
                                                        '-test',
                                                        defines=defines)
     fpgaimage = buildutils.generate_B100_image('message',
                                                'debug',
                                                '-test',
                                                defines=defines)
     tb_icarus = TestBenchIcarusOuter(executable,
                                      in_raw=in_data,
                                      sendnth=sendnth)
     tb_b100 = TestBenchB100(fpgaimage, in_raw=in_data)
     for tb, steps in (
             #(tb_icarus, len(in_data)*sendnth*2+1000),
         (tb_b100, 100000), ):
         tb.run(steps)
         r_samples, r_packets = msg_utils.stream_to_samples_and_packets(
             tb.out_raw, config.msg_length_width, width)
         print(in_data)
         print(r_samples)
         print(r_packets)
         self.assertEqual(len(in_data), len(r_samples))
         for e, r in zip(in_data, r_samples):
             self.assertEqual(e, r)
         e_even = [s for s in in_data if s % 2 == 0]
         r_even = [p[1] for p in r_packets]
         self.assertEqual(len(e_even), len(r_even))
         for e, r in zip(e_even, r_even):
             self.assertEqual(e, r)
Esempio n. 20
0
    def test_sample_msg_splitter_returns_msgs(self):
        """
        Tests the sample msg splitter.

        Just checks that the messages are correct.
        """
        # Then test qa_wrapper modules returning the messages.
        executable = buildutils.generate_icarus_executable(
            'message', 'sample_msg_splitter_returns_msgs', '-test')
        fpgaimage = buildutils.generate_B100_image(
            'message', 'sample_msg_splitter_returns_msgs', '-test')
        tb_icarus = TestBenchIcarusOuter(executable, in_raw=self.data)
        tb_b100 = TestBenchB100(fpgaimage, in_raw=self.data)
        for tb, steps in (
            (tb_icarus, 10000),
            (tb_b100, 1000),
        ):
            tb.run(steps)
            samples, packets = msg_utils.stream_to_samples_and_packets(
                tb.out_raw, config.msg_length_width, self.width)
            self.assertEqual(len(samples), 0)
            first_index = None
            for i, p in enumerate(packets):
                if p != self.dummypacket:
                    first_index = i
                    break
            last_index = None
            for i, p in reversed(list(enumerate(packets))):
                if p != self.dummypacket:
                    last_index = i + 1
                    break
            if first_index is None:
                raise StandardError("No packets found")
            packets = packets[first_index:last_index]
            self.assertEqual(len(packets), len(self.packets))
            for e, r in zip(packets, self.packets):
                self.assertEqual(len(e), len(r))
                for ee, rr in zip(e, r):
                    self.assertEqual(ee, rr)
Esempio n. 21
0
    def test_sample_msg_splitter(self):
        """
        Tests the sample msg splitter.

        Just checks that the samples are correct.
        """
        # First test qa_wrapper modules that return the samples
        executable = buildutils.generate_icarus_executable(
            'message', 'sample_msg_splitter', '-test')
        fpgaimage = buildutils.generate_B100_image(
            'message', 'sample_msg_splitter', '-test')
        tb_icarus = TestBenchIcarusOuter(executable, in_raw=self.data)
        tb_b100 = TestBenchB100(fpgaimage, in_raw=self.data)
        for tb, steps in (
            (tb_icarus, 10000),
            (tb_b100, 10000),
            ):
            tb.run(steps)
            samples, packets = msg_utils.stream_to_samples_and_packets(
                self.original_data, config.msg_length_width, self.width)
            self.assertEqual(len(samples), len(tb.out_raw))
            for e, r in zip(samples, tb.out_raw):
                self.assertEqual(e, r)
Esempio n. 22
0
    def test_sample_msg_splitter(self):
        """
        Tests the sample msg splitter.

        Just checks that the samples are correct.
        """
        # First test qa_wrapper modules that return the samples
        executable = buildutils.generate_icarus_executable(
            'message', 'sample_msg_splitter', '-test')
        fpgaimage = buildutils.generate_B100_image('message',
                                                   'sample_msg_splitter',
                                                   '-test')
        tb_icarus = TestBenchIcarusOuter(executable, in_raw=self.data)
        tb_b100 = TestBenchB100(fpgaimage, in_raw=self.data)
        for tb, steps in (
            (tb_icarus, 10000),
            (tb_b100, 10000),
        ):
            tb.run(steps)
            samples, packets = msg_utils.stream_to_samples_and_packets(
                self.original_data, config.msg_length_width, self.width)
            self.assertEqual(len(samples), len(tb.out_raw))
            for e, r in zip(samples, tb.out_raw):
                self.assertEqual(e, r)
Esempio n. 23
0
 def test_one(self):
     """
     Test the filter module.
     """
     width = config.default_width
     sendnth = config.default_sendnth
     # Changing filter_length will require resynthesis.
     filter_length = 4
     taps = [random.random() * 2 - 1 for i in range(filter_length)]
     total = sum([abs(t) for t in taps])
     taps = [t / total for t in taps]
     # Arguments used for producing verilog from templates.
     extraargs = {
         'summult_length': filter_length,
     }
     # Amount of data to send.
     n_data = 10
     # Define the input
     in_samples = [
         random.random() * 2 - 1 + random.random() * 2j - 1j
         for i in range(n_data)
     ]
     in_samples += [0] * (filter_length - 1)
     steps_rqd = len(in_samples) * sendnth + 100
     # Define meta data
     mwidth = 1
     in_ms = [random.randint(0, pow(2, mwidth) - 1) for d in in_samples]
     expected = convolve(in_samples, taps)
     steps_rqd = n_data * sendnth * 2 + 1000
     filter_id = 123
     # Create, setup and simulate the test bench.
     defines = config.updated_defines({
         'WIDTH': width,
         'FILTER_LENGTH': filter_length,
         'FILTER_ID': filter_id,
     })
     executable_inner = buildutils.generate_icarus_executable(
         'flter',
         'filter_inner',
         '-test',
         defines=defines,
         extraargs=extraargs)
     executable_outer = buildutils.generate_icarus_executable(
         'flter', 'filter', '-test', defines=defines, extraargs=extraargs)
     fpgaimage = buildutils.generate_B100_image('flter',
                                                'filter',
                                                '-test',
                                                defines=defines,
                                                extraargs=extraargs)
     start_msgs = taps_to_start_msgs(taps, defines['WIDTH'] / 2, filter_id)
     tb_icarus_inner = TestBenchIcarusInner(executable_inner, in_samples,
                                            in_ms, start_msgs)
     tb_icarus_outer = TestBenchIcarusOuter(executable_outer, in_samples,
                                            start_msgs)
     tb_b100 = TestBenchB100(fpgaimage, in_samples, start_msgs)
     for tb, steps in (
         (tb_icarus_inner, steps_rqd),
         (tb_icarus_outer, steps_rqd),
         (tb_b100, 100000),
     ):
         tb.run(steps)
         # Confirm that our data is correct.
         self.assertEqual(len(tb.out_samples), len(expected))
         for r, e in zip(tb.out_samples, expected):
             self.assertAlmostEqual(e, r, 3)
Esempio n. 24
0
    def test_bits(self):
        width = 32
        maxint = pow(2, width) - 1
        n_data = 10
        data = [random.randint(1, maxint) for d in range(n_data)]
        buffer_length = 128
        defines = config.updated_defines({
            'COMBINER_BUFFER_LENGTH':
            buffer_length,
            'LOG_COMBINER_BUFFER_LENGTH':
            logceil(buffer_length),
            'MAX_PACKET_LENGTH':
            pow(2, config.msg_length_width),
            'WIDTH':
            width,
            'LOG_SENDNTH':
            14,
            'LOG_WIDTH':
            logceil(width),
            'ERRORCODE':
            666,
        })
        executable = buildutils.generate_icarus_executable(
            'message',
            'message_stream_combiner_bits',
            '-test',
            defines=defines)
        fpgaimage = buildutils.generate_B100_image(
            'message',
            'message_stream_combiner_bits',
            '-test',
            defines=defines)
        tb_icarus = TestBenchIcarusOuter(executable, in_raw=data, sendnth=70)
        tb_b100 = TestBenchB100(fpgaimage, in_raw=data)

        for tb, steps in (
            (tb_icarus, 10000),
            (tb_b100, 100000),
        ):
            tb.run(steps)
            start_pos = None
            for i, x in enumerate(tb.out_raw):
                if (x == width - 1):
                    start_pos = i
                    break
            for i, x in reversed(zip(range(0, len(tb.out_raw)), tb.out_raw)):
                if (x == width - 1):
                    stop_pos = i
                    break
            if start_pos is None:
                raise ValueError("{0} not found in output".format(width - 1))
            out = tb.out_raw[start_pos:stop_pos + 2 * width]
            bitted = [
                out[i * 2 * width + 1:(i + 1) * 2 * width + 1:2]
                for i in range(len(out) / width / 2)
            ]
            poses = [
                out[i * 2 * width:(i + 1) * 2 * width:2]
                for i in range(len(out) / width / 2)
            ]
            expected = [31 - x for x in range(32)]
            for i, p in enumerate(poses):
                self.assertEqual(p, expected)
            r_ints = [bits_to_int(bits) for bits in bitted]
            r_ints = [x for x in r_ints if x != 0]
            self.assertEqual(len(data), len(r_ints))
            for e, r in zip(data, r_ints):
                self.assertEqual(e, r)
Esempio n. 25
0
 def test_one(self):
     """
     Tests split module and message stream combiner together.
     """
     width = 32
     sendnth = 2
     max_packet_length = 10
     n_packets = 20
     data1 = []
     for i in range(n_packets):
         length = random.randint(0, max_packet_length)
         packet = msg_utils.generate_random_packet(length,
                                                   config.msg_length_width,
                                                   width)
         data1.extend(packet)
     max_val = pow(2, width - 1) - 1
     data2 = [random.randint(1, max_val) for i in range(len(data1))]
     i_data = []
     for d1, d2 in zip(data1, data2):
         i_data.append(d1)
         i_data.append(d2)
     a_data = data1 + data2
     padded_data = i_data + [0] * 1000
     buffer_length = 128
     defines = config.updated_defines({
         'COMBINER_BUFFER_LENGTH':
         buffer_length,
         'LOG_COMBINER_BUFFER_LENGTH':
         logceil(buffer_length),
         'MAX_PACKET_LENGTH':
         pow(2, config.msg_length_width),
         'ERRORCODE':
         666,
         'WIDTH':
         width,
     })
     executable = buildutils.generate_icarus_executable('message',
                                                        'splitcombiner',
                                                        '-test',
                                                        defines=defines)
     fpgaimage = buildutils.generate_B100_image('message',
                                                'splitcombiner',
                                                '-test',
                                                defines=defines)
     tb_icarus = TestBenchIcarusOuter(executable,
                                      in_raw=i_data,
                                      sendnth=sendnth)
     tb_b100 = TestBenchB100(fpgaimage, in_raw=padded_data)
     for tb, steps in (
         (tb_icarus, len(i_data) * sendnth * 2 + 1000),
         (tb_b100, 100000),
     ):
         tb.run(steps)
         e_samples, e_packets = msg_utils.stream_to_samples_and_packets(
             a_data, config.msg_length_width, width)
         r_samples, r_packets = msg_utils.stream_to_samples_and_packets(
             tb.out_raw, config.msg_length_width, width)
         # Remove 0's from samples.
         # The splitter can introduce 0's at beginning and end.
         r_samples = [r for r in r_samples if r != 0]
         self.assertEqual(len(e_samples), len(r_samples))
         for e, r in zip(e_samples, r_samples):
             self.assertEqual(e, r)
         # Confirm all the packets are equal.
         self.assertEqual(len(e_packets), len(r_packets))
         for ep, rp in zip(e_packets, r_packets):
             self.assertEqual(len(ep), len(rp))
             for e, r in zip(ep, rp):
                 self.assertEqual(e, r)
Esempio n. 26
0
 def test_one(self):
     """
     Test the filterbank module.
     """
     width = config.default_width
     sendnth = config.default_sendnth
     # Changing filter_length will require resynthesis.
     n_filters = 3
     filter_length = 3
     all_taps = []
     combined_taps = []
     for n in range(n_filters):
         taps = [random.random() * 2 - 1 for i in range(filter_length)]
         total = sum([abs(t) for t in taps])
         taps = [t / total for t in taps]
         all_taps.append(taps)
         combined_taps.extend(taps)
     # Arguments used for producing verilog from templates.
     extraargs = {
         'summult_length': filter_length,
     }
     # Amount of data to send.
     n_data = 30
     # Define the input
     in_samples = [0] * filter_length * n_filters * 2
     in_samples += [
         random.random() * 2 - 1 + random.random() * 2j - 1j
         for i in range(n_data)
     ]
     in_samples += [0] * (filter_length - 1) * n_filters
     steps_rqd = len(in_samples) * sendnth + 100
     # Define meta data
     mwidth = 1
     in_ms = [random.randint(0, pow(2, mwidth) - 1) for d in in_samples]
     possible_expected = []
     for m in range(n_filters):
         shifted_taps = all_taps[m:] + all_taps[:m]
         expected_outputs = []
         for n in range(n_filters):
             filter_inputs = in_samples[n::n_filters]
             convolved = convolve(filter_inputs, shifted_taps[n])
             expected_outputs.append(convolved)
         expected = []
         for eo in zip(*expected_outputs):
             expected.extend(eo)
         possible_expected.append(expected)
     steps_rqd = n_data * sendnth * 2 + 1000
     # Create, setup and simulate the test bench.
     filter_id = 123
     defines = config.updated_defines({
         'WIDTH': width,
         'FILTER_LENGTH': filter_length,
         'FILTERBANK_ID': filter_id,
         'N_FILTERS': n_filters,
         'FILTERBANK_MSG_BUFFER_LENGTH': 128,
     })
     executable_inner = buildutils.generate_icarus_executable(
         'flter',
         'filterbank_inner',
         '-test',
         defines=defines,
         extraargs=extraargs)
     executable_outer = buildutils.generate_icarus_executable(
         'flter',
         'filterbank',
         '-test',
         defines=defines,
         extraargs=extraargs)
     fpgaimage = buildutils.generate_B100_image('flter',
                                                'filterbank',
                                                '-test',
                                                defines=defines,
                                                extraargs=extraargs)
     start_msgs = taps_to_start_msgs(combined_taps, defines['WIDTH'] / 2,
                                     filter_id)
     tb_icarus_inner = TestBenchIcarusInner(executable_inner, in_samples,
                                            in_ms, start_msgs)
     tb_icarus_outer = TestBenchIcarusOuter(executable_outer, in_samples,
                                            start_msgs)
     tb_b100 = TestBenchB100(fpgaimage, in_samples, start_msgs)
     for tb, steps in (
         (tb_icarus_inner, steps_rqd),
         (tb_icarus_outer, steps_rqd),
         (tb_b100, 100000),
     ):
         tb.run(steps)
         # Confirm that our data is correct.
         received = prune_zeros(tb.out_samples)
         tol = 0.001
         matched_once = False
         for expected in possible_expected:
             expected = prune_zeros(expected)
             matches = True
             if (len(received) != len(expected)):
                 matches = False
             else:
                 for r, e in zip(received, expected):
                     if (abs(r - e) > tol):
                         matches = False
                         break
             if matches:
                 matched_once = True
         self.assertTrue(matched_once)
Esempio n. 27
0
 def test_bits(self):
     """
     Tests the bits qa_wrapper.
     """
     width = 32
     sendnth = 70
     max_sample = pow(2, width) - 1
     n_samples = 2
     data = [self.rg.randint(1, max_sample) for i in range(n_samples)]
     defines = config.updated_defines({
         'LOG_WIDTH': logceil(width),
         'ERRORCODE': 666,
         'WIDTH': width,
         'LOG_SENDNTH': 12,
     })
     executable = buildutils.generate_icarus_executable('uhd',
                                                        'bits',
                                                        '-test',
                                                        defines=defines)
     fpgaimage = buildutils.generate_B100_image('uhd',
                                                'bits',
                                                '-test',
                                                defines=defines)
     tb_icarus = TestBenchIcarusOuter(executable,
                                      in_raw=data,
                                      sendnth=sendnth)
     tb_b100 = TestBenchB100(fpgaimage, in_raw=data)
     for tb, steps in (
         (tb_icarus, 5000),
         (tb_b100, 100000),
     ):
         tb.run(steps)
         start_pos = None
         for i, x in enumerate(tb.out_raw):
             if (x == width - 1):
                 start_pos = i
                 break
         for i, x in reversed(zip(range(0, len(tb.out_raw)), tb.out_raw)):
             if (x == width - 1):
                 stop_pos = i
                 break
         if start_pos is None:
             raise ValueError("{0} not found in output".format(width - 1))
         out = tb.out_raw[start_pos:stop_pos + 2 * width]
         bitted = [
             out[i * 2 * width + 1:(i + 1) * 2 * width + 1:2]
             for i in range(len(out) / width / 2)
         ]
         poses = [
             out[i * 2 * width:(i + 1) * 2 * width:2]
             for i in range(len(out) / width / 2)
         ]
         expected = [31 - x for x in range(32)]
         for i, p in enumerate(poses):
             if (p != expected):
                 print(i)
                 print(p)
             self.assertEqual(p, expected)
         r_ints = [bits_to_int(bits) for bits in bitted]
         r_ints = [x for x in r_ints if x != 0]
         self.assertEqual(len(data), len(r_ints))
         for e, r in zip(data, r_ints):
             self.assertEqual(e, r)
Esempio n. 28
0
 def test_one(self):
     """
     Test the filterbank module.
     """
     width = config.default_width
     sendnth = config.default_sendnth
     # Changing filter_length will require resynthesis.
     n_filters = 3
     filter_length = 3
     all_taps = []
     combined_taps = []
     for n in range(n_filters):
         taps = [random.random()*2-1 for i in range(filter_length)]
         total = sum([abs(t) for t in taps])
         taps = [t/total for t in taps]
         all_taps.append(taps)
         combined_taps.extend(taps)
     # Arguments used for producing verilog from templates.
     extraargs = {'summult_length': filter_length,}
     # Amount of data to send.
     n_data = 30
     # Define the input
     in_samples = [0]*filter_length*n_filters*2
     in_samples += [random.random()*2-1 + random.random()*2j-1j for i in range(n_data)]
     in_samples += [0]*(filter_length-1)*n_filters
     steps_rqd = len(in_samples)*sendnth + 100
     # Define meta data
     mwidth = 1
     in_ms = [random.randint(0, pow(2,mwidth)-1) for d in in_samples]
     possible_expected = []
     for m in range(n_filters):
         shifted_taps = all_taps[m:] + all_taps[:m]
         expected_outputs = []
         for n in range(n_filters):
             filter_inputs = in_samples[n::n_filters]
             convolved = convolve(filter_inputs, shifted_taps[n])
             expected_outputs.append(convolved)
         expected = []
         for eo in zip(*expected_outputs):
             expected.extend(eo)
         possible_expected.append(expected)
     steps_rqd = n_data * sendnth * 2 + 1000
     # Create, setup and simulate the test bench.
     filter_id = 123
     defines = config.updated_defines(
         {'WIDTH': width,
          'FILTER_LENGTH': filter_length,
          'FILTERBANK_ID': filter_id,
          'N_FILTERS': n_filters,
          'FILTERBANK_MSG_BUFFER_LENGTH': 128,
          })
     executable_inner = buildutils.generate_icarus_executable(
         'flter', 'filterbank_inner', '-test', defines=defines, extraargs=extraargs)
     executable_outer = buildutils.generate_icarus_executable(
         'flter', 'filterbank', '-test', defines=defines, extraargs=extraargs)
     fpgaimage = buildutils.generate_B100_image(
         'flter', 'filterbank', '-test', defines=defines,
         extraargs=extraargs)
     start_msgs = taps_to_start_msgs(combined_taps, defines['WIDTH']/2, filter_id)
     tb_icarus_inner = TestBenchIcarusInner(executable_inner, in_samples, in_ms, start_msgs)
     tb_icarus_outer = TestBenchIcarusOuter(executable_outer, in_samples, start_msgs)
     tb_b100 = TestBenchB100(fpgaimage, in_samples, start_msgs)
     for tb, steps in (
             (tb_icarus_inner, steps_rqd),
             (tb_icarus_outer, steps_rqd),
             (tb_b100, 100000), 
             ):
         tb.run(steps)
         # Confirm that our data is correct.
         received = prune_zeros(tb.out_samples)
         tol = 0.001
         matched_once = False
         for expected in possible_expected:
             expected = prune_zeros(expected)
             matches = True
             if (len(received) != len(expected)):
                 matches = False
             else:
                 for r, e in zip(received, expected):
                     if (abs(r-e) > tol):
                         matches = False
                         break
             if matches:
                 matched_once = True
         self.assertTrue(matched_once)