예제 #1
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)
예제 #2
0
 def setUp(self):
     self.rg = random.Random(0)
     top_packet_length = 64
     n_packets = 10
     self.width = 32
     prob_start = 0.1
     data, packets = msg_utils.generate_random_packets(
         top_packet_length, n_packets, config.msg_length_width,
         self.width, prob_start, self.rg, none_sample=False)
     self.dummypacket = msg_utils.generate_random_packet(0, config.msg_length_width, self.width)
     self.original_data = data
     self.data = data + self.dummypacket * 100000
     self.samples, self.packets = msg_utils.stream_to_samples_and_packets(
         data, config.msg_length_width, self.width)
예제 #3
0
 def setUp(self):
     self.rg = random.Random(0)
     top_packet_length = 64
     n_packets = 10
     self.width = 32
     prob_start = 0.1
     data, packets = msg_utils.generate_random_packets(
         top_packet_length,
         n_packets,
         config.msg_length_width,
         self.width,
         prob_start,
         self.rg,
         none_sample=False)
     self.dummypacket = msg_utils.generate_random_packet(
         0, config.msg_length_width, self.width)
     self.original_data = data
     self.data = data + self.dummypacket * 100000
     self.samples, self.packets = msg_utils.stream_to_samples_and_packets(
         data, config.msg_length_width, self.width)
예제 #4
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)