3 #include "pybind11/operators.h"
4 #include "pybind11/pybind11.h"
5 #include "pybind11/stl.h"
6 #include "pybind11/stl_bind.h"
18 #ifdef PYBIND11_MODULE
19 PYBIND11_MODULE(xilinx_toolbox, m)
21 m.doc() =
"A collection of functions specifically designed to operate on Xilinx FPGA netlists.";
25 py::module m(
"xilinx_toolbox",
"A collection of functions specifically designed to operate on Xilinx FPGA netlists.");
28 py::class_<XilinxToolboxPlugin, RawPtrWrapper<XilinxToolboxPlugin>,
BasePluginInterface> py_xilinx_toolbox_plugin(
29 m,
"XilinxToolboxPlugin", R
"(This class provides an interface to integrate the Xilinx toolbox as a plugin within the HAL framework.)");
32 The name of the plugin.
38 Get the name of the plugin.
40 :returns: The name of the plugin.
45 The version of the plugin.
51 Get the version of the plugin.
53 :returns: The version of the plugin.
58 The description of the plugin.
64 Get the description of the plugin.
66 :returns: The description of the plugin.
71 A set of plugin names that this plugin depends on.
77 Get a set of plugin names that this plugin depends on.
79 :returns: A set of plugin names that this plugin depends on.
85 [](
Netlist* nl,
const std::vector<Gate*>& gates) -> std::optional<u32> {
93 log_error(
"python_context",
"{}", res.get_error().get());
98 py::arg(
"gates") = std::vector<Gate*>(),
100 Split LUTs with two outputs into two separate LUT gates.
101 Replaces ``LUT6_2`` with a ``LUT6`` and a ``LUT5`` gate if the respective outputs of the ``LUT6_2`` are actually used, i.e., connected to other gates.
103 :param hal_py.Netlist nl: The netlist to operate on.
104 :param list[hal_py.Gate] gates: The gates to consider. Defaults to an empty list, in which case all gates of the netlist are considered.
105 :returns: The number of split ``LUT6_2`` gates on success, ``None`` otherwise.
110 "split_shift_registers",
111 [](
Netlist* nl,
const std::vector<Gate*>& gates) -> std::optional<u32> {
119 log_error(
"python_context",
"{}", res.get_error().get());
124 py::arg(
"gates") = std::vector<Gate*>(),
126 Split shift register primitives and replaces them with equivalent flip-flops chains.
127 Currently only implemented for gate types ``SRL16E`` and ``SRLC32E``.
128 The created flip-flops are assigned to the module of the shift register gate that they replace.
130 :param hal_py.Netlist nl: The netlist to operate on.
131 :param list[hal_py.Gate] gates: The gates to consider. Defaults to an empty list, in which case all gates of the netlist are considered.
132 :returns: The number of split shift registers on success, ``None`` otherwise.
137 "remove_no_load_wires",
138 [](
Netlist* nl,
const std::vector<Net*>& nets) -> std::optional<u32> {
146 log_error(
"python_context",
"{}", res.get_error().get());
151 py::arg(
"nets") = std::vector<Net*>(),
153 Remove the "no load wire" nets that Vivado writes for unused output pins.
154 Vivado names such nets ``NLW_<instance>_<pin>_UNCONNECTED`` and only connects them to the output pin they stand in for.
155 A net is removed if its name starts with ``NLW_`` (or has ``NLW_`` right after a ``/`` in a flattened path) and ends with ``_UNCONNECTED``, optionally followed by a bit index such as ``(2)`` or ``[2]``, it has no destinations, and it is not a global output.
156 The output pins that drove the removed nets are left unconnected.
158 :param hal_py.Netlist nl: The netlist to operate on.
159 :param list[hal_py.Net] nets: The nets to consider. Defaults to an empty list, in which case all nets of the netlist are considered.
160 :returns: The number of removed nets on success, ``None`` otherwise.
166 [](
Netlist* nl,
const std::filesystem::path& xdc_file) ->
bool {
174 log_error(
"python_context",
"{}", res.get_error().get());
181 Parse an ``.xdc`` file and extract the position LOC and BEL data of each gate.
182 Translates the coordinates extracted from the ``.xdc`` file into integer values.
184 :param hal_py.Netlist nl: The netlist to operate on.
185 :param path xdc_file: The path to the ``.xdc`` file.
186 :returns: ``True`` on success, ``False`` otherwise.
190 #ifndef PYBIND11_MODULE
#define log_error(channel,...)
const Module * module(const Gate *g, const NodeBoxes &boxes)
This file contains functions specifically designed to preprocess Xilinx FPGA netlists.