Example #1
0
File: exec.py Project: hoangt/sylva
    def execute_write_hdl(self, hdl_output_dir):

        self.log_critical('Writing HDLs ...')
        top_module_name = self.system_name or 'top'

        if hdl_output_dir:
            output_dir, name, _ = dir_and_file(hdl_output_dir[0])
        else:
            output_dir, name = self.output_path, None

        top_module_name = name or self.system_name or 'top'

        mkdir(output_dir)

        if self.solutions:
            for i, schedules in enumerate(self.solutions):
                solution = schedules[-1]
                output_path = os.path.join(output_dir,
                                           self.hdl_output_dir_perfix + str(i))
                mkdir(output_path)
                hsdfg = SDFG.load(solution)
                air = self.create_air(self.sdf_graph, hsdfg, solution)
                sample_interval = solution['sample interval']
                air_to_vhdl(air, sample_interval, self.fimp_library,
                            output_path, top_module_name)
            self.log_critical('Writing HDLs is done.')
        else:
            self.log_critical(
                'No design space exploration solution for code generation.')
Example #2
0
File: exec.py Project: hoangt/sylva
    def execute_write_fimp_plots(self, plot_output_dir):

        self.log_critical('Writing FIMP plots ...')

        if plot_output_dir:
            output_dir, _, _ = dir_and_file(plot_output_dir[0])
        else:
            output_dir = self.plot_path

        mkdir(output_dir)

        for schedule_index, schedule in enumerate(self.solutions):
            fimp_count = len(schedule[-1]['fimp_types'])
            plot_name = self.fimp_schedule_plot_pattern.replace(
                'INDEX', str(schedule_index))
            plot_name = plot_name.replace('FIMPS', str(fimp_count))
            plot_path = os.path.join(output_dir, plot_name)
            hsdfg = SDFG.load(schedule[-1])
            fimps = [fimp.load_fimp(f) for f in schedule[-1]['fimp_instances']]
            for a in hsdfg.actors:
                a.assign_to(fimps[a.fimp_index])

            p = schedule_plot(hsdfg.actors)
            p.savefig(plot_path)
            p.close()

        self.log_critical('Writing FIMP plots is done.')
Example #3
0
File: exec.py Project: zcold/sylva
    def execute_write_fimp_plots(self, plot_output_dir):

        self.log_critical('Writing FIMP plots ...')

        if plot_output_dir:
            output_dir, _, _ = dir_and_file(plot_output_dir[0])
        else:
            output_dir = self.plot_path

        mkdir(output_dir)

        for schedule_index, schedule in enumerate(self.solutions):
            fimp_count = len(schedule[-1]['fimp_types'])
            plot_name = self.fimp_schedule_plot_pattern.replace('INDEX', str(schedule_index))
            plot_name = plot_name.replace('FIMPS', str(fimp_count))
            plot_path = os.path.join(output_dir, plot_name)
            hsdfg = SDFG.load(schedule[-1])
            fimps = [fimp.load_fimp(f) for f in schedule[-1]['fimp_instances']]
            for a in hsdfg.actors:
                a.assign_to(fimps[a.fimp_index])

            p = schedule_plot(hsdfg.actors)
            p.savefig(plot_path)
            p.close()

        self.log_critical('Writing FIMP plots is done.')
Example #4
0
File: exec.py Project: zcold/sylva
    def execute_write_hdl(self, hdl_output_dir):

        self.log_critical('Writing HDLs ...')
        top_module_name = self.system_name or 'top'

        if hdl_output_dir:
            output_dir, name, _ = dir_and_file(hdl_output_dir[0])
        else:
            output_dir, name = self.output_path, None

        top_module_name = name or self.system_name or 'top'

        mkdir(output_dir)

        if self.solutions:
            for i, schedules in enumerate(self.solutions):
                solution = schedules[-1]
                output_path = os.path.join(output_dir, self.hdl_output_dir_perfix + str(i))
                mkdir(output_path)
                hsdfg = SDFG.load(solution)
                air = self.create_air(self.sdf_graph, hsdfg, solution)
                sample_interval = solution['sample interval']
                air_to_vhdl(air, sample_interval, self.fimp_library, output_path, top_module_name)
            self.log_critical('Writing HDLs is done.')
        else:
            self.log_critical('No design space exploration solution for code generation.')
Example #5
0
File: exec.py Project: hoangt/sylva
    def execute_generate(self, args):
        o, i = args[:2]

        if len(args) > 2:
            output_dir, name, ext = dir_and_file(args[2])
        else:
            output_dir, name, ext = self.output_path, None, None

        mkdir(output_dir)

        self.log_critical('Generating {} from {} ...'.format(o, i))

        if i not in tcl_parser.generate_inputs.keys:
            self.log_critical(
                'Error: input format {} is not supported'.format(i))
            return

        if i == 'sdf_graph':  # o == 'hsdf_graph' is included
            self.prepare_from_sdf_graph()
        elif i == 'simulink':
            if not self['simulink_model']:
                self.log_critical('Error: simulink_model is not provided')
                return
            else:
                self.prepare_from_sdf_graph()
            if not self['fimp_library']:
                self.log_critical('Error: fimp_library is not provided')
                return

        if o == 'vhdl':
            self.prepare_to_vhdl()

            for a in self.hsdf_graph.actors:
                if a.name.lower() not in self.fimp_library.function_name_set:
                    self.log_critical(
                        'Error: Cannot find {} in library'.format(a.name))
                    return
                a.assign_to(self.fimp_library[a.name][0])
                self.fimp_library[a.name][0].base_actor = a.base_actor
                self.fimp_library[a.name][0].global_index = a.index

            entity_name = name or self.system_name or 'top'
            ext = ext or '.vhdl'
            output_file_path = os.path.join(output_dir, entity_name + ext)
            msg = hsdf_to_vhdl(self.hsdf_graph.actors,
                               self.hsdf_graph.edges,
                               self.fimp_library,
                               entity_name=entity_name,
                               used_libraries=self.vhdl_use_library,
                               output_file=output_file_path)
            self.log_critical(msg)
            self.log_critical('Generating {} from {} is done'.format(o, i))
            return
        self.log_critical('Unsupported generation ({} > {}).'.format(i, o))
Example #6
0
File: exec.py Project: zcold/sylva
 def execute_dump(self, args):
     attr_name, file_name = args
     self.log_critical('Dumping {} to file {} ...'.format(attr_name, file_name))
     dirname, name, ext = dir_and_file(file_name)
     dump_path = dirname or self.dump_path or self.output_path
     mkdir(dump_path)
     try:
         self.dump(self[attr_name], name + ext, dump_path)
         self.log_critical('Dumping {} to file {} is done.'.format(attr_name, file_name))
     except Exception as e:
         self.log_critical('ERROR : Dumping {} to file {} failed.'.format(attr_name, file_name))
         self.log_critical(str(e))
Example #7
0
File: exec.py Project: zcold/sylva
    def execute_generate(self, args):
        o, i = args[:2]

        if len(args) > 2:
            output_dir, name, ext = dir_and_file(args[2])
        else:
            output_dir, name, ext = self.output_path, None, None

        mkdir(output_dir)

        self.log_critical('Generating {} from {} ...'.format(o, i))

        if i not in tcl_parser.generate_inputs.keys:
            self.log_critical('Error: input format {} is not supported'.format(i))
            return

        if i == 'sdf_graph':  # o == 'hsdf_graph' is included
            self.prepare_from_sdf_graph()
        elif i == 'simulink':
            if not self['simulink_model']:
                self.log_critical('Error: simulink_model is not provided')
                return
            else:
                self.prepare_from_sdf_graph()
            if not self['fimp_library']:
                self.log_critical('Error: fimp_library is not provided')
                return

        if o == 'vhdl':
            self.prepare_to_vhdl()

            for a in self.hsdf_graph.actors:
                if a.name.lower() not in self.fimp_library.function_name_set:
                    self.log_critical('Error: Cannot find {} in library'.format(a.name))
                    return
                a.assign_to(self.fimp_library[a.name][0])
                self.fimp_library[a.name][0].base_actor = a.base_actor
                self.fimp_library[a.name][0].global_index = a.index

            entity_name = name or self.system_name or 'top'
            ext = ext or '.vhdl'
            output_file_path = os.path.join(output_dir, entity_name + ext)
            msg = hsdf_to_vhdl(
                self.hsdf_graph.actors, self.hsdf_graph.edges,
                self.fimp_library, entity_name=entity_name,
                used_libraries=self.vhdl_use_library,
                output_file=output_file_path)
            self.log_critical(msg)
            self.log_critical('Generating {} from {} is done'.format(o, i))
            return
        self.log_critical('Unsupported generation ({} > {}).'.format(i, o))
Example #8
0
File: exec.py Project: hoangt/sylva
 def execute_dump(self, args):
     attr_name, file_name = args
     self.log_critical('Dumping {} to file {} ...'.format(
         attr_name, file_name))
     dirname, name, ext = dir_and_file(file_name)
     dump_path = dirname or self.dump_path or self.output_path
     mkdir(dump_path)
     try:
         self.dump(self[attr_name], name + ext, dump_path)
         self.log_critical('Dumping {} to file {} is done.'.format(
             attr_name, file_name))
     except Exception as e:
         self.log_critical('ERROR : Dumping {} to file {} failed.'.format(
             attr_name, file_name))
         self.log_critical(str(e))
Example #9
0
File: exec.py Project: zcold/sylva
    def execute_write_cgra_floorplans(self, plot_output_dir):

        self.log_critical('Writing CGRA floorplans ...')
        if not self.floorplanner:
            self.log_critical('Error: Floorplanning has not been performed.')
        else:
            if plot_output_dir:
                output_dir, _, _ = dir_and_file(plot_output_dir[0])
            else:
                output_dir = self.plot_path

            mkdir(output_dir)

            name_pattern = self.cgra_schedule_plot_pattern.replace('INDEX', '{index}')
            name_pattern = name_pattern.replace('COST', '{cost}')
            self.floorplanner.plot_solutions(output_dir, name_pattern)
            self.log_critical('Writing CGRA floorplans is done.')
Example #10
0
File: exec.py Project: hoangt/sylva
    def execute_write_cgra_floorplans(self, plot_output_dir):

        self.log_critical('Writing CGRA floorplans ...')
        if not self.floorplanner:
            self.log_critical('Error: Floorplanning has not been performed.')
        else:
            if plot_output_dir:
                output_dir, _, _ = dir_and_file(plot_output_dir[0])
            else:
                output_dir = self.plot_path

            mkdir(output_dir)

            name_pattern = self.cgra_schedule_plot_pattern.replace(
                'INDEX', '{index}')
            name_pattern = name_pattern.replace('COST', '{cost}')
            self.floorplanner.plot_solutions(output_dir, name_pattern)
            self.log_critical('Writing CGRA floorplans is done.')
Example #11
0
File: exec.py Project: hoangt/sylva
def clean_command():
    print('')
    for a in to_clean:
        v = sy[a]
        if v:
            if v.startswith('./'):
                v = v[2:]
            dirname, name, ext = dir_and_file(v)
            if dirname == '.' and not name and not ext:
                pass
            elif name:
                path = os.path.join(dirname, name + ext)
                if os.path.exists(path):
                    os.remove(path)
                    print('Deleted file {}'.format(path))
            else:
                if os.path.exists(dirname):
                    shutil.rmtree(dirname)
                    print('Deleted directory {}'.format(dirname))
Example #12
0
File: exec.py Project: zcold/sylva
def clean_command():
    print('')
    for a in to_clean:
        v = sy[a]
        if v:
            if v.startswith('./'):
                v = v[2:]
            dirname, name, ext = dir_and_file(v)
            if dirname == '.' and not name and not ext:
                pass
            elif name:
                path = os.path.join(dirname, name + ext)
                if os.path.exists(path):
                    os.remove(path)
                    print('Deleted file {}'.format(path))
            else:
                if os.path.exists(dirname):
                    shutil.rmtree(dirname)
                    print('Deleted directory {}'.format(dirname))