Logic optimization method, device, computer equipment and storage medium based on replacement with reverse graph AIG

By determining the target AND gate node and its maximum fan-out cone in the reverse graph AIG, generating an optimization window according to the preset constraints, and replacing the original nodes, the problem in the existing technology that the optimization effect is affected by the quality of the AIG library is solved. , achieving more efficient and accurate logic optimization.

CN118297144BActive Publication Date: 2024-10-11SUZHOU YIGE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410720228.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-05
Publication Date
2024-10-11
Estimated Expiration
2044-06-05

AI Technical Summary

Technical Problem

The existing logic optimization method based on reverse graph AIG relies on the preset AIG library quality, resulting in poor optimization results. When the number of input signals is large, the number of truth tables is too large, which limits the scope and efficiency of the optimization.

Method used

By determining the target AND gate node and its maximum fan-out cone according to the topological order of the reverse graph AIG, determining the optimization window according to the preset constraints, and generating new AND gate nodes to replace the original nodes to perform logic optimization and avoid external AIG Effects of library quality and redundant reduction optimizations.

Benefits of technology

It improves the accuracy and efficiency of logic optimization, reduces optimization complexity, ensures the locality and functional correctness of the optimization process, and is suitable for scenarios with a large number of input signals.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118297144B_ABST
    Figure CN118297144B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of logic optimization technology, and discloses a logic optimization method, device, computer equipment and storage medium based on the replacement of the AND inverse graph AIG. According to the topological order of the AND inverse graph AIG, a target AND gate node is determined, and the maximum fan-out cone corresponding to the target AND gate node is determined; the target AND gate node is used as the root node, and the optimization window of the root node is determined according to the maximum fan-out cone and preset constraints; the preset constraints are used to limit the complexity of the optimization window; according to the optimization window, a preset number of new AND gate nodes are generated to replace the root node and the maximum fan-out cone corresponding to the root node, and the AND inverse graph AIG is logically optimized. The technical solution provided by one or more embodiments disclosed in the present invention can make the logic optimization effect no longer affected by the quality of the external AIG library, and increase the accuracy of the logic optimization process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of logic optimization, and in particular to a logic optimization method, device, computer equipment and storage medium based on replacement with an inverse graph AIG. Background Art

[0002] And Inverter Graph (AIG) is a representation of a Boolean function, commonly used in the field of logic optimization technology. Classical logic optimization algorithms based on AIG are usually based on a preset AIG library, and the subgraphs in the AIG library are used to perform equivalent replacements for local parts in the target AIG. However, this type of method has the problem that the optimization effect is affected by the quality of the AIG library, which may lead to poor AIG logic optimization effects. A better solution is needed. Summary of the invention

[0003] In view of this, the present invention provides a logic optimization method, apparatus, computer device and storage medium based on replacement with an inverse graph AIG to solve the problem of poor optimization effect in the logic optimization process of the inverse graph AIG.

[0004] On one hand, the present invention provides a logic optimization method based on replacement of an AND inverse graph AIG, the method comprising determining a target AND gate node according to the topological order of the AND inverse graph AIG, determining a maximum fan-out cone corresponding to the target AND gate node; taking the target AND gate node as a root node, and determining an optimization window of the root node according to the maximum fan-out cone and preset constraints; the preset constraints are used to limit the complexity of the optimization window; generating a preset number of new AND gate nodes according to the optimization window to replace the root node and the maximum fan-out cone corresponding to the root node, and performing logic optimization on the AND inverse graph AIG.

[0005] On the other hand, the present invention also provides a logic optimization device based on replacement of the AND inverse graph AIG, the device comprising: a first determination module, used to determine the target AND gate node according to the topological order of the AND inverse graph AIG, and determine the maximum fan-out cone corresponding to the target AND gate node; a second determination module, used to take the target AND gate node as the root node, and determine the optimization window of the root node according to the maximum fan-out cone and preset constraints; the preset constraints are used to limit the complexity of the optimization window; an optimization module, used to generate a preset number of new AND gate nodes according to the optimization window to replace the root node and the maximum fan-out cone corresponding to the root node, and perform logic optimization on the AND inverse graph AIG.

[0006] On the other hand, the present invention also provides a computer device, which includes: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor implements the above-mentioned logic optimization method based on replacement with the inverse graph AIG by executing the computer instructions.

[0007] Another aspect of the present invention provides a computer-readable storage medium having computer instructions stored thereon, wherein the computer instructions are used to enable a computer to implement the above-mentioned logic optimization method based on replacement with the inverse graph AIG.

[0008] In this process, the optimization window is determined according to the maximum fan-out cone determined by the target AND gate node in the reverse graph AIG and the preset constraints, and a preset number of new AND gate nodes are generated according to the optimization window to replace the target AND gate node in the reverse graph AIG. This can make the accuracy of the logic optimization process unaffected by the quality of the preset external AIG library, thereby improving the accuracy of the logic optimization of the reverse graph AIG. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0010] Figure 1 It is a flow chart of a logic optimization method based on replacement with an inverse graph AIG provided by an embodiment of the present invention;

[0011] Figure 2 It is a schematic diagram of an AIG of a logic optimization method based on replacement with an inverse graph AIG provided by an embodiment of the present invention;

[0012] Figure 3 It is a schematic diagram of an AIG of another logic optimization method based on replacement with an inverse graph AIG provided by an embodiment of the present invention;

[0013] Figure 4 It is a schematic diagram of an AIG of another logic optimization method based on replacement with an inverse graph AIG provided by an embodiment of the present invention;

[0014] Figure 5 It is a flow chart of another logic optimization method based on replacement with the inverse graph AIG provided by an embodiment of the present invention;

[0015] Figure 6It is a flow chart of an optimization window generation method based on a logic optimization method replaced with an inverse graph AIG provided by an embodiment of the present invention;

[0016] Figure 7 It is a structural schematic diagram of a logic optimization device based on replacement with an inverse graph AIG provided by an embodiment of the present invention;

[0017] Figure 8 It is a structural schematic diagram of another logic optimization device based on replacement with an inverse graph AIG provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0018] Classical AIG-based logic optimization algorithms are often based on a pre-generated AIG library, and attempt to use the AIG subgraphs in the library to perform equivalent replacements on local parts of the target AIG. This type of method has the following problems:

[0019] First, the optimization process needs to rely on the AIG library generated in advance, so the optimization effect is affected by the quality of the AIG library;

[0020] Second, the optimization process is indexed by the truth table, and the relationship between the number of truth tables and the input signal is m=2^(2 n ), where m is the number of truth tables and n is the number of input signals. Obviously, when n is greater than or equal to 5, m will exceed 400 million. Therefore, this type of method is often limited to the AIG subgraphs with the number of input signals less than or equal to 4.

[0021] In order to solve at least one of the above problems, various embodiments of the present invention provide a logic optimization method based on replacement of an AND inverse graph AIG, including: determining a target AND gate node according to the topological order of the AND inverse graph AIG, and determining a maximum fan-out cone corresponding to the target AND gate node; taking the target AND gate node as a root node, and determining an optimization window of the root node according to the maximum fan-out cone and preset constraints; the preset constraints are used to limit the complexity of the optimization window; generating a preset number of new AND gate nodes according to the optimization window to replace the root node and the maximum fan-out cone corresponding to the root node, and performing logic optimization on the AND inverse graph AIG.

[0022] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0023] According to an embodiment of the present invention, a logic optimization method based on replacement with an inverse graph AIG is provided. Figure 1 is a flow chart of a logic optimization method based on replacement with an inverse graph AIG provided by an embodiment of the present invention, such as Figure 1 As shown, the process includes the following steps:

[0024] Step S101, determining a target AND gate node according to the topological order of the inverse graph AIG, and determining a maximum fan-out-free cone corresponding to the target AND gate node;

[0025] Step S102, taking the target AND gate node as the root node, and determining the optimization window of the root node according to the maximum fan-out cone and preset constraints; the preset constraints are used to limit the complexity of the optimization window;

[0026] Step S103, generating a preset number of new AND gate nodes according to the optimization window to replace the root node and the maximum non-fan-out cone corresponding to the root node, and performing logic optimization on the AND inverse graph AIG.

[0027] In a possible implementation, the AND-inverter graph AIG may be a graph structure representing a Boolean function, and the AIG may include an AND gate node and an inverter; in the AIG, a node may represent an AND gate node, an input signal and an output signal, and an edge may represent a connection between nodes.

[0028] Here, the AND gate node has two inputs and one output, and its function may be to perform a logical AND operation on the Boolean values ​​of the two inputs and output the result; for example, the inputs of the AND gate node are 1110 and 0101, and the output result after the logical AND operation is 0100.

[0029] For example, Figure 2 is a schematic diagram of an AIG of a logic optimization method based on replacement with an inverse graph AIG provided by an embodiment of the present invention, Figure 2 For example,

[0030] Nodes a, b, c, and d are the input signals of AIG, node o is the output signal, nodes 1, 2, and 3 are AND gates, and the lines between signals and nodes or between nodes are edges. The solid black dots on the edges can indicate the inversion of the signals on the edges (non-logical). For example, the signal between node 1 and node 3 is an inverted edge. Assuming that the output signal of node 1 is 0, after passing through the inverted edge, the input signal reaching node 3 becomes 1.

[0031] Furthermore, according to the topological order of the AND inverse graph AIG, the method of determining the target AND gate node may refer to traversing in the order of the connection relationship between the AND gate nodes in the AIG; in the AIG, according to the connection relationship between the nodes, traverse layer by layer from the input node to the output node to ensure that the input node of each node is traversed before the node; wherein, the target AND gate node may refer to any AND gate node in the AIG.

[0032] In a possible implementation, a Maximum Fanout Free Cone (MFFC) may consist of a root node and all transitive fan-in nodes without external fan-out. MFFC may represent the range of a node and all its propagated signals without being affected by other nodes.

[0033] Specifically, fan-in can represent the number of inputs accepted by a node, and fan-out can represent the number of outputs connected to a node; external fan-out can refer to the transitive fan-in of a fan-out node that is not a root node; a transitive fan-in node can refer to a node that has a path with the root node.

[0034] Here, if the root node of the MFFC can be replaced and removed from the AIG, then all nodes included in the entire MFFC can be removed from the AIG.

[0035] In one possible implementation, the optimization window may refer to a specific part or range that the AIG focuses on during the logic optimization process, which may include some nodes to be optimized and other nodes directly or indirectly connected to the nodes; by determining the optimization window, the optimization range may be limited so that the AIG can perform more effective logic optimization within a specific range.

[0036] Through the above method, the MFFC corresponding to the target AND gate node in the AIG is determined, and the target AND gate node of the AIG is replaced according to the optimization window determined by the MFFC and the preset constraints; on the one hand, the accuracy of the logic optimization process can be made unaffected by the quality of the preset external AIG library, thereby improving the accuracy of the AIG logic optimization with the reverse graph; on the other hand, by determining the MFFC and the optimization window, the optimization of the entire AIG can be avoided, thereby reducing the complexity and overhead of the optimization, ensuring that the optimization operation will not affect the nodes outside the MFFC range, thereby maintaining the functional correctness of the AIG.

[0037] In one embodiment, according to the topological order of the inverse graph AIG, determining the target AND gate node, and determining the maximum fan-out-free cone corresponding to the target AND gate node include:

[0038] Determine all transitive fan-in nodes without external fan-out corresponding to the target AND gate node in the inverse graph AIG;

[0039] Determine the maximum no fan-out cone based on the target AND gate nodes and the transitive fan-in nodes.

[0040] Specifically, all transitive fan-in nodes without external fan-out corresponding to the target AND gate node in the AIG are determined, and a node set including the target AND gate node and all transitive fan-in nodes without external fan-out is used as the maximum no-fan-out cone MFFC.

[0041] For example, Figure 3 is another AIG schematic diagram of a logic optimization method based on replacement with an inverse graph AIG provided by an embodiment of the present invention, Figure 3 For example,

[0042] by Figure 3 Taking node 3 as an example, all transitive fan-in nodes of node 3 can include node 6, node 9 and node 0, but node 9 has an external fan-out to node 5, so node 9 is not included in the MFFC with node 3 as the root node, that is, the MFFC with node 3 as the root node can include {node 3, node 6, node 0}; the MFFC with node 2 as the root node can include {node 2, node 4, node 5, node 7, node 8}.

[0043] Here, if the root node of MFFC can be replaced and removed from AIG, then all nodes included in the entire MFFC can be removed from AIG; for example, Figure 3 For example, if Figure 3 Node 3 in can be removed without affecting the function of the entire AIG. After removing node 3, the output of node 6 will be left floating, which will not affect the function of AIG, that is, it can also be removed. Similarly, node 0 can also be removed without affecting the function of AIG. Therefore, all MFFCs with node 3 as the root node can be removed from AIG.

[0044] Through the above method, by determining MFFC and optimizing the nodes related to the current target gate node in a targeted manner, the optimization goal can be better achieved; through MFFC, the locality in the optimization operation can be ensured, and repeated optimization of irrelevant parts in the AIG can be avoided, thereby reducing redundant calculations and unnecessary operations in the optimization process, and improving the efficiency and effect of the optimization.

[0045] In one embodiment, the target AND gate node is used as the root node, and the optimization window of the root node is determined according to the maximum fan-out cone and preset constraints, including:

[0046] Determine the first node input into the optimization window according to the root node and the preset constraint condition; wherein the preset constraint condition includes: the number of the first nodes and the number of the original second nodes in the optimization window;

[0047] The optimization window is determined based on the number of first nodes, second nodes, and the maximum fan-out-free cone.

[0048] Specifically, the first node is determined according to the root node, the number of first nodes, and the number of second nodes; and the optimization window is determined according to the first node, the number of second nodes, and MFFC.

[0049] Here, the first node may refer to the optimization window input node, and the second node may refer to the optimization window node; the scale of the optimization window is adaptively adjusted by adjusting the optimization window input node and the number of optimization window nodes in the preset constraints; if the purpose of AIG logic optimization is to improve the optimization effect, the scope of the optimization window can be expanded; if the purpose of AIG logic optimization is to reduce the optimization time, the scope of the optimization window can be narrowed.

[0050] Furthermore, the number of optimization window input nodes may refer to the number of input nodes of the optimization window, which may be input signals of each node in the optimization window, and may determine the accuracy and efficiency of the optimization window during the optimization process; the number of optimization window nodes may refer to the total number of each node in the optimization window, and may determine the complexity of optimizing the optimization window.

[0051] Through the above method, according to the different focuses when optimizing AIG, the corresponding preset constraints are determined, and the corresponding optimization window is generated, so that logical optimization effects with different precision and efficiency can be achieved during the optimization process.

[0052] In one embodiment, determining the first node input to the optimization window according to the root node and the preset constraint condition includes:

[0053] Set the node queue and node set; the node queue initially includes only the root node, and the node set is empty in the initial state;

[0054] Take out a node from the node queue and store it in the node set, and perform a preset judgment on all input nodes of the node; wherein the node includes at least one of an AND gate node, an input node and an output node;

[0055] If the input node is not in the node set and the input node is an AND gate node, store the input node in the node queue;

[0056] If the number of nodes in the node queue is greater than the first number of nodes in the preset condition, the state of the node queue is returned to before the last node is taken out;

[0057] The first node input to the optimization window is determined based on the node queue.

[0058] Specifically, the node queue and the node set can be a preset data structure; the node queue can be used to store nodes to be processed, and the data structure of the node queue can refer to a queue; the node set can be used to store nodes that have been processed, and to check whether the node has been processed, and the data structure of the node set can include but is not limited to: a set, a hash table; among them, the set can be used to store non-duplicate nodes and realize fast search and insertion operations, and the hash table can realize fast node search through a hash function.

[0059] In a possible implementation, taking a node from the node queue and storing it in the node set, and performing a preset judgment on all input nodes of the node may include:

[0060] Try to add all input nodes corresponding to the node to the node queue;

[0061] All input nodes are traversed. If the input node is not in the node set and is an AND gate node, the input node is placed in the node queue.

[0062] Specifically, taking a node from the node queue and putting the node into the node set can indicate that the node has been processed; checking all input nodes of the node, if the input node is not in the node set and the input node is an AND gate node, it can be indicated that the input node is an unprocessed AND gate node, and the input node can be put into the node queue to indicate that the processing has been completed.

[0063] In a possible implementation, if taking out a certain node causes the number of nodes in the node queue to exceed the first node number limit, processing of the node is abandoned and the state of the node queue is rolled back to the state before taking out the node.

[0064] Here, this method can be used to ensure that the size of the optimization window is constrained and does not exceed the expected range set by the preset constraints, so that the scale and complexity of the AIG can be effectively controlled during the optimization process.

[0065] Through the above method, by means of node queues and node sets, it can be ensured that only input nodes of unprocessed AND gate nodes are added to the node queue, which can avoid repeated processing of nodes and unnecessary traversal, and improve the efficiency of the optimization process.

[0066] In one embodiment, determining the optimization window according to the number of first nodes, second nodes, and the maximum fan-out-free cone includes:

[0067] Determine the traversal direction from the optimization window input node to the root node, and traverse the AND gate nodes in the inverse graph AIG layer by layer;

[0068] If the AND gate node does not belong to the maximum fan-out cone of the root node and does not belong to the optimized window node set, the AND gate node is stored in the optimized window node set;

[0069] If the number of nodes in the node layer containing the root node or the optimized window node set traversed is greater than the second node number in the preset constraint condition, the traversal of the AND gate node is terminated;

[0070] The optimization window of the root node is determined according to the optimization window node set.

[0071] Specifically, starting from the determined optimization window input node, traverse the AND gate nodes layer by layer toward the root node; if the AND gate node belongs to the MFFC of the root node and the AND gate node does not exist in the optimization window node set, store the AND gate node in the optimization window node set until the node layer containing the root node is traversed, add the root node to the optimization window node set and end the traversal; or, if the number of nodes in the optimization window node set is greater than the second number of nodes in the preset constraint condition during the traversal process, end the traversal even if the layer containing the root node is not traversed; determine the optimization window corresponding to the root node according to the final optimization window node set.

[0072] Among them, the inputs of the AND gate nodes are all nodes in the previous layer.

[0073] Here, by determining whether the AND gate node does not belong to the maximum fan-out cone of the root node and does not belong to the optimization window node set, it can be ensured that all nodes related to the root node but not in the MFFC are included in the optimization window.

[0074] Furthermore, starting from the input node of the optimization window, traverse layer by layer toward the root node, add the nodes related to the root node but not in the MFFC to the optimization window node set, and finally obtain an optimization window that meets the constraints; the optimization window contains both nodes related to the root node and the number of nodes in the window is controlled by the preset constraints.

[0075] For example, Figure 4 is a schematic diagram of an AIG of another logic optimization method based on replacement with the reverse graph AIG provided by an embodiment of the present invention, Figure 4 For example,

[0076] Assume the root node is node 2, set the number of first nodes to 3, Figure 4 It can be determined that the MFFC corresponding to the root node is {node 2, node 5}, and the input nodes of the optimization window are {node 7, node 8, node 9};

[0077] Traversing layer by layer from the direction of the input node to the direction of the root node, first traversing to node 10, node 4 and node 5; among them, although node 3 is the output node of node 9, the input nodes of node 3 do not all come from the nodes of the previous layer {node 7, node 8, node 9}, but also from node 6, so node 3 is not included in the traversal range; among the traversed nodes 10, node 4 and node 5, node 5 belongs to the MFFC of the root node, so node 10 and node 4 are added to the optimization window node set; continue to traverse the next layer of nodes through node 10 and node 4, that is, traverse to node 2 as the root node, and end the traversal; the final node set of the optimization window can be {node 4, node 10}.

[0078] Through the above method, by adding all nodes related to the root node but not in MFFC to the node set of the optimization window, it can be ensured that the optimization window covers all nodes directly or indirectly related to the root node, thereby ensuring the comprehensiveness and effectiveness of the optimization process; on the other hand, by manually adjusting the constraints of the optimization window, the optimization range can be controlled, thereby balancing the running time and optimization effect.

[0079] In one embodiment, a preset number of new AND gate nodes are generated according to the optimization window to replace the root node and the maximum fan-out cone corresponding to the root node, and the AND inverse graph AIG is logically optimized, including:

[0080] Determine the truth table of the nodes and the root node in the optimization window node set by using a preset simulation method;

[0081] Determine that the upper limit of the preset data is 3, and generate 0, 1, 2, or 3 new AND gate nodes according to the optimization window from small to large;

[0082] According to the number of new AND gate nodes, the corresponding preset judgment method is determined. If the truth table of the new AND gate node is the same as that of the root node, the root node and the maximum fan-out cone of the root node are replaced by the new AND gate node.

[0083] Specifically, a preset simulation method is used to calculate the truth table of the nodes and the root node in the optimization window node set; the upper limit of the preset data n is determined to be 3 (i.e., n≤3), and a series of n-node optimization attempts are made from small to large, that is, by adding n AND gate nodes to ensure that the function of the entire AIG remains unchanged after eliminating the root node and its MFFC.

[0084] Here, when n=0, it can mean traversing all AND gate nodes in the optimization window and trying to find a node whose truth table is exactly the same as the root node; if such a node exists, the root node and its MFFC can be replaced by the node;

[0085] When n=1, it can represent the combination of all nodes (including AND gate nodes and input nodes) in the traversal optimization window, trying to find a combination a, b, and newly generate an AND gate node c. Nodes a and b are the input nodes of node c. If the truth table of node c is the same as the root node truth table, node c can replace the root node and its MFFC.

[0086] When n=2, we can first traverse all the node combinations in the optimization window and try to find a combination a, b, and use it as input to generate an AND gate node c. Then, we use node c as an input and try to find another node d (which can be the same as a, b) in the optimization window as the second input to generate an AND gate node e. If the truth table of node e is the same as the root node, we can replace the root node and its MFFC with node e.

[0087] When n=3, we can first traverse all node combinations in the optimization window, try to find a combination a, b, use it as input to generate AND gate node c, traverse node c and all node combinations in the optimization window to try to find combination d, e (which can be the same as a, b, c), use it as input nodes to generate AND gate node f, use node c and node f as input nodes to generate an AND gate node g, if the truth table of node g is the same as the truth table of the root node, then node g can replace the root node and its MFFC.

[0088] Among them, non-logic can be added to each edge of AIG; for example, taking n=1 as an example, assuming that the truth table of the root node is 1000, the truth tables of the two input nodes a and b are 1001 and 0110 respectively; if an AND gate node c is directly generated, the truth table is 0000, and it cannot replace the root node equivalently; at this time, the output of b can be inverted, so that the logic of node c becomes c=ab-, and the truth table of c can be changed to 1000 to meet the replacement condition of the root node.

[0089] Furthermore, before each optimization attempt, it is necessary to determine whether the number of nodes in the MFFC to be optimized is greater than n; for example, if the number of nodes in the MFFC is 2, 0-node optimization and 1-node optimization can be attempted.

[0090] In a possible implementation, determining the upper limit of the preset data n to be 3 may be a statistical conclusion, which is a result of optimal cost performance determined through experiments.

[0091] Specifically, if the number of nodes in the optimization window is m, the time complexity of n-node optimization is O(m n+1 ); if n is greater than 3, the time required will greatly increase, while the optimization effect will not be obvious when n is less than or equal to 3.

[0092] In a possible implementation, if all optimization attempts from 0 to 3 for n-node optimization are not feasible, it can be indicated that the node and MFFC cannot be optimized, and then the next node is optimized in topological order until all AND gate nodes in the AIG are traversed, and finally the optimized AIG is determined.

[0093] Through the above method, through 0-3 node optimization attempts, it is possible to replace the AND gate nodes and their MFFCs in the original AIG with only 0-3 newly added AND gate nodes, making the optimization effect more significant and greatly reducing the time complexity of the optimization process.

[0094] In one embodiment, determining the truth table of the nodes and the root node in the optimization window node set by a preset simulation method includes:

[0095] Determine an input sequence corresponding to the input node according to the number of the first nodes;

[0096] According to the input sequence and the Boolean function, determine the truth tables corresponding to the nodes in the optimization window node set and the root node respectively;

[0097] A long integer vector of a preset length is determined to store the truth table and the input sequence.

[0098] In a possible implementation, determining the input sequence corresponding to the input node according to the first node number may include: for an n-input Boolean function, determining that the mth input sequence is 2 m-1 1 plus 2 m-1 0, repeated 2 n -m Second-rate.

[0099] Exemplarily, for a two-input Boolean function, all inputs may include 00, 01, 10 and 11, and the first input sequence of the two-input Boolean function can be determined to be 1010, and the second input sequence can be determined to be 1100; for a three-input Boolean function, all inputs may include 000, 001, 010, 011, 100, 101, 110 and 111, and the first input sequence of the three-input Boolean function can be determined to be 10101010, the second input sequence can be 11001100, and the third input sequence can be determined to be 11110000.

[0100] In a possible implementation, determining the truth tables corresponding to the nodes in the optimization window node set and the root node, respectively, according to the input sequence and the Boolean function, may include:

[0101] An input sequence with the same number of bits as the truth table is generated according to the rule of input combination, so that the truth table of the node can be obtained through one simulation.

[0102] Specifically, after determining the input sequence, we can directly substitute the input sequence into the Boolean function to obtain the truth table; for example, a two-input AND logic Boolean function, whose input sequences are 1010 and 1100 respectively, and whose Boolean function is f=ab, we can directly substitute the input sequence into the bitwise AND operation to obtain the truth table 1000.

[0103] Among them, the truth table itself can also be used as an input sequence. If there is another function g=cd, where the truth table of c is 1001 and the truth table of d is 0001, then we can directly substitute the truth tables of c and d into the calculation to obtain the truth table of g as 0001; therefore, the input sequence of each input signal can be generated based on the input of an optimization window, and then the truth table of the AND gate node can be calculated through the input sequence, and then the truth tables of subsequent AND gate nodes can be calculated layer by layer based on the truth table of the AND gate node, so as to obtain the truth tables of all nodes and the root node in the optimization window.

[0104] In a possible implementation, determining a long integer vector of a preset length to store the truth table and the input sequence may include:

[0105] A long integer vector is used to store the truth table and the input sequence. The length of the vector is 2. n-6 (n≥6), when n is less than 6, the vector length is 1, that is, there is only one long integer variable.

[0106] Here, when the length of the generated input sequence exceeds 64, each 64 bits from low to high is stored in a long integer variable.

[0107] For example, a 96-bit input sequence (expressed in hexadecimal): 88888888ffffffffffffffff can be represented by two long integer variables, namely: 0000000088888888, ffffffffffffffffff; the 64 bits from low to high are stored in a long integer, so the low 64 bits ffffffffffffffff are first stored in a long integer, and then there are only 32 bits left, 88888888, which is also stored in a long integer, but the long integer only uses its low 32 bits, and the remaining high 32 bits are padded with 0, which can be 0000000088888888.

[0108] Through the above method, fast truth table calculation is achieved by generating an input sequence when performing simulation calculation of the truth table. Compared with the general bit-by-bit simulation method, the running time can be reduced by orders of magnitude; on the other hand, through the long integer vector and the high-order 0 filling method, the application of this efficient simulation method to the case where the number of inputs is greater than 6 can be realized, and a larger number of inputs can be supported.

[0109] Figure 5 is a flow chart of another logic optimization method based on replacement with the inverse graph AIG provided by an embodiment of the present invention, Figure 5 For example, the process includes the following steps:

[0110] Step S501, traverse the AND gate nodes in topological order;

[0111] Here, the AIG to be optimized is determined, and the target AND gate node is determined according to the topological order with the reverse graph AIG;

[0112] Step S502, obtaining the node MFFC;

[0113] Here, the maximum fan-out cone MFFC is determined based on the target AND gate node and the corresponding transitive fan-in node;

[0114] Step S503, generating an optimization window;

[0115] Here, the optimization window input node is determined according to the root node, the number of first nodes, and the number of second nodes; the optimization window is determined according to the number of first nodes, the number of second nodes, and MFFC;

[0116] Step S504, optimization;

[0117] Here, through the 0-3 node optimization attempt, the target AND gate node and its MFFC in the original AIG are replaced by 0-3 newly added AND gate nodes to optimize the nodes in the AIG;

[0118] Step S505, determine whether the traversal of the target node is completed; if so, determine the optimized AIG and end the process; if not, return to step S501 and continue to determine the target AND gate node.

[0119] Figure 6 The present invention provides a flow chart of an optimization window generation method based on a logic optimization method replaced with an inverse graph AIG. Figure 6 For example, the process includes the following steps:

[0120] Step S601, determining the optimization window input node;

[0121] Here, a node queue representing the node to be processed and a node set representing the processed nodes are set; a node is taken out from the node queue and stored in the node set, and a preset judgment is performed on all input nodes of the node. If the input node is not in the node set and the input node is an AND gate node, the input node is stored in the node queue. If the number of nodes in the node queue is greater than the first number of nodes in the preset condition, the state of the node queue is returned to the state before the previous node is taken out, and the optimization window input node is determined according to the node queue.

[0122] Step S602, generating an optimization window;

[0123] Here, starting from the determined optimization window input node, the AND gate nodes are traversed layer by layer toward the root node; if the AND gate node belongs to the MFFC of the root node and the AND gate node does not exist in the optimization window node set, the AND gate node is stored in the optimization window node set until the node layer containing the root node is traversed, the root node is added to the optimization window node set and the traversal is terminated; or, during the traversal process, if the number of nodes in the optimization window node set is greater than the second number of nodes in the preset constraint condition, the traversal is terminated even if the layer containing the root node is not traversed; the optimization window corresponding to the root node is determined according to the final optimization window node set.

[0124] Figure 7 is a schematic diagram of the structure of a logic optimization device based on replacement with an inverse graph AIG provided by an embodiment of the present invention, such as Figure 7 As shown, the device can be applied to intelligent electronic devices such as servers and computers; the device includes: a first determination module 701, a second determination module 702 and an optimization module 703;

[0125] The first determination module 701 is used to determine the target AND gate node according to the topological order of the inverse graph AIG, and determine the maximum fan-out-free cone corresponding to the target AND gate node;

[0126] A second determination module 702 is used to take the target AND gate node as a root node and determine an optimization window of the root node according to the maximum fan-out cone and a preset constraint condition; the preset constraint condition is used to limit the complexity of the optimization window;

[0127] An optimization module 703 is used to generate a preset number of new AND gate nodes according to the optimization window to replace the root node and the maximum non-fan-out cone corresponding to the root node, and perform logic optimization on the AND inverse graph AIG;

[0128] The first determination module 701 is used to determine all transitive fan-in nodes without external fan-out corresponding to the target AND gate node in the inverse graph AIG;

[0129] Determine the maximum no fan-out cone based on the target AND gate node and the transitive fan-in node;

[0130] The second determination module 702 is used to determine the first node input into the optimization window according to the root node and the preset constraint condition; wherein the preset constraint condition includes: the number of the first nodes and the number of the original second nodes in the optimization window;

[0131] Determine an optimization window according to the number of first nodes, second nodes and a maximum no-fan-out cone;

[0132] The second determination module 702 is used to set a node queue and a node set; wherein the node queue initially includes only the root node, and the node set is initially empty;

[0133] Take out a node from the node queue and store it in the node set, and perform a preset judgment on all input nodes of the node; wherein the node includes at least one of an AND gate node, an input node and an output node;

[0134] If the input node is not in the node set and the input node is an AND gate node, store the input node in the node queue;

[0135] If the number of nodes in the node queue is greater than the first number of nodes in the preset condition, the state of the node queue is returned to before the last node is taken out;

[0136] Determine the first node input to the optimization window according to the node queue;

[0137] The second determination module 702 is used to determine the traversal direction from the first node to the root node, and traverse the AND gate nodes in the AND inverse graph AIG layer by layer;

[0138] If the AND gate node does not belong to the maximum fan-out cone of the root node and does not belong to the optimized window node set, the AND gate node is stored in the optimized window node set;

[0139] If the number of nodes in the node layer containing the root node or the optimized window node set traversed is greater than the second node number in the preset constraint condition, the traversal of the AND gate node is terminated;

[0140] Determine the optimization window of the root node according to the optimization window node set;

[0141] The optimization module 703 is used to determine the truth table of the nodes and the root node in the optimization window node set by using a preset simulation method;

[0142] Determine that the upper limit of the preset data is 3, and generate 0, 1, 2, or 3 new AND gate nodes according to the optimization window from small to large;

[0143] According to the number of new AND gate nodes, the corresponding preset judgment method is determined. If the truth table of the new AND gate node is the same as that of the root node, the root node and the maximum fan-out cone of the root node are replaced by the new AND gate node;

[0144] An optimization module 703, configured to determine an input sequence corresponding to the input node according to the number of second nodes;

[0145] According to the input sequence and the Boolean function, determine the truth tables corresponding to the nodes in the optimization window node set and the root node respectively;

[0146] A long integer vector of a preset length is determined to store the truth table and the input sequence.

[0147] It should be noted that: the logic optimization device based on the AIG replacement with the reverse graph provided in the above embodiment only uses the division of the above program modules as an example to illustrate when implementing the corresponding logic optimization method based on the AIG replacement with the reverse graph. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device can be divided into different program modules to complete all or part of the above-described processing. In addition, the device provided in the above embodiment and the corresponding Figure 1 The embodiments of the method shown belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be repeated here.

[0148] To implement the method of the embodiment of the present invention, the embodiment of the present invention provides a logic optimization device based on replacement with the inverse graph AIG, such as Figure 8 As shown, the device includes: a processor 801 and a memory 802 for storing a computer program that can be run on the processor; wherein,

[0149] When the processor 801 is used to run the computer program, it executes: according to the topological order of the AND reverse graph AIG, determine the target AND gate node, determine the maximum fan-out cone corresponding to the target AND gate node; take the target AND gate node as the root node, and determine the optimization window of the root node according to the maximum fan-out cone and preset constraints; the preset constraints are used to limit the complexity of the optimization window; according to the optimization window, generate a preset number of new AND gate nodes to replace the root node and the maximum fan-out cone corresponding to the root node, and perform logic optimization on the AND reverse graph AIG. Specifically, the device can execute the following Figure 1 The method shown, and Figure 1 The logic optimization method embodiment based on replacement with the inverse graph AIG shown belongs to the same concept, and its specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0150] In practical application, such as Figure 8 As shown, the device may also include: at least one network interface 803. The various components in the logic optimization device based on the permutation with the inverse graph AIG are coupled together through a bus system 804. It can be understood that the bus system 804 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 804 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, in Figure 8 In the figure, various buses are marked as bus system 804. There may be at least one processor 801. The network interface 803 is used for wired or wireless communication between the logic optimization device based on the AIG replacement and other devices.

[0151] The memory 802 in the embodiment of the present invention is used to store various types of data to support the operation of the logic optimization device based on the replacement with the inverse graph AIG.

[0152] The method disclosed in the above embodiment of the present invention can be applied to the processor 801, or implemented by the processor 801. The processor 801 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor 801 or an instruction in the form of software.

[0153] The above-mentioned processor 801 can be a general-purpose processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 801 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor can be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present invention, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 802. The processor 801 reads the information in the memory 802 and completes the steps of the aforementioned method in combination with its hardware.

[0154] In an exemplary embodiment, the logic optimization estimation device based on replacement with the inverse graph AIG can be implemented by one or more application-specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD), field programmable gate array (FPGA), general-purpose processor, controller, microcontroller (MCU), microprocessor, or other electronic components to execute the aforementioned method.

[0155] The embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored; when the computer program is executed by a processor, the following is performed: according to the topological order of the AND inverse graph AIG, a target AND gate node is determined, and the maximum fan-out cone corresponding to the target AND gate node is determined; the target AND gate node is used as the root node, and the optimization window of the root node is determined according to the maximum fan-out cone and preset constraints; the preset constraints are used to limit the complexity of the optimization window; according to the optimization window, a preset number of new AND gate nodes are generated to replace the root node and the maximum fan-out cone corresponding to the root node, and the AND inverse graph AIG is logically optimized. Specifically, the computer program can also perform the following Figure 1 The method shown, and Figure 1 The method embodiments shown belong to the same concept, and their specific implementation processes are detailed in the method embodiments, which will not be repeated here.

[0156] In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0157] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0158] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0159] A person skilled in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), disks or optical disks, etc. Various media that can store program codes.

[0160] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.

[0161] It should be noted that: "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0162] In addition, the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.

[0163] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A logic optimization method based on replacement with an inverse graph AIG, characterized in that: The method comprises: According to the topological order of the AND inverse graph AIG, a target AND gate node is determined, and a maximum fan-out-free cone corresponding to the target AND gate node is determined; the AND inverse graph AIG includes but is not limited to: an AND gate node and an inverter; Taking the target AND gate node as a root node, determining an optimization window of the root node according to the maximum fan-out cone and a preset constraint condition; the preset constraint condition is used to limit the complexity of the optimization window; Generate a preset number of new AND gate nodes according to the optimization window to replace the root node and the maximum non-fan-out cone corresponding to the root node, and perform logic optimization on the AND inverse graph AIG; The step of determining the target AND gate node according to the topological order of the inverse graph AIG and determining the maximum fan-out-free cone corresponding to the target AND gate node includes: Determine all transitive fan-in nodes without external fan-out corresponding to the target AND gate node in the inverse graph AIG; The maximum no-fan-out cone is determined according to the target AND gate node and the transitive fan-in node.

2. The method according to claim 1, characterized in that The step of taking the target AND gate node as a root node and determining an optimization window of the root node according to the maximum fan-out-free cone and preset constraints includes: Determine the first node input into the optimization window according to the root node and the preset constraint condition; wherein the preset constraint condition includes: the number of the first nodes and the number of the original second nodes in the optimization window; An optimization window is determined according to the first nodes, the second nodes, and a maximum no-fan-out cone.

3. The method according to claim 2, characterized in that The step of determining the first node input to the optimization window according to the root node and the preset constraint condition comprises: Set a node queue and a node set; wherein the node queue initially includes only the root node, and the node set is initially empty; Taking out a node from the node queue and storing it in the node set, performing a preset judgment on all input nodes of the node; wherein the node includes at least one of an AND gate node, an input node and an output node; If the input node is not in the node set and the input node is an AND gate node, storing the input node in the node queue; If the number of the nodes in the node queue is greater than the first number of nodes in the preset condition, returning the state of the node queue to the state before the last node is taken out; A first node input to the optimization window is determined according to the node queue.

4. The method according to claim 3, characterized in that The step of determining the optimization window according to the number of the first nodes, the second nodes, and the maximum fan-out-free cone includes: Determine the traversal direction from the first node to the root node, and traverse the AND gate nodes in the inverse graph AIG layer by layer; If the AND gate node does not belong to the maximum fan-out cone of the root node and does not belong to the optimized window node set, storing the AND gate node in the optimized window node set; If the number of nodes in the node layer containing the root node or the optimized window node set traversed is greater than the second number of nodes in the preset constraint condition, the traversal of the AND gate node is terminated; The optimization window of the root node is determined according to the optimization window node set.

5. The method according to claim 4, characterized in that The step of generating a preset number of new AND gate nodes according to the optimization window to replace the root node and the maximum non-fan-out cone corresponding to the root node, and performing logic optimization on the AND inverse graph AIG includes: Determine the truth table of the nodes and the root node in the optimization window node set by using a preset simulation method; Determine that the upper limit of the preset data is 3, and generate 0, 1, 2, or 3 new AND gate nodes according to the optimization window from small to large; According to the number of the new AND gate nodes, a corresponding preset judgment method is determined. If the truth table of the new AND gate node is the same as that of the root node, the root node and the maximum fan-out cone of the root node are replaced by the new AND gate node.

6. The method according to claim 5, characterized in that The step of determining the truth table of the nodes and the root node in the optimization window node set by a preset simulation method includes: Determine the input sequence corresponding to the input node according to the number of the first nodes; According to the input sequence and the Boolean function, determine the truth tables corresponding to the nodes in the optimization window node set and the root node respectively; A long integer vector of a preset length is determined to store the truth table and the input sequence.

7. A logic optimization device based on replacement with an inverse graph AIG, characterized in that: The device comprises: The first determination module is used to determine the target AND gate node according to the topological order of the AND inverse graph AIG, and determine the maximum fan-out cone corresponding to the target AND gate node; the AND inverse graph AIG includes but is not limited to: AND gate nodes, inverters; A second determination module is used to take the target AND gate node as a root node and determine an optimization window of the root node according to the maximum fan-out cone and a preset constraint condition; the preset constraint condition is used to limit the complexity of the optimization window; An optimization module, used for generating a preset number of new AND gate nodes according to the optimization window to replace the root node and the maximum non-fan-out cone corresponding to the root node, and performing logic optimization on the AND inverse graph AIG; Wherein, the first determination module is specifically used to: determine all transitive fan-in nodes without external fan-out corresponding to the target AND gate node in the reverse graph AIG; The maximum no-fan-out cone is determined according to the target AND gate node and the transitive fan-in node.

8. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the logic optimization method based on replacement with the inverse graph AIG as described in any one of claims 1 to 6 by executing the computer instructions.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the logic optimization method based on replacement with the inverse graph AIG according to any one of claims 1 to 6.