예제 #1
0
    def _setup_targets(self, target, gen_structures=False, debug=False):
        """
        Setup targets for project.
        This may differ from one project to another and needs customization.
        1. Create target object for each target that is supported in project
        2. Assign filesets to all target objects of the project
        """

        if not self.project_sources_finalized:
            # Populate the fileset dict which will be used to copy data to target object and store in filesets variable
            self.filesets.populate_fileset_dict()
            self.project_sources_finalized = True

        filesets = self.filesets.fileset_dict

        if target in self.cpu_targets:
            #######################################################
            # Create and setup simulation target
            #######################################################
            self.__setattr__(
                target,
                CPUTarget(prj_cfg=self._prj_cfg,
                          plugins=self._plugins,
                          name=target,
                          float_type=self.float_type))
            getattr(getattr(self, target),
                    'assign_fileset')(fileset=filesets['default'])
            if target in filesets:
                getattr(getattr(self, target),
                        'assign_fileset')(fileset=filesets[target])

            # Update simulation target specific configuration
            getattr(getattr(getattr(self, target), 'cfg'),
                    'update_config')(subsection=target)
            getattr(getattr(self, target), 'set_tstop')()
            getattr(getattr(self, target), 'update_structure_config')()
            if (not getattr(getattr(getattr(self, target), 'cfg'),
                            'custom_top') and gen_structures):
                getattr(getattr(self, target), 'gen_structure')()

        elif target in self.fpga_targets:
            #######################################################
            # Create and setup FPGA target
            #######################################################
            self.__setattr__(
                target,
                FPGATarget(prj_cfg=self._prj_cfg,
                           plugins=self._plugins,
                           name=target,
                           float_type=self.float_type))
            getattr(getattr(self, target),
                    'assign_fileset')(fileset=filesets['default'])
            if target in filesets:
                getattr(getattr(self, target),
                        'assign_fileset')(fileset=filesets[target])

            # Update fpga target specific configuration
            getattr(getattr(getattr(self, target), 'cfg'),
                    'update_config')(subsection=target)
            getattr(getattr(self, target), 'set_tstop')()
            getattr(getattr(self, target), 'update_structure_config')()
            if not getattr(getattr(getattr(self, target), 'cfg'),
                           'custom_top'):
                getattr(getattr(self, target), 'setup_ctrl_ifc')(debug=debug)
                if gen_structures:
                    getattr(getattr(self, target), 'gen_structure')()

            # Generate corresponding firmware and add to sources
            getattr(getattr(self, target), 'gen_firmware')()

        # Copy generated sources by plugin from plugin build_root to target-specific build_root
        for plugin in self._plugins:
            try:
                dst = os.path.join(
                    self._prj_cfg.build_root,
                    os.path.relpath(plugin._build_root,
                                    self._prj_cfg.build_root_base))
                if os.path.exists(dst):
                    shutil.rmtree(dst)
                shutil.copytree(plugin._build_root, dst)
            except OSError as exc:
                if exc.errno == errno.ENOTDIR:
                    shutil.copy(plugin._build_root, self._prj_cfg.build_root)
                else:
                    raise Exception(
                        f'ERROR: Could not copy from root:{plugin._build_root} to {self._prj_cfg.build_root}'
                    )

        # Indication that project setup for active target is complete
        self._setup_finished[target] = True
예제 #2
0
def main():
    print(TemplExtClk(target=FPGATarget(prj_cfg=EmuConfig(root='test', cfg_file=''))).render())
예제 #3
0
def main():
    from anasymod.targets import FPGATarget
    print(
        TemplVIO(target=FPGATarget(
            prj_cfg=EmuConfig(root='test', cfg_file=''))).render())