.. _multi_mode_logic_block_tutorial: Multi-mode Logic Block Tutorial =============================== This tutorial aims to introduce how to build a representative multi-mode logic block by exploiting VPR architecture description language, as well as debugging tips to guarantee each mode of a logic block is functional. Definition ---------- Modern FPGA logic blocks are designed to operate in various modes, so as to provide best performance for different applications. VPR offers enriched syntax to support highly flexible multi-mode logic block architecture. :numref:`fig_frac_lut_le` shows the physical implementation of a Fracturable Logic Element (FLE), which consists of a fracturable 6-input Look-Up Table (LUT), two Flip-flops (FFs) and routing multiplexers to select between combinational and sequential outputs. .. _fig_frac_lut_le: .. figure:: frac_lut_le.png :scale: 125% Schematic of a fracturable logic element The FLE in :numref:`fig_frac_lut_le` can operate in two different modes: (a) dual 5-input LUT mode (see :numref:`fig_frac_lut_le_dual_lut5_mode`); and (b) single 6-input LUT mode (see :numref:`fig_frac_lut_le_lut6_mode`). Note that each operating mode does not change the physical implementation of FLE but uses part of the programmable resources. .. _fig_frac_lut_le_dual_lut5_mode: .. figure:: frac_lut_le_dual_lut5_mode.png :scale: 125% Simplified organization when the FLE in :numref:`fig_frac_lut_le` operates in dual 5-input LUT mode .. _fig_frac_lut_le_lut6_mode: .. figure:: frac_lut_le_lut6_mode.png :scale: 125% Simplified organization when the FLE in :numref:`fig_frac_lut_le` operates in 6-input LUT mode Architecture Description ------------------------ To accurately model the operating modes of the FLE, we will use the syntax ```` and ```` in architecture description language. .. code-block:: xml In the above XML codes, we define a ```` for the FLE by following the port organization in :numref:`fig_frac_lut_le`. Under the ````, we create two modes, ``n2_lut5`` and ``n1_lut6``, corresponding to the two operating modes as shown in :numref:`fig_frac_lut_le_dual_lut5_mode` and :numref:`fig_frac_lut_le_lut6_mode`. Note that we focus on operating modes here, which are sufficient to perform architecture evaluation. Under the dual 5-input LUT mode, we can define ```` and ```` to model the schematic in :numref:`fig_frac_lut_le_dual_lut5_mode`. .. code-block:: xml 235e-12 235e-12 235e-12 235e-12 235e-12 Under the 6-input LUT mode, we can define ```` and ```` to model the schematic in :numref:`fig_frac_lut_le_lut6_mode`. .. code-block:: xml 261e-12 261e-12 261e-12 261e-12 261e-12 261e-12 Full example can be found at `link `_. Validation in packer -------------------- After finishing the architecture description, the next step is to validate that VPR can map logic to each operating mode. Since VPR packer will exhaustively try each operating mode and finally map logic to one of it. As long as there is an operating mode that is feasible for mapping, VPR will complete packing without errors. However, this may shadow the problems for other operating modes. It is entirely possible that an operating mode is not defined correctly and is always dropped by VPR during packing. Therefore, it is necessary to validate the correctness of each operating mode. To efficiently reach the goal, we will temporarily apply the syntax ``disable_packing`` to specific modes, so as to narrow down the search space. First, we can disable the dual 5-input LUT mode for packer, by changing .. code-block:: xml to .. code-block:: xml As a result, VPR packer will only consider the 6-input LUT mode during packing. We can try a benchmark `mult_2x2.blif `_ by following the design flow tutorial :ref:`basic_design_flow_tutorial`. If the flow-run succeed, it means that the 6-input LUT mode is being successfully used by the packer. Then, we can enable the dual 5-input LUT mode for packer, and disable the 6-input LUT mode, by changing .. code-block:: xml to .. code-block:: xml In this case, VPR packer will consider the dual 5-input LUT mode during packing. We can again try the same benchmark `mult_2x2.blif `_ by following the design flow tutorial :ref:`basic_design_flow_tutorial`. If the flow-run succeed, it means that the dual 5-input LUT mode is being successfully used by the packer. Finally, after having validated that both operating modes are being successfully used by the packer, we can re-enable both operating modes by changing to .. code-block:: xml Now, VPR packer will try to choose the best operating mode to use. Tips for Debugging ------------------ When packing fails on a multi-mode logic block, the following procedures are recommended to quickly spot the bugs. - Apply ``disable_packing`` to all the modes, except the one you suspect to be problematic. In the example of this tutorial, you may disable the packing for mode ``n2_lut5`` and focus on debugging mode ``n1_lut6``. .. code-block:: xml - Turn on verbose output of packer ``--pack_verbosity`` (see details in :ref:`packing_options`. Recommend to use a higher verbosity number than the default value, e.g., 5. Consider the example blif and architecture in this tutorial, you may execute ``vpr`` with .. code-block:: shell vpr k6_frac_N10_40nm.xml mult_2x2.blif --pack_verbosity 5 - Packer will show detailed information about why it fails. For example: .. code-block:: shell FAILED Detailed Routing Legality Placed atom 'p3' (.names) at clb[0][default]/fle[4][n1_lut6]/ble6[0][default]/lut6[0][lut6]/lut[0] (921:cluster-external source (LB_SOURCE)-->1:'clb[0].I[1]') (1:'clb[0].I[1]'-->62:'fle[0].in[1]') (62:'fle[0].in[1]'-->123:'ble6[0].in[1]') (123:'ble6[0].in[1]'-->131:'lut6[0].in[1]') (131:'lut6[0].in[1]'-->138:'lut[0].in[1]') (138:'lut[0].in[1]'-->930:cluster-internal sink (LB_SINK accessible via architecture pins: clb[0]/fle[0]/ble6[0]/lut6[0]/lut[0].in[0], clb[0]/fle[0]/ble6[0]/lut6[0]/lut[0].in[1], clb[0]/fle[0]/ble6[0]/lut6[0]/lut[0].in[2], clb[0]/fle[0]/ble6[0]/lut6[0]/lut[0].in[3], clb[0]/fle[0]/ble6[0]/lut6[0]/lut[0].in[4], clb[0]/fle[0]/ble6[0]/lut6[0]/lut[0].in[5])) Which indicates that input ports of ```` in the mode ``n1_lut6`` may be dangling, and thus leads to failures in routing stage of packing. - You may modify the architecture description and re-run vpr until packing succeeds. - Move on to the next mode you will debug and repeat from the first step. The debugging tips are not only applicable to the example showed in this tutorial but rather general to any multi-mode logic block architecture.