def print_kernel_xml( name: str, inputs: Iterable[Tuple[str, str, int, str]], outputs: Iterable[Tuple[str, str, int, str]], kernel_xml: TextIO, interface: str = 'm_axi', ) -> None: """Generate kernel.xml file. Args: name: Name of the kernel. inputs: Iterable of (port_name, bundle_name, width, _) of input ports. outputs: Iterable of (port_name, bundle_name, width, _) of output ports. kernel_xml: File object to write to. interface: Interface type, supported values are 'm_axi' and 'axis'. """ args: List[backend.Arg] = [] if interface == 'm_axi': for ports in outputs, inputs: for port_name, bundle_name, width, _ in ports: args.append( backend.Arg( cat=backend.Cat.MMAP, name=port_name, port=bundle_name, ctype=f'ap_uint<{width}>*', width=width, )) args.append( backend.Arg( cat=backend.Cat.SCALAR, name='coalesced_data_num', port='', ctype='uint64_t', width=64, )) elif interface == 'axis': for cat, ports in ((backend.Cat.ISTREAM, inputs), (backend.Cat.OSTREAM, outputs)): for port_name, _, width, _ in ports: ctype = f'stream<ap_axiu<{width}, 0, 0, 0>>&' args.append( backend.Arg( cat=cat, name=port_name, port='', ctype=ctype, width=width, )) else: raise util.InternalError(f'unexpected interface `{interface}`') backend.print_kernel_xml(name=name, args=args, kernel_xml=kernel_xml)
def print_kernel_xml(name: str, ports: Iterable[tapa.instance.Port], kernel_xml: IO[str]) -> None: """Generate kernel.xml file. Args: name: name of the kernel. ports: Iterable of tapa.instance.Port. kernel_xml: file object to write to. """ args = [] for port in ports: if port.cat == tapa.instance.Instance.Arg.Cat.SCALAR: cat = backend.Cat.SCALAR elif port.cat in { tapa.instance.Instance.Arg.Cat.MMAP, tapa.instance.Instance.Arg.Cat.ASYNC_MMAP }: cat = backend.Cat.MMAP elif port.cat == tapa.instance.Instance.Arg.Cat.ISTREAM: cat = backend.Cat.ISTREAM elif port.cat == tapa.instance.Instance.Arg.Cat.OSTREAM: cat = backend.Cat.OSTREAM else: raise ValueError(f'unexpected port.cat: {port.cat}') args.append( backend.Arg( cat=cat, name=port.name, port='', # use defaults ctype=port.ctype, width=port.width, )) backend.print_kernel_xml(name, args, kernel_xml)