def test_functions(self) -> NoReturn: params = self.make_params("func") params['a'] = "alO@)IW)IJW)EWJ)FIJ" def check_rendered(data: str) -> NoReturn: assert data assert isinstance(data, str) assert params['a'] in data with use_mock_loader(): for res in (Render.functions(name="functions/func", **params), Render.functions(name="functions/func.v.jinja", fmt=None, **params)): check_rendered(res)
def generate(self, project_name: str = None, **kwargs) -> object: """ Generates FPGA configs """ if project_name or kwargs: self.setup(project_name=project_name, **kwargs) self.configs = {'LICENSE': Loader.load_static("LICENSE")} self.configs.update( dict( zip( map(lambda x: f"{self.project_name}.{x}", ("v", "qpf", "qsf", "sdc")), (Render.v(self.project_name, assignments=self._v, **self._mips_v), Render.qpf(self.project_name, **self._qpf), Render.qsf(self.project_name, func=self._functions, mips=self._mips_qsf, **self._qsf), Render.sdc(self.project_name, mips=self._mips_type, **self._sdc))))) # NOTE additional modules are placed in separate folder 'functions' self.configs.update( dict( zip( map(lambda x: x + ".v", self._functions), # file paths map(lambda x: Render.functions(x, **self._func), self._functions)))) if self._mips_type: # Generate additional configs for SchoolMIPS program_hex = os.path.join(PATHS.MIPS, "program.hex") self.configs['program.hex'] = Loader.load_static(program_hex) mips_path = os.path.join(PATHS.MIPS, self._mips_type) files = os.listdir(mips_path) self.configs.update( dict( zip( map(lambda x: os.path.join(DESTINATIONS.MIPS, x), files), map(lambda x: Loader.load_static(x, mips_path), files)))) return self