def test_one(self): directory = os.path.abspath('proj_test_testA') data_width = 4 array_length = 6 params = { 'data_width': data_width, 'array_length': array_length, } # Make input and expected data n_data = 20 input_data = [] expected_data = [] max_data = pow(2, data_width)-1 for data_index in range(n_data): input_d = { 'i_valid': random.randint(0, 1), 'i_data': random.randint(0, max_data), 'i_array': [random.randint(0, max_data) for i in range(array_length)], } expected_d = { 'o_valid': input_d['i_valid'], 'o_data': input_d['i_data'], 'o_array': input_d['i_array'], } input_data.append(input_d) expected_data.append(expected_d) # Create project interface = testA.get_testA_interface(params) p = project.FileTestBenchProject.create_or_update( interface=interface, directory=directory, board=config.default_board, part=config.default_part, ) t = p.wait_for_most_recent_task() errors = t.get_errors() self.assertEqual(len(errors), 0) # Run the simulation runtime = '{} ns'.format((len(input_data) + 20) * 10) errors, output_data = p.run_simulation( input_data=input_data, runtime=runtime) self.check_output(output_data[1:], expected_data) self.assertEqual(len(errors), 0)
def get_hash(data_width, array_length, directory, temp_directory): interface = testA.get_testA_interface({ 'data_width': data_width, 'array_length': array_length, }) inner_wrapper_builder = inner_wrapper.InnerWrapperBuilder({ 'interface': interface, }) file_testbench_builder = file_testbench.FileTestbenchBuilder({ 'interface': interface, }) design_builders = [inner_wrapper_builder, interface.builder] simulation_builders = [file_testbench_builder] parameters = interface.parameters h = project.BuilderProject.predict_hash( design_builders=design_builders, simulation_builders=simulation_builders, parameters=parameters, temp_directory=temp_directory, directory=directory, ) return h