A method, device and medium for merging and decomposing FPGA lookup tables
By collaboratively executing LUT merging and decomposition operations, utilizing Minor relation detection and Blossom maximum weight matching algorithm, and combining critical path awareness strategy, the problems of low resource utilization and coarse-grained timing management in existing FPGA logic synthesis are solved, achieving efficient resource utilization and timing performance assurance of FPGA chips.
Patent Information
- Application Number
- CN202610024508.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-09
- Publication Date
- 2026-03-17
- Estimated Expiration
- 2046-01-09
AI Technical Summary
Existing FPGA logic synthesis and netlist optimization technologies suffer from problems such as low resource utilization, lack of a global optimization perspective, fragmented merging and decomposition strategies, coarse-grained timing management, and weak equivalence verification mechanisms.
By collaboratively executing LUT merging and decomposition operations, we identify mergeable units using Minor relationship detection and small LUT pairing rules, employ the Blossom maximum weight matching algorithm to achieve global conflict-free optimal selection, combine a critical path awareness strategy to decompose LUTs only on non-critical paths, and ensure functional equivalence through truth table rearrangement and Shannon decomposition, dynamically updating the topology and temporal information of the LUT connection graph.
Significantly reduce the number of LUT units used, improve the logic resource utilization efficiency of FPGA chips, ensure that critical path delay does not increase, and ensure functional equivalence and timing performance.
Smart Images

Figure CN121503381B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of integrated circuit netlist optimization technology, and more specifically, to a method, apparatus, device, and medium for merging and decomposing FPGA lookup tables. Background Technology
[0002] In the FPGA (Field-Programmable Gate Array) design flow, one of the core tasks of the logic synthesis stage is to efficiently map high-level described Boolean logic functions into logic networks built from lookup tables (LUTs), and then perform coordinated optimization of resource consumption and circuit timing performance. Modern FPGA architectures commonly use 6-input LUTs (LUT6) as the basic logic unit, and some devices also support dual-output structures (such as LUT6_2, or LUT6D, in the Xilinx UltraScale series), allowing a single physical LUT to simultaneously implement two logic functions sharing most of their inputs, thereby significantly improving hardware resource utilization. However, current mainstream logic synthesis and mapping tools (such as ABC, Yosys, etc.) typically employ a two-stage strategy of "initial mapping + local optimization," performing only limited post-processing optimization after the initial LUT network generation, making it difficult to fully exploit the potential of dual-output LUTs.
[0003] Existing technologies for LUT network optimization have several key limitations. First, in terms of LUT merging strategies, most methods rely on local greedy algorithms, only considering merging adjacent or directly connected LUT pairs. This lacks a holistic consideration of the global network structure, easily leading to limited overall resource savings due to local optimal choices, and even causing conflicts or loss of subsequent optimization opportunities. Second, existing methods generally treat LUT merging and decomposition as independent operations, failing to establish a collaborative mechanism between them. In particular, they neglect the fact that purposeful LUT decomposition (such as splitting a LUT6 into a cascaded structure of LUT5 and LUT2) can create new input sharing relationships, thus providing the possibility for subsequent merging with neighboring LUTs to generate LUT6D, missing out on important area optimization space. Third, regarding timing management, existing optimization processes lack differentiated and refined control over the impact of merging and decomposition operations on the critical path of the circuit. While LUT merging typically does not increase the number of logic levels and thus has a relatively small impact on latency, LUT decomposition often introduces additional logic levels. If such operations are performed on the critical path, it can easily lead to a deterioration in the maximum latency of the circuit, and existing methods often lack effective critical path identification and protection mechanisms. Finally, in terms of functional correctness assurance, some optimization methods lack rigorous verification mechanisms when performing truth table operations (such as Shannon decomposition and truth table rearrangement), relying solely on heuristic rules or partial sampling tests. This poses a risk of introducing functional equivalence errors and makes it difficult to meet the requirements of high-reliability designs.
[0004] In view of the above, this application is hereby submitted. Summary of the Invention
[0005] This invention aims to provide a method, apparatus, device, and medium for merging and decomposing FPGA lookup tables, in order to address the shortcomings of existing FPGA logic synthesis and netlist optimization technologies, such as low resource utilization, lack of a global optimization perspective, fragmented merging and decomposition strategies, coarse-grained timing management, and weak equivalence verification mechanisms. This invention uses a mapped LUT network as input and, through the collaborative execution of LUT merging and decomposition operations, significantly reduces the number of LUT cells used and improves the logic resource utilization efficiency of FPGA chips while strictly maintaining circuit functional equivalence and critical path delay.
[0006] To solve the above-mentioned technical problems, the present invention is achieved through the following technical solution:
[0007] A method for merging and decomposing FPGA lookup tables, comprising:
[0008] S1, Obtain the FPGA-mapped lookup table (LUT) network;
[0009] S2, perform candidate pair identification on the LUT network, select conflict-free LUT candidate pairs with optimal weights for merging, and construct a LUT connection graph after merging to identify critical paths;
[0010] S3, based on the LUT connection diagram, decompose the LUTs on non-critical paths into smaller cascaded LUT units according to LUT priority order;
[0011] S4. After each decomposition, the network topology and timing information of the LUT connection graph are dynamically updated to complete the optimization of the FPGA netlist.
[0012] Preferably, S2 specifically comprises:
[0013] First, LUT5 and LUT6 pairs that can be merged into LUT6D are identified in the LUT network through Minor relation detection. Then, LUT2 to LUT5 pairs that can be merged are identified in the LUT network through small LUT pairing rules, forming a merging candidate set. The small LUT pairing rules are as follows: at least one input signal of the two LUTs is shared, the total number of inputs after merging is not greater than 5, and there is no data dependency between the two LUTs. The merging priority is calculated by weighting the number of shared inputs and the size weight.
[0014] Then, based on the candidate set for merging, an undirected candidate graph is constructed with LUTs as graph nodes, merging candidate relationships as edges, and merging priorities as edge weights. The Blossom maximum weight matching algorithm is then used to select the optimal merging set with the largest weight sum and no conflicts from the undirected candidate graph.
[0015] Finally, the LUT pairs in the optimal merge set are merged, and after the merge is completed, a LUT connection graph is constructed. The depth information of each LUT node in the LUT connection graph is calculated so as to identify the critical path of the LUT network by topological sorting and reverse traversal.
[0016] Preferably, when constructing the LUT connection graph, all LUTs in the LUT network are traversed, and the output signal of each LUT is extracted as a graph node;
[0017] Analyze the input signal of each LUT. If the input signal is the output of another LUT, then establish a directed edge between the two LUT nodes to construct the LUT connection graph.
[0018] Preferably, when identifying the critical path of the LUT network, a breadth-first search method is used to perform topological sorting on the LUT connection graph, and the forward depth of each LUT node is calculated synchronously during the sorting process. The formula for calculating the forward depth is:
[0019] ;
[0020] in, , Representing nodes respectively , Forward depth; For nodes The set of predecessor nodes, i.e., all directly related nodes The node that outputs the signal;
[0021] Maximum value based on forward depth The reverse depth of each LUT node is calculated by traversing in reverse. The formula is as follows:
[0022] ;
[0023] in, , Representing nodes respectively , The reverse depth; For nodes The set of successor nodes, i.e., all directly receiving nodes. The node that outputs the signal; Indicates any;
[0024] A LUT node that meets the following conditions is considered a critical path node:
[0025] or .
[0026] Preferably, the LUT5 and LUT6 pairs in the LUT network that can be merged into LUT6D are identified by Minor relation detection, specifically as follows:
[0027] Extract the set of 6 input signals of the LUT6 to be detected. and the set of 5 input signals of LUT5. ;
[0028] Verify that the two sets share at least 5 inputs and satisfy the input set constraints of the Minor relation: ;
[0029] Traversal ,contrast Find the unique difference input and record its index as ;
[0030] Filter out and The five shared inputs in the LUT6 are recorded, and their index set in the LUT6 input port is denoted as . ;
[0031] according to and Establish a mapping relationship between the old and new ports so that the first 5 input ports of the LUT6D correspond to... The shared input in the middle, the 6th input port corresponds to the difference input, that is Input;
[0032] Extract the original initialization vector of LUT6 ;
[0033] Iterate through each new address of the LUT6D, calculate its corresponding original address in reverse according to the old and new port mapping relationship, and then... The value at the original address is copied to the corresponding new address to obtain the new initialization vector of LUT6D. This completes the rearrangement of the truth table;
[0034] Iterate through each address of the LUT5, based on The mapping relationship of the ports is calculated, and the corresponding LUT6D address for each LUT5 address is calculated.
[0035] examine Is the value at the corresponding LUT6D address completely consistent with the value at the corresponding address of the original LUT5 initialization vector?
[0036] If all address values match, the equivalence verification passes; otherwise, the merge fails and the process terminates.
[0037] Create a new LUT6D unit based on the old and new port mapping relationship, set the input ports to connect to the corresponding shared input and differential input respectively, and then... Configure the INIT parameters for LUT6D, connect the Z5 port of LUT6D to the output of the original LUT5, and connect the Z port to the output of the original LUT6;
[0038] Remove the LUT5 and LUT6 elements to be merged from the original network;
[0039] The signal driving mapping relationship of LUT6D is recorded as follows: Z5 output corresponds to the 5 inputs of the original LUT5, and Z output corresponds to the 6 inputs of the original LUT6. The node connection relationship and dependency relationship of the LUT network are updated.
[0040] Preferably, based on the LUT connection graph, the LUTs on non-critical paths are decomposed into smaller cascaded LUT units according to LUT priority, specifically:
[0041] Identify LUTs on non-critical paths in the LUT connection graph and denote them as LUTs to be decomposed. Decomposition is performed in two stages: LUT6 decomposition and small LUT decomposition.
[0042] Traverse all LUT6s in the LUT connection graph. If there exists a target LUT6 that satisfies the following condition with respect to a LUT6 in the LUT to be decomposed: the input set has 5 shared inputs and the remaining input is a different input, then include the LUT6 in the LUT to be decomposed in the decomposition candidate set and record the index of the different input. ;
[0043] If there are at least two target small LUTs in the LUT connection graph that share inputs with the LUT in the LUT to be decomposed, then the LUT in the LUT to be decomposed will be included in the decomposition candidate set.
[0044] During the LUT6 decomposition phase: The LUT6s to be decomposed in the candidate decomposition set are... Set it to 0, perform Shannon decomposition on its 64-bit original initialization vector, split it into a concatenated structure of new LUT5 and new LUT2, and extract the lower 32 bits as the initialization vector of new LUT5;
[0045] Define the two input mappings of the new LUT2 as follows: the first input is connected to the difference input, and the second input is connected to the output of the new LUT5;
[0046] Iterate through all input combinations of the LUT6 to be decomposed in the candidate decomposition set, and store the output value of each new LUT2 address into the output verification set; wherein, the output value of the new LUT2 address is determined by the corresponding two inputs;
[0047] If the output verification set contains multiple different output values, it is determined that the LUT6 to be decomposed cannot be decomposed, and the current decomposition process is terminated.
[0048] Simultaneously, the output of the cascaded structure of the new LUT5 and the new LUT2 is compared with the output of the LUT6 to be decomposed: if the outputs of all input combinations of the LUT6 to be decomposed in the decomposition candidate set are consistent, the equivalence verification is passed; otherwise, the decomposition fails and the current process is terminated.
[0049] If the equivalence verification passes, create a new LUT5 unit and a new LUT2 unit respectively. Connect the first input of the newly created LUT2 unit to the difference input, connect the second input to the output of the new LUT5 unit, and connect its output directly to the output signal of the original LUT6 to be decomposed. Then remove the original LUT6 to be decomposed from the network.
[0050] The new LUT5 unit and the corresponding target LUT6 are merged into a new LUT6D unit based on the Minor relationship detection rule. If the merging fails, the new LUT5 unit and the new LUT2 unit generated in this decomposition are deleted, the network connection of the original LUT6 to be decomposed is restored, and the LUT6 decomposition is completed.
[0051] When performing the small LUT decomposition stage: decompose LUT5, LUT4, and LUT3 in the decomposition candidate set according to priority. Then, perform Shannon decomposition into a new LUT cascade structure, input mapping allocation of the new LUT, output verification of the cascade structure, equivalence verification, and merging operation of the new LUT unit with the target LUT in the LUT6 decomposition stage.
[0052] The LUT5 to be decomposed is decomposed into a cascaded structure of two new LUT3s, the LUT4 to be decomposed is decomposed into a cascaded structure of new LUT2 and new LUT3, and the LUT3 to be decomposed is decomposed into a cascaded structure of two new LUT2s.
[0053] Preferably, the network topology and timing information of the LUT connection graph are dynamically updated after each decomposition, specifically as follows:
[0054] Add the newly generated LUT nodes to the LUT connection graph to establish new input-output directed edges;
[0055] Recalculate the forward and backward depths of the new LUT nodes, and update the labels of critical path nodes for use in the next non-critical path decomposition.
[0056] The present invention also provides a device for merging and decomposing FPGA lookup tables, comprising:
[0057] The LUT network acquisition module is used to acquire the LUT networks mapped on the FPGA.
[0058] The LUT merging and identification module is used to identify candidate pairs in the LUT network, select conflict-free LUT candidate pairs with the optimal weights for merging, and construct an LUT connection graph after merging to identify critical paths.
[0059] The LUT decomposition module is used to decompose the LUTs on non-critical paths into smaller cascaded LUT units according to the LUT connection relationship graph and LUT priority order.
[0060] The topology update module is used to dynamically update the network topology and timing information of the LUT connection graph after each decomposition, thereby optimizing the FPGA netlist.
[0061] The present invention also provides a device for merging and decomposing FPGA lookup tables, including a processor and a memory, wherein the memory stores a computer program that can be executed by the processor to implement the merging and decomposing method of FPGA lookup tables as described above.
[0062] The present invention also provides a computer-readable storage medium storing computer-readable instructions, which, when executed by a processor of the device on which the computer-readable storage medium resides, implement the above-described method for merging and decomposing an FPGA lookup table.
[0063] In summary, compared with the prior art, the present invention has the following beneficial effects:
[0064] In the LUT merging stage, this invention utilizes Minor relation detection and small LUT pairing rules to accurately identify mergeable units, and employs the Blossom maximum weight matching algorithm to achieve a globally conflict-free optimal selection, avoiding suboptimal solutions caused by local greedy strategies. In the LUT decomposition stage, a critical path-aware strategy is adopted, decomposing only large input LUTs on non-critical paths, and creating new merging opportunities by attempting to recombine them with adjacent target LUTs, forming a "decomposition-merging" collaborative optimization closed loop. Throughout the optimization process, the functional equivalence of each operation is ensured through truth table rearrangement, Shannon decomposition extraction, input mapping, and output consistency verification. By dynamically maintaining the LUT connection graph, forward depth, and backward depth information, the timing behavior is precisely controlled to ensure that critical path delays do not increase.
[0065] This invention significantly reduces LUT resource consumption by synergistically applying LUT merging and decomposition strategies, while strictly ensuring functional equivalence and timing constraints. Attached Figure Description
[0066] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained from these drawings without creative effort.
[0067] Figure 1 This is a flowchart illustrating a method for merging and decomposing FPGA lookup tables provided in Embodiment 1.
[0068] Figure 2 This is a schematic diagram of the LUT merging process provided in Example 1.
[0069] Figure 3 This is a schematic diagram of the LUT decomposition process provided in Example 1.
[0070] Figure 4 This is a schematic diagram of a merging and decomposing device for an FPGA lookup table provided in Embodiment 2.
[0071] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Detailed Implementation
[0072] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0073] Example 1
[0074] Embodiment 1 of the present invention provides a method for merging and decomposing FPGA lookup tables, which can be implemented by an FPGA lookup table merging and decomposing device (hereinafter referred to as optimization device), specifically, executed by one or more processors within the optimization device.
[0075] In this embodiment, the optimization device may be an electronic device equipped with a processor, the processor having a computer program for the merging and decomposition method of the FPGA lookup table and the computer program being executable, such as a computer, smartphone, smart tablet, workstation, etc., which are not limited here.
[0076] This embodiment achieves improved resource utilization and guaranteed timing performance of FPGA netlists through a closed-loop process of LUT merging optimization, non-critical path decomposition, and dynamic updates of topology and timing.
[0077] like Figure 1 As shown, a method for merging and decomposing FPGA lookup tables includes steps S1 to S4.
[0078] S1, obtain the FPGA-mapped lookup table (LUT) network.
[0079] The input to this embodiment is a LUT network generated using existing LUT mapping techniques (such as the if command in the ABC tool or the Yosys synthesis tool). This network contains LUT1 to LUT6 cells and their connections, provided in Verilog netlist or BLIF format.
[0080] The netlist data is parsed to extract the input signal set, output signal identifier, and cell type for each LUT. An index mapping table between LUT cells and signals is established to provide data support for subsequent merging and decomposition.
[0081] S2, perform candidate pair identification on the LUT network, select the LUT candidate pairs that are conflict-free and have the optimal weights for merging, and construct the LUT connection graph after merging to identify the critical path.
[0082] The core of this step is to reduce the number of LUTs by using two-stage candidate identification and optimal matching and merging, while constructing a topology graph and locating critical paths to define the scope for decomposition and optimization.
[0083] Phase 1: Candidate merging and identification phase, such as Figure 2 As shown, it includes a parallel Minor relation detection step (i.e., merging LUT5 and LUT6) and a small LUT pairing step (i.e., merging small LUTs).
[0084] (1) Minor Relationship Detection
[0085] like Figure 2 As shown, firstly, the LUT5 and LUT6 pairs that can be merged into LUT6D in the LUT network are identified through Minor relation detection, specifically:
[0086] Extract the set of 6 input signals of the LUT6 to be detected. and the set of 5 input signals of LUT5. ;
[0087] Verify that the two sets share at least 5 inputs and satisfy the input set constraints of the Minor relation: You can then use the MergeKeepOrder function to calculate whether the total number of inputs after merging is 6.
[0088] Traversal ,contrast Find the unique difference input Record its index as ;
[0089] Filter out and The five shared inputs in the LUT6 are recorded, and their index set in the LUT6 input port is denoted as . ;
[0090] according to and Establish a mapping relationship between the old and new ports so that the first 5 input ports of the LUT6D correspond to... The shared input in the middle, the 6th input port corresponds to the difference input, that is Input;
[0091] Extract the original initialization vector of LUT6 ;
[0092] Iterate through each new address of the LUT6D, calculate its corresponding original address in reverse according to the old and new port mapping relationship, and then... The value at the original address is copied to the corresponding new address to obtain the new initialization vector of LUT6D. This completes the rearrangement of the truth table;
[0093] Iterate through each address of the LUT5, based on The mapping relationship of the ports is calculated, and the corresponding LUT6D address for each LUT5 address is calculated.
[0094] examine Is the value at the corresponding LUT6D address completely consistent with the value at the corresponding address of the original LUT5 initialization vector?
[0095] If all address values match, the equivalence verification passes; otherwise, the merge fails and the process terminates.
[0096] Create a new LUT6D unit based on the old and new port mapping relationship, set the input ports to connect to the corresponding shared input and differential input respectively, and then... Configure the INIT parameters for LUT6D, connect the Z5 port of LUT6D to the output of the original LUT5, and connect the Z port to the output of the original LUT6;
[0097] Remove the LUT5 and LUT6 elements to be merged from the original network;
[0098] The signal driving mapping relationship of LUT6D is recorded as follows: Z5 output corresponds to the 5 inputs of the original LUT5, and Z output corresponds to the 6 inputs of the original LUT6. The node connection relationship and dependency relationship of the LUT network are updated.
[0099] (2) Small LUT pairing
[0100] Next, mergeable LUT2 to LUT5 pairs in the LUT network are identified using small LUT pairing rules. The small LUT pairing rules are as follows:
[0101] The two LUTs must share at least one input signal, calculated using the Countshared function;
[0102] The total number of inputs after merging is no greater than 5, as verified by the MergeKeepOrder function;
[0103] Furthermore, there is no data dependency between the two LUTs, meaning that it checks whether the output of one LUT is the input of the other LUT;
[0104] Furthermore, the merging priority is calculated by weighting the number of shared inputs and the size weight. For example, when both LUTs are LUT5, the size weight is 5; when only one is LUT5, the weight is 3; otherwise, the weight is 0. Candidate pairs with higher priority are selected for merging more frequently.
[0105] The system identifies LUT5 and LUT6 pairs that can be merged into LUT6D by detecting Minor relationships, and identifies LUT2 to LUT5 pairs that can be merged by small LUT pairing, thus forming a candidate set for merging.
[0106] (3) Selection of conflict-free optimal candidate pairs
[0107] Based on the aforementioned candidate set for merging, an undirected candidate graph G=(V,E) is constructed, with LUTs as graph nodes, candidate merging relationships as edges, and merging priorities as edge weights. The Blossom maximum weight matching algorithm is then used to select the optimal merging set from the undirected candidate graph that has the largest sum of weights and is conflict-free.
[0108] The execution logic of the Blossom algorithm first initializes the matching state of all nodes in the undirected candidate graph G to unmatched. Then, it iteratively calls BFS to search for augmenting paths for each unmatched node. During the search, once an odd cycle (Blossom) is detected, it is transformed into a supernode through a shrinking operation and the orig array is used to maintain the affiliation relationship. If an augmenting path is successfully found, the augment function is called to flip the edge state on the path to increase the number of matches. This process continues to iterate until no new augmenting path can be found.
[0109] Output the matching result, which maximizes the sum of the weights of all matching pairs, and ensures that no two merged pairs share a LUT node, meaning that no two edges in the matching set M have a common vertex.
[0110] (4) Perform LUT merge operation
[0111] Finally, the LUT pairs in the optimal merge set are merged, and a LUT connection graph is constructed after the merge is completed (i.e., ...). Figure 3 (Based on the LUT network graph), calculate the depth information of each LUT node in the LUT connection graph, so as to identify the critical path of the LUT network through topological sorting and reverse traversal.
[0112] When constructing the LUT connection graph, all LUTs in the LUT network are traversed, and the output signal of each LUT is extracted as a graph node. For example, for the dual-output LUT6D unit, its Z5 and Z output signals are extracted as two independent graph nodes; for ordinary single-output LUTs (LUT2 to LUT6), its Z output signal is extracted as a node. Then, the input signal of each LUT is analyzed. If the input signal is the output of another LUT, a directed edge is established between the two LUT nodes to construct the LUT connection graph.
[0113] Simultaneously, the in-degree of each node, i.e., the number of edges pointing to that node, is dynamically counted during the graph construction process. When identifying the critical path of the LUT network, a breadth-first search (BFS) method is used to perform topological sorting on the LUT connection graph, and the forward depth of each LUT node is calculated synchronously during the sorting process.
[0114] First, add all initial nodes with an in-degree of 0 to the processing queue and initialize their depth to 0. Then, sequentially remove nodes from the queue and add them to the topology sequence. Traverse all successor nodes of each successor node, decrementing their in-degree by 1. When the in-degree of a successor node reaches 0, calculate its forward depth. After calculation, add the node to the queue until the queue is empty.
[0115] The formula for calculating the forward depth is:
[0116] ;
[0117] in, , Representing nodes respectively , Forward depth; For nodes The set of predecessor nodes, i.e., all directly related nodes The node that outputs the signal.
[0118] Maximum value based on forward depth The reverse depth of each LUT node is calculated by traversing in reverse. The formula is as follows:
[0119] ;
[0120] in, , Representing nodes respectively , The reverse depth; For nodes The set of successor nodes, i.e., all directly receiving nodes. The node that outputs the signal;
[0121] A LUT node that meets the following conditions is considered a critical path node:
[0122] or .
[0123] Subsequent decomposition and optimization should avoid critical path nodes to prevent timing degradation due to increased logical levels.
[0124] S3. Based on the LUT connection diagram, decompose the LUTs on non-critical paths into smaller cascaded LUT units according to LUT priority order.
[0125] The core of this step is to decompose only non-critical path LUTs, creating new merging opportunities while ensuring that timing performance does not degrade. The processing priority of the LUTs to be decomposed is determined in the order of LUT6, LUT5, LUT4, and LUT3.
[0126] Based on the LUT connection graph, the LUTs on non-critical paths are decomposed into smaller cascaded LUT units according to LUT priority, specifically:
[0127] Identify LUTs on non-critical paths in the LUT connection graph and denote them as LUTs to be decomposed. The decomposition is performed in two stages: LUT6 decomposition and small LUT decomposition.
[0128] like Figure 3As shown, traverse all LUT6s in the LUT connection graph. If there exists a target LUT6 that satisfies the following condition with the LUT6 in the LUT to be decomposed: the input set has 5 shared inputs and the remaining input is a different input, then the LUT6 in the LUT to be decomposed is included in the decomposition candidate set, and the index of the different input is recorded. .
[0129] For example, for any lut6_a to be decomposed, the system performs the following filtering: if lut6_a is on the critical path or is an input to the original netlist, it is skipped; then, all input signals of lut6_a are traversed, and other LUT6 units sharing the input are found using mapping, such as lut6_b. It checks whether lut6_b is not on the critical path and is not an original LUT, and calculates the number of shared inputs between the two: if the number of shared inputs is exactly 5, then lut6_a is considered to have decomposition potential and is expected to be merged with lut6_b after decomposition.
[0130] If there are at least two target small LUTs in the LUT connection graph that share inputs with the LUT in the LUT to be decomposed, then the LUT in the LUT to be decomposed will be included in the decomposition candidate set.
[0131] During the LUT6 decomposition phase:
[0132] Step 1: First, determine the decomposition scheme. Then, select the LUT6 files to be decomposed from the candidate decomposition set. Set it to 0, perform Shannon decomposition on its 64-bit original initialization vector, splitting it into a cascaded structure of new LUT5 and new LUT2.
[0133] Step 2: Extract the truth table of the lower-level LUT. Extract the lower 32 bits as the initialization vector for the new LUT5.
[0134] Step 3: Construct the truth table of the upper-level LUT. Define the mapping relationship between the two inputs of the new LUT2 as follows: the first input is connected to the difference input, and the second input is connected to the output of the new LUT5;
[0135] Traverse all input combinations of the LUT6 to be decomposed in the candidate decomposition set, and store the output value of each new LUT2 address into the output verification set; wherein, the output value of the new LUT2 address is determined by the corresponding two inputs.
[0136] If the output verification set contains multiple different output values, it is determined that the LUT6 to be decomposed cannot be decomposed, and the current decomposition process is terminated.
[0137] Simultaneously, the output of the cascaded structure of the new LUT5 and the new LUT2 is compared with the output of the LUT6 to be decomposed: if the outputs of all input combinations of the LUT6 to be decomposed in the decomposition candidate set are consistent, the equivalence verification is passed; otherwise, the decomposition fails and the current process is terminated.
[0138] Step 4: Create cascaded units and attempt to merge them. If the equivalence verification passes, create new LUT5 units and new LUT2 units respectively. Connect the first input of the newly created LUT2 unit to the difference input, connect the second input to the output of the new LUT5 unit, and connect its output directly to the output signal of the original LUT6 to be decomposed. Remove the original LUT6 to be decomposed from the network.
[0139] The new LUT5 unit and the corresponding target LUT6 are merged into a new LUT6D unit based on the Minor relationship detection rule. If the merging fails, the new LUT5 unit and the new LUT2 unit generated in this decomposition are deleted, the network connection of the original LUT6 to be decomposed is restored, and the LUT6 decomposition is completed.
[0140] For example, let's continue with the example above. First, compare the input sets of lut6_a and lut6_b, and identify the unique input signal in lut6_a that is not shared by lut6_b. The index is recorded. When constructing the LUT5 part, the remaining 5 inputs from lut6_a (excluding the difference inputs) are taken as the input ports of the newly generated LUT5. Based on the Shannon decomposition principle, the 32-bit truth table of LUT5 is extracted. Specifically, for each address of the LUT5 truth table, it is mapped back to the 64-bit address space of the original LUT6 (with the difference bits fixed to 0), and the value of the corresponding bit in the original truth table is read. When constructing the LUT2 part, its input is... And the output of the new LUT5; iterate through all 64 input combinations of the original LUT6 and calculate The value of LUT5 and the expected output value of LUT5 are combined to form a 2-bit address index for LUT2. The output of the original LUT6 under the same index is checked for consistency. If consistent, a 4-bit truth table is generated; otherwise, the decomposition fails. After completing the equivalence verification (simulating the generated LUT5-LUT2 cascade structure and comparing its output with the original LUT6), if the verification passes, LUT5 and LUT2 cells are instantiated in the netlist, port connections and truth table parameters are configured, and signal drive relationships are updated. Finally, the output signals of the newly generated LUT5 and LUT2 are registered in the bit2driver mapping table, and then the merge function is called to attempt to merge the newly generated LUT5 with the target lut6_b into LUT6D. If the merge is successful, LUT2 in the cascaded structure is retained, and the merged original LUT5 and target lut6_b are removed from the module. If the merge fails, a recovery process is performed: the output signal of the new LUT is removed from the bit2driver mapping table, the output signal mapping of the original LUT6 is restored, the newly generated LUT5 and LUT2 units are removed from the module, and the original LUT6 is retained without any modification. If the operation is successful, the critical path update mechanism is then triggered, marking the original LUT6 and its merged LUT as processed to avoid duplicate operations.
[0141] During the small LUT decomposition stage: the LUT5, LUT4, and LUT3 in the decomposition candidate set are decomposed in order of priority (LUT5>LUT4>LUT3). The Shannon decomposition into a new LUT cascade structure, the input mapping allocation of the new LUT, the output verification of the cascade structure, the equivalence verification, and the merging operation of the new LUT unit with the target LUT are performed in sequence, as in the LUT6 decomposition stage.
[0142] Specifically, all smaller LUTs are traversed, skipping critical path nodes and the original LUT. For each LUT to be decomposed, two target LUTs (target LUT 1, target LUT 2) are searched in the set of smaller LUTs, satisfying the following conditions: No data dependency: There are no direct input / output connections between the LUT to be decomposed and the target LUTs. Input sharing: The LUT to be decomposed shares at least one input signal with each target LUT. Merging feasibility: The total number of inputs after merging the decomposed sub-LUTs with their corresponding target LUTs does not exceed 5.
[0143] Sorting and Optimization: For LUT5: Prioritize combinations that share fewer inputs with the target LUT (sorted in ascending order of shared input count) to reserve as many free ports as possible for the decomposed sub-LUTs. For LUT4 and LUT3: Prioritize combinations that share more inputs with the target LUT (sorted in descending order of shared input count) to improve the merging success rate. Qualifying combinations are packaged into candidate objects, containing the LUT to be decomposed, the two target LUTs, and a priority score.
[0144] The LUT5 to be decomposed is decomposed into a cascaded structure of two new LUT3s, the LUT4 to be decomposed is decomposed into a cascaded structure of new LUT2 and new LUT3, and the LUT3 to be decomposed is decomposed into a cascaded structure of two new LUT2s.
[0145] (1) LUT5 decomposition (target structure: LUT3 + LUT3): First, analyze the five input signals of LUT5 and classify them into four categories: shared by both targets simultaneously, shared only by target 1, shared only by target 2, and not shared by any target. Then, allocate the inputs to the lower-level LUT3_a according to priority until three inputs are available; the remaining two inputs are allocated to the upper-level LUT3_b. Next, extract the 8-bit truth table of LUT3_a and construct the truth table of LUT3_b, whose inputs include the output of LUT3_a and the remaining two original inputs. Verify all input combinations to ensure that no conflicting outputs occur. Finally, create two new LUT3 units and attempt to merge them with the two target LUTs respectively; if at least one merge is successful, commit the changes; otherwise, perform a rollback operation.
[0146] (2) LUT4 decomposition (target structure: LUT2 + LUT3): LUT4 is decomposed into a lower-level LUT2 (which is allocated 2 inputs) and an upper-level LUT3 (which receives the output of LUT2 and 2 other inputs). The input allocation strategy is dynamically adjusted according to the sharing situation. The remaining truth table construction, consistency check, creation and merging steps are similar to those of LUT5 decomposition.
[0147] (3) LUT3 decomposition (target structure: LUT2 + LUT2): Decompose LUT3 into lower layer LUT2_a (allocate 2 inputs) and upper layer LUT2_b (receive LUT2_a output and another input). The remaining steps are the same as above.
[0148] S4. After each decomposition, the network topology and timing information of the LUT connection graph are dynamically updated to complete the optimization of the FPGA netlist.
[0149] After each successful decomposition operation (whether it's a LUT6 or a small LUT), the system immediately calls the update function to maintain the accuracy of the timing information.
[0150] like Figure 3 As shown, the network topology and timing information of the LUT connection graph are dynamically updated after each decomposition to ensure the accuracy of subsequent optimizations, and finally, the optimized FPGA netlist is output. Specifically:
[0151] Step 1: Initialize the reverse depth of the new LUT nodes, inheriting the timing constraints of the original decomposed LUT. Add the newly generated LUT nodes to the LUT connection graph, establishing new input-output directed edges, which represent the reverse depth of the upper-layer new LUT (cascaded output). Equal to the original LUT Simultaneously, calculate the new LUT (input) at the lower layer. Subtract 1 from the value of the parent node. If the forward depth of the new node... It has exceeded its If so, it will be immediately marked as a critical path node.
[0152] Step 2: Recalculate the forward and backward depths of the new LUT nodes, and update the labels of critical path nodes for the next non-critical path decomposition.
[0153] Specifically, the successor connections of the original LUT are transferred to the newly generated upper-level LUT; starting from the upper-level LUT, all successor nodes are traversed using BFS, according to the formula... Recalculate the depth if an increase in the depth of a node leads to... If so, then add it to the critical path set.
[0154] During forward propagation, starting from the driver input node of the lower-level LUT, the predecessor nodes are traversed forward using BFS, and the current node's... Decrease by 1; if the update results in Mark this node as a critical path node. Sort by priority and number of input connections.
[0155] Finally, clear the successor relationships of the original decomposed LUT in the graph structure to ensure the connectivity and correctness of the topological graph.
[0156] After all decomposable LUTs have been processed, an optimized LUT network list is generated. This list improves LUT resource utilization while ensuring that the critical path latency does not increase.
[0157] In summary, compared with the prior art, the present invention has the following beneficial effects:
[0158] This invention makes full use of dual-output LUT resources, efficiently generating LUT6D through Minor relation detection and small LUT pairing, thereby improving resource utilization.
[0159] This invention uses the Blossom maximum matching algorithm to achieve the globally optimal merging selection, which achieves a better merging scheme compared to the local greedy strategy;
[0160] This invention employs a collaborative optimization approach of decomposition and merging. First, merging reduces the number of LUTs, and then decomposition creates new merging opportunities, expanding the optimization space.
[0161] This invention employs critical path-aware optimization, decomposing LUTs only on non-critical paths to avoid timing performance degradation caused by optimization. It allows for free optimization during the merging phase and dynamically updates critical path information during the decomposition phase, ensuring that optimization does not increase circuit delay.
[0162] This invention employs strict equivalence guarantees and uses formal verification methods to ensure the correctness of the optimized circuit function;
[0163] This invention features a high degree of automation and significant effects, requiring no complex parameter adjustments.
[0164] Experiments show that the number of LUTs is reduced by an average of 10.7% across 14 standard test cases, while the critical path delay remains unchanged in all cases, fully verifying the effectiveness and practicality of the present invention.
[0165] Example 2
[0166] like Figure 4 As shown, the second embodiment of the present invention also provides a device for merging and decomposing FPGA lookup tables, including:
[0167] The LUT network acquisition module is used to acquire the LUT networks mapped on the FPGA.
[0168] The LUT merging and identification module is used to identify candidate pairs in the LUT network, select conflict-free LUT candidate pairs with the optimal weights for merging, and construct an LUT connection graph after merging to identify critical paths.
[0169] The LUT decomposition module is used to decompose the LUTs on non-critical paths into smaller cascaded LUT units according to the LUT connection relationship graph and LUT priority order.
[0170] The topology update module is used to dynamically update the network topology and timing information of the LUT connection graph after each decomposition, thereby optimizing the FPGA netlist.
[0171] Example 3
[0172] The third embodiment of the present invention also provides a device for merging and decomposing FPGA lookup tables, which includes a memory and a processor. The memory stores a computer program that can be executed by the processor to implement the merging and decomposing method of FPGA lookup tables as described above.
[0173] Example 4
[0174] The fourth embodiment of the present invention also provides a computer-readable storage medium storing computer-readable instructions. When the computer-readable instructions are executed by the processor of the device where the computer-readable storage medium is located, they implement the merging and decomposition method of the FPGA lookup table as described above.
[0175] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for merging and splitting of FPGA lookup tables, characterized in that, The method comprises the following steps: S1, obtaining a lookup table (LUT) network mapped by an FPGA; S2, performing candidate pair identification on the LUT network, selecting a LUT candidate pair without conflict and with optimal weight for merging, and constructing a LUT connection relationship graph after merging to identify a critical path; S3, based on the LUT connection relationship graph, decomposing LUTs on a non-critical path into smaller cascaded LUT units in order of LUT priority; S4, dynamically updating the network topology structure and timing information of the LUT connection relationship graph after each decomposition to complete optimization of the FPGA netlist; The S2 specifically comprises the following steps: Firstly, LUT5 and LUT6 pairs that can be merged into LUT6D in the LUT network are identified through Minor relationship detection, and LUT2 to LUT5 pairs that can be merged in the LUT network are identified through a small LUT pairing rule to form a merging candidate set; The small LUT pairing rule is that the input signals of two LUTs share at least one input signal, the total input number after merging is not greater than 5, there is no data dependency between the two LUTs, and the merging priority is calculated by weighting the number of shared inputs and the size weight; Then, a non-directional candidate graph is constructed based on the merging candidate set, taking LUT as a graph node, merging candidate relationship as an edge, and merging priority as an edge weight, and the Blossom maximum weight matching algorithm is used to screen an optimal merging set with maximum weight and without conflict from the non-directional candidate graph; Finally, a merging operation is performed on the LUT pairs in the optimal merging set, and after the merging is completed, a LUT connection relationship graph is constructed, and the depth information of each LUT node in the LUT connection relationship graph is calculated to identify the critical path of the LUT network through topological sorting and reverse traversal.
2. The method of claim 1, wherein When constructing the LUT connection relationship graph, all LUTs in the LUT network are traversed, and the output signals of each LUT are extracted as graph nodes; The input signals of each LUT are analyzed, and if the input signal is the output of another LUT, a directed edge is established between the two LUT nodes to construct the LUT connection relationship graph.
3. The method of claim 2, wherein When identifying the critical path of the LUT network, a breadth-first search method is used to topologically sort the LUT connection relationship graph, and the forward depth of each LUT node is calculated synchronously during the sorting process, and the calculation formula of the forward depth is: ; wherein, , respectively denote the forward depth of the nodes , ; is the set of predecessor nodes of the node , i.e. all nodes directly outputting a signal to the node . Maximum value based on forward depth The reverse depth of each LUT node is calculated by traversing backward, and the calculation formula is: ; wherein, , denote the reverse depth of the nodes , , is the successor node set of the node , i.e. all nodes that directly receive the output signal of the node ; denotes arbitrary; LUT nodes satisfying the following conditions are determined as critical path nodes: or .
4. The method of claim 3, wherein LUT5 and LUT6 pairs that can be merged into LUT6D in the LUT network are identified through Minor relationship detection, specifically as follows: extracting a set of 6 input signals of the LUT6 to be detected and a set of 5 input signals of the LUT5 ; Verify that the shared input quantity of two sets is not less than 5 and the input set constraint that meets the Minor relationship: ; Traverse , find unique difference input, record its index as ; Screening out With 5 shared inputs in LUT6, record their index set in LUT6 input port, denoted as ; According to and , the new-old port mapping relationship is constructed so that the first 5 input ports of LUT6D correspond to the shared inputs in , and the 6th input port corresponds to the differential input, i.e. the input of ; Extracting the original initialization vector of LUT6 ; Each new address of LUT6D is traversed, and its original address of LUT6 is reversely calculated according to the new-old port mapping relationship, and the value at the original address is copied to the corresponding new address to obtain the new initialization vector of LUT6D , and the rearrangement of the truth table is completed . Each address of LUT5 is traversed, and according to The mapping relationship of the middle port is calculated, and the LUT6D address corresponding to each LUT5 address is calculated. check whether the value at the corresponding LUT6D address is identical to the value at the corresponding address of the LUT5 original initialization vector; If the values of all addresses match, the equivalence verification is passed; Otherwise, it is determined that the merging fails, and the process is terminated; Based on the old and new port mapping relationship to create a new LUT6D unit, set the input port to connect the corresponding shared input and difference input, and The INIT parameter of the LUT6D is configured, the Z5 port of the LUT6D is connected to the output end of the original LUT5, and the Z port is connected to the output end of the original LUT6. The LUT5 and LUT6 to be merged are removed from the original network; The signal driving mapping relationship of the LUT6D is recorded as: Z5 output corresponds to 5 inputs of the original LUT5, and Z output corresponds to 6 inputs of the original LUT6, and the node connection relationship and dependency relationship of the LUT network are updated.
5. The method of claim 4, wherein , based on the LUT connection relationship diagram, the LUT on the non-critical path is decomposed into smaller cascade LUT units in the LUT priority order, specifically: Identify the LUT on the non-critical path in the LUT connection relationship diagram, denoted as the LUT to be decomposed, and decompose it in two stages of LUT6 decomposition and small LUT decomposition; If there exists a target LUT6 and a LUT6 in the LUT to be decomposed satisfying that the input set has 5 shared inputs and the remaining one is a differential input, the LUT6 in the LUT to be decomposed is included in the decomposition candidate set, and the index of the differential input is recorded as ; If there are at least two target small LUTs in the LUT connection relationship diagram, and there is input sharing between the LUTs in the LUT to be decomposed, then the LUTs in the LUT to be decomposed are included in the decomposition candidate set; When performing the LUT6 decomposition stage: set the 64-bit original initialization vector of the to-be-decomposed LUT6 in the decomposition candidate set to 0, perform Shannon decomposition, split into a concatenated structure of a new LUT5 and a new LUT2, and extract the low 32 bits as the initialization vector of the new LUT5 set to 0, perform Shannon decomposition, split into a concatenated structure of a new LUT5 and a new LUT2, and extract the low 32 bits as the initialization vector of the new LUT5 Define two input mapping relationships of new LUT2 as follows: the first input is connected to the difference input, and the second input is connected to the output of new LUT5; Iterate through all input combinations of the LUT6 to be decomposed in the decomposition candidate set, and store the output value of each new LUT2 address in the output verification set; wherein the output value of the new LUT2 address is determined by the corresponding two inputs; If the output verification set contains multiple different output values, it is determined that the LUT6 to be decomposed cannot be decomposed, and the current decomposition process is terminated; At the same time, compare the output of the cascade structure of new LUT5 and new LUT2 with the output of the LUT6 to be decomposed one by one: if the outputs of all input combinations of the LUT6 to be decomposed in the decomposition candidate set are consistent, the equivalence verification is passed; otherwise, the decomposition fails, and the current process is terminated; If the equivalence verification is passed, create new LUT5 units and new LUT2 units respectively, connect the first input of the created new LUT2 unit to the difference input, and connect the second input to the output of the new LUT5 unit, and directly connect the output of the new LUT5 unit to the output signal of the original LUT6 to be decomposed, and remove the original LUT6 to be decomposed from the network; Merge new LUT5 unit and corresponding target LUT6 into new LUT6D unit based on Minor relationship detection rule, if merge fails, delete new LUT5 unit and new LUT2 unit generated in this decomposition, restore the network connection of the original LUT6 to be decomposed, and complete the LUT6 decomposition; When performing the small LUT decomposition stage: in turn, the LUT5 to be decomposed, the LUT4 to be decomposed, and the LUT3 to be decomposed in the decomposition candidate set are decomposed in turn, and the Shannon decomposition into new LUT cascade structure, input mapping allocation of new LUT, cascade structure output verification, equivalence verification, and new LUT unit and target LUT merging operation are performed in turn as in the LUT6 decomposition stage; Decompose the LUT5 to be decomposed into a cascade structure of two new LUT3, decompose the LUT4 to be decomposed into a cascade structure of new LUT2 and new LUT3, and decompose the LUT3 to be decomposed into a cascade structure of two new LUT2.
6. The method of claim 5, wherein After each decomposition, dynamically update the network topology structure and timing information of the LUT connection relationship diagram, specifically: Add the new LUT node generated by decomposition to the LUT connection relationship diagram, and establish new input-output directed edges; Recalculate the forward depth and reverse depth of the new LUT node, and update the labels of the critical path nodes for the next non-critical path decomposition.
7. An apparatus for merging and splitting of FPGA lookup tables, for implementing a method for merging and splitting of FPGA lookup tables according to any one of claims 1-6, characterized in that, It includes: A LUT network acquisition module is configured to acquire a mapped LUT network of the FPGA. A LUT merging and identifying module is configured to identify candidate pairs of the LUT network, select a LUT candidate pair with no conflict and optimal weight for merging, and construct a LUT connection relationship graph after the merging to identify a critical path. A LUT decomposition module is configured to decompose, based on the LUT connection relationship graph, a LUT on a non-critical path into smaller cascaded LUT units in order of LUT priority. A topology updating module is configured to dynamically update a network topology and timing information of the LUT connection relationship graph after each decomposition to complete optimization of the FPGA netlist.
8. A merging and splitting device for FPGA lookup tables, characterized in that The computer program stored in the memory can be executed by the processor to implement the FPGA lookup table merging and decomposing method of any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer readable instructions, and the computer readable instructions are executed by a processor of a device where the computer readable storage medium is located to implement the FPGA lookup table merging and decomposing method of any one of claims 1-6.
Citation Information
Patent Citations
Delay fault testing method and system oriented to the application of FPGA
CN101581762A
Netlist segmentation method of multi-bare-chip FPGA (Field Programmable Gate Array) based on time sequence
CN113128152A