alkaid.codegen.xls package

Submodules

alkaid.codegen.xls.xls_codegen module

alkaid.codegen.xls.xls_codegen.build_xls_function(sol: CombLogic, fn_name: str = 'alir_fn') tuple[xls.Package, xls.ir_builder.Function]
alkaid.codegen.xls.xls_codegen.build_xls_io_wrapper(sol: CombLogic, fn_name: str = 'alir_fn') tuple[xls.Package, xls.ir_builder.Function]

Build an XLS function with unpacked array I/O.

Input: bits[max_inp_bw][N_inp] — array of uniform-width input elements Output: bits[max_out_bw][N_out] — array of uniform-width output elements

Uses RTL-style uniform bit layout: max_bw = max(k) + max(i) + max(f). Each element is LSB-aligned at bit offset max(f) - f_j within its slot.

alkaid.codegen.xls.xls_codegen.negate(bb: xls.ir_builder.BuilderBase, val: xls.ir_builder.BValue, bw_in: int, bw_out: int, in_signed: bool)
alkaid.codegen.xls.xls_codegen.shift_adder(bb: xls.ir_builder.BuilderBase, v0: xls.ir_builder.BValue, v1: xls.ir_builder.BValue, bw0: int, bw1: int, s0: int, s1: int, bw_out: int, drop_lsbs: int, shift: int, is_sub: int)

alkaid.codegen.xls.xls_model module

class alkaid.codegen.xls.xls_model.XLSModel(logic: CombLogic | Pipeline, prj_name: str | None = None)

Bases: object

Experimental XLS wrapper for ALIR JIT execution and Verilog generation.

compile(path: str | Path | None = None, scheduling_options: str = '', codegen_flags: str = 'generator: GENERATOR_KIND_COMBINATIONAL', with_delay_model: bool = False) str

Generate Verilog from the XLS IR via schedule_and_codegen.

Returns the Verilog text. If path is provided, writes it there.

jit() XLSModel

Build the XLS IR and JIT-compile for execution.

predict(data: ndarray[tuple[Any, ...], dtype[_ScalarT]] | Sequence[ndarray[tuple[Any, ...], dtype[_ScalarT]]], n_threads: int = 0) ndarray[tuple[Any, ...], dtype[float64]]

Run the JIT-compiled model on input data.

Parameters:
  • data (NDArray | Sequence[NDArray]) – Input data. Shape is flattened; number of samples determined by size / inp_size.

  • n_threads (int) – Unused (XLS JIT is single-threaded per call). Kept for API compatibility.

Returns:

Output in shape (n_samples, output_size).

Return type:

NDArray[np.float64]

Module contents