Optimization method and device of multi-bit-width electronic forest, equipment and medium
By identifying and optimizing the target selector in the multi-bit wide electronic forest and adjusting the connection relationship of the input signal, the problems of high cost, complex structure and large computing resources in the prior art are solved, and the effects of structural simplification, cost reduction and computing resources improvement are achieved.
Patent Information
- Application Number
- CN202510001838.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-02
- Publication Date
- 2025-04-29
Smart Images

Figure CN119906453A_ABST
Abstract
Description
Background Art
[0002] Binary multiplexer: Binary Multiplexer, abbreviated as binary-mux. A multiplexer with binary-coded input at the selector end. One of the commonly used multiplexers is the 2-to-1 multiplexer, abbreviated as mux21, which is a multiplexer with only 1 selector end and 2 data ends.
[0003] Multiple 2-to-1 multiplexers can be combined and connected step by step to form a 2-to-1 multiplexer tree: 2to1 multiplexer tree, referred to as mux21 tree. Since the 2-to-1 multiplexer tree has the characteristics of both data path and control logic, combining multiple 2-to-1 multiplexer trees can construct a multi-bit wide multiplexer tree, also known as a multi-bit wide electronic forest.
[0004] However, the above multi-bit width electronic forest has the following technical problems: the larger the bit width, the more multi-bit width electronic forests are needed, and the more multiplexers are used. This not only increases the circuit cost and the connection structure, but also increases the computing resources and consumption resources, making it difficult to meet the existing application requirements. Summary of the invention
[0005] The present invention proposes an optimization method, device, equipment and medium for a multi-bit width electronic forest. The method can solve the technical problems of high cost, complex structure and large computing resources in the prior art.
[0006] A first aspect of an embodiment of the present invention provides a method for optimizing a multi-bit width electronic forest, the method comprising:
[0007] After obtaining a multi-bit-wide electronic forest to be processed, determining whether the multi-bit-wide electronic forest has a target selector, the target selector being a multiplexer in which one input signal is public data;
[0008] If the multi-bit-width electronic forest has a target selector, iteratively optimizing the multi-bit-width electronic forest according to the target selector to obtain a target electronic forest;
[0009] The iterative optimization is a process of adjusting the connection relationship of the input signal of the target selector in the multi-bit width electronic forest.
[0010] In combination with the first aspect, in one implementation, iteratively optimizing the multi-bit-width electronic forest according to the target selector to obtain a target electronic forest includes:
[0011] Connecting the non-public input signal of each of the target selectors in the multi-bit width electronic forest to the input end of the back-end selector, and clearing the target selectors to obtain an initial electronic forest, wherein the non-public input signal is an input signal of non-public data in the target selector, and the back-end selector is a multiplexer connected to the output end of the target selector;
[0012] Using the initial electronic forest and a preset selector to construct an electronic forest to be tested, and calculating resource benefit parameters of the electronic forest to be tested;
[0013] If the resource benefit parameter does not meet the preset parameter condition, the multi-bit-width electronic forest to be processed before the iterative optimization of the electronic forest to be tested is used as the target electronic forest.
[0014] In combination with the first aspect, in one implementation, the iterative optimization of the multi-bit-width electronic forest according to the target selector to obtain a target electronic forest further includes:
[0015] If the resource benefit parameter satisfies the preset parameter condition, the electronic forest to be tested is used as the multi-bit-width electronic forest to be processed, and the iterative optimization operation is re-executed.
[0016] In combination with the first aspect, in one implementation, the calculating the resource benefit parameter of the electronic forest to be tested includes:
[0017] Determining the number of logic gates of the multi-bit width electronic forest and the electronic forest to be tested respectively, and obtaining the number of multi-bit width gates and the initial number of gates;
[0018] Calculating the difference between the multi-bit width gate number and the initial gate number to obtain a gate number difference;
[0019] The ratio of the gate number difference to the multi-bit width gate number is calculated to obtain a resource benefit parameter.
[0020] In combination with the first aspect, in one implementation, the calculation of the number of logic gates includes:
[0021] Count the number of data-end bits, the number of multiplexers, the number of AND gates, and the number of AND gates in the forest respectively;
[0022] After calculating the number of AND gates and the sum of the number of AND gates, the product of the sum, the number of data end bits and the number of multiplexers is calculated to obtain the number of logic gates.
[0023] In combination with the first aspect, in one implementation, the step of constructing the electronic forest to be tested by using the initial electronic forest and a preset selector includes:
[0024] Connecting the preset selector to the selection signal terminal of the multiplexer of the initial electronic forest to obtain the electronic forest to be tested;
[0025] The preset selector is a selector that uses the selection signal terminals of a plurality of the target selectors to form a shared selection logic.
[0026] In combination with the first aspect, in one implementation, determining whether the multi-bit-width electronic forest has a target selector includes:
[0027] Obtaining a data input signal of each multiplexer at an input end of the multi-bit width electronic forest;
[0028] After arranging the plurality of data input signals from high to low, determining the number of multiplexers corresponding to the data input signal with the highest arrangement, and obtaining an arrangement quantity value;
[0029] If the value of the number of permutations is greater than 2, it is determined that a target selector exists in the multi-bit-width electronic forest, and the multiplexer corresponding to the data input signal with the highest permutation is used as the target selector.
[0030] A second aspect of an embodiment of the present invention provides an optimization device for a multi-bit width electronic forest, the device comprising:
[0031] A determination module, configured to determine whether a target selector exists in the multi-bit-width electronic forest after obtaining the multi-bit-width electronic forest to be processed, wherein the target selector is a multiplexer in which one input signal is public data;
[0032] an optimization module, configured to iteratively optimize the multi-bit-width electronic forest according to the target selector to obtain a target electronic forest if the multi-bit-width electronic forest has a target selector;
[0033] The iterative optimization is a process of adjusting the connection relationship of the input signal of the target selector in the multi-bit width electronic forest.
[0034] In conjunction with the second aspect, in one implementation, the optimization module is further configured to:
[0035] Connecting the non-public input signal of each of the target selectors in the multi-bit width electronic forest to the input end of the back-end selector, and clearing the target selectors to obtain an initial electronic forest, wherein the non-public input signal is an input signal of non-public data in the target selector, and the back-end selector is a multiplexer connected to the output end of the target selector;
[0036] Using the initial electronic forest and a preset selector to construct an electronic forest to be tested, and calculating resource benefit parameters of the electronic forest to be tested;
[0037] If the resource benefit parameter does not meet the preset parameter condition, the multi-bit-width electronic forest to be processed before the iterative optimization of the electronic forest to be tested is used as the target electronic forest.
[0038] In conjunction with the second aspect, in one implementation, the optimization module is further configured to:
[0039] If the resource benefit parameter satisfies the preset parameter condition, the electronic forest to be tested is used as the multi-bit-width electronic forest to be processed, and the iterative optimization operation is re-executed.
[0040] In conjunction with the second aspect, in one implementation, the optimization module is further configured to:
[0041] Determining the number of logic gates of the multi-bit width electronic forest and the electronic forest to be tested respectively, and obtaining the number of multi-bit width gates and the initial number of gates;
[0042] Calculating the difference between the multi-bit width gate number and the initial gate number to obtain a gate number difference;
[0043] The ratio of the gate number difference to the multi-bit width gate number is calculated to obtain a resource benefit parameter.
[0044] In conjunction with the second aspect, in one implementation, the optimization module is further configured to:
[0045] Count the number of data-end bits, the number of multiplexers, the number of AND gates, and the number of AND gates in the forest respectively;
[0046] After calculating the number of AND gates and the sum of the number of AND gates, the product of the sum, the number of data end bits and the number of multiplexers is calculated to obtain the number of logic gates.
[0047] In conjunction with the second aspect, in one implementation, the optimization module is further configured to:
[0048] Connecting the preset selector to the selection signal terminal of the multiplexer of the initial electronic forest to obtain the electronic forest to be tested;
[0049] The preset selector is a selector that uses the selection signal terminals of a plurality of the target selectors to form a shared selection logic.
[0050] In conjunction with the second aspect, in one implementation, the determining module is further configured to:
[0051] Obtaining a data input signal of each multiplexer at an input end of the multi-bit width electronic forest;
[0052] After arranging the plurality of data input signals from high to low, determining the number of multiplexers corresponding to the data input signal with the highest arrangement, and obtaining an arrangement quantity value;
[0053] If the value of the number of permutations is greater than 2, it is determined that a target selector exists in the multi-bit-width electronic forest, and the multiplexer corresponding to the data input signal with the highest permutation is used as the target selector.
[0054] Compared with the prior art, the optimization method, device, equipment and medium of a multi-bit-width electronic forest provided by the embodiments of the present invention have the following beneficial effects: after obtaining the multi-bit-width electronic forest to be processed, the present invention can determine whether there is a multiplexer in the multi-bit-width electronic forest where one of the input signals is public data; if there is a multiplexer in the multi-bit-width electronic forest where one of the input signals is public data, the connection relationship of the multiplexers in the multi-bit-width electronic forest where the input signals are public data is adjusted, and the multiplexer is cleared, thereby simplifying the structure of the multi-bit-width electronic forest, reducing the number of multiplexers, and improving computing resources on the basis of reducing circuit costs to meet existing application needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 It is a structural schematic diagram of a two-choose-one multiplexer provided in one embodiment of the present invention;
[0056] Figure 2 It is a structural schematic diagram of a two-choice multiplexer tree provided by an embodiment of the present invention;
[0057] Figure 3 is a schematic diagram of the structure of a multi-bit width electronic forest provided by an embodiment of the present invention;
[0058] Figure 4 It is a flow chart of a method for optimizing a multi-bit-width electronic forest provided by one embodiment of the present invention;
[0059] Figure 5 is a schematic diagram of the connection structure of an iteratively optimized multiplexer provided in one embodiment of the present invention;
[0060] Figure 6 is a schematic diagram of the structure of a multi-bit-width electronic forest that completes an iterative optimization according to an embodiment of the present invention;
[0061] Figure 7 is a schematic diagram of the structure of an electronic forest to be tested provided by an embodiment of the present invention;
[0062] Figure 8 It is a schematic diagram of a circuit provided by an embodiment of the present invention having a resource amount of 3 logic gates;
[0063] Fig. 9It is an operation flow chart of a method for optimizing a multi-bit-width electronic forest provided by one embodiment of the present invention;
[0064] Fig.10 It is a schematic structural diagram of a device for optimizing a multi-bit-width electronic forest provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0065] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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 ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0066] Binary multiplexer: Binary Multiplexer, abbreviated as binary-mux. A multiplexer with binary-coded selection input. For example, an 8-to-1 binary multiplexer has a 3-bit selection end, represented by sel; the number of its data ends is 8, represented by i0, i1, i2, i3, i4, i5, i6, and i7; when the code of sel is 000, the input signal of i0 is selected as the output; when the code of sel is 001, the input signal of i1 is selected as the output; when the code of sel is 010, the input signal of i2 is selected as the output, and so on.
[0067] Reference Figure 1 , shows a schematic diagram of the structure of a two-to-one multiplexer provided by an embodiment of the present invention. Two-to-one multiplexer: 2-to-1 Multiplexer, abbreviated as mux21. A multiplexer with only 1 selection terminal and 2 data terminals. When the selection terminal input signal sel is 0, the value of the output signal out is d0, and when sel is 1, the value of out is d1. The circuit diagram is shown in FIG. Figure 1 shown.
[0068] Reference Figure 2 , shows a schematic diagram of the structure of a 2-to-1 multiplexer tree provided by an embodiment of the present invention. Multiple 2-to-1 multiplexers are combined and connected step by step to form a 2-to-1 multiplexer tree: 2to1 multiplexer tree, referred to as mux21 tree.
[0069] Figure 2The figure shows the circuit diagram of a two-choice multiplexer tree in the HDL description scenario. In the circuit diagram, a0~a8 are the data inputs of mux21, and the data source is the input port of the module; s0~s9 are the selection signal inputs of mux21, and the data source is the input port of the module; out is the data output of the mux21 tree, which is connected to the output port of the module; among them, the HDL (Hardware Description Language abbreviation "HDL") description scenario is generally a hardware usage scenario. HDL is a general term for hardware description languages, which are generally used as inputs to the synthesis tool synthesis circuit to describe the hardware usage scenario.
[0070] Reference Figure 3 , shows a schematic diagram of the structure of a multi-bit-width electronic forest provided by an embodiment of the present invention. Since a two-to-one multiplexer tree has the characteristics of both data path and control logic, a multi-bit-width multiplexer tree, also known as a multi-bit-width electronic forest, can be constructed by combining multiple two-to-one multiplexer trees.
[0071] As shown in the example, in actual digital circuits, the two-to-one multiplexer tree is usually multi-bit wide. Figure 2 The data bit width of the two-choose-one multiplexer tree is m, so the corresponding data signals can be expressed as a0[m-1:0], a1[m-1:0]…a8[m-1:0], and the output signal can be expressed as out[m-1:0]. The selection signal remains unchanged, still s0~s9. Correspondingly, Figure 2 The number of mux21 in the tree also needs to increase by m times, that is, the total number of mux21 becomes m*10. In the above example, the bit width of the mux21 tree is 10, that is, the number of mux21 in the example is 100.
[0072] Reference Figure 2 and Figure 3 It can be seen from the circuit that the larger the bit width, the more multi-bit width electronic forests are needed, and the more multiplexers are used. This not only increases the circuit cost and the connection structure, but also increases the computing resources and consumption resources, making it difficult to meet the existing application requirements.
[0073] In order to solve the above problems, an optimization method, device, equipment and medium of a multi-bit-width electronic forest provided in an embodiment of the present application will be introduced and explained in detail through the following specific embodiments.
[0074] Reference Figure 4 , showing a flow chart of a method for optimizing a multi-bit-width electronic forest provided by an embodiment of the present invention.
[0075] Wherein, as an example, the optimization method of the multi-bit width electronic forest may include:
[0076] S11. After obtaining a multi-bit-width electronic forest to be processed, determine whether the multi-bit-width electronic forest has a target selector, wherein the target selector is a multiplexer in which one input signal is public data.
[0077] In one embodiment, a multi-bit width electronic forest to be optimized can be obtained. For the convenience of description, reference can be made to Figure 3 Assume that Figure 3 The multi-bit-wide electron forest is the multi-bit-wide electron forest to be processed.
[0078] After obtaining the multi-bit-width electronic forest to be processed, it can be determined whether there is a target selector among multiple multiplexers included in the multi-bit-width electronic forest to be processed, wherein the target selector is a multiplexer in which one input signal is public data.
[0079] Reference Figure 1 It can be seen that each multiplexer has two input signals. The input signal of each multiplexer can be determined, and then it can be determined whether each multiplexer has the same input signal. If multiple multiplexers have the same input signal, the data of the signal is public data, and correspondingly, the multiplexer is the target selector.
[0080] In order to determine whether a target selector exists from an input end of a multi-bit-width electronic forest to be processed, as an example, the determining whether the multi-bit-width electronic forest has a target selector may include the following sub-steps:
[0081] S111, obtaining a data input signal of each multiplexer at an input end of the multi-bit width electronic forest.
[0082] S112, after arranging the plurality of data input signals from high to low, determine the number of multiplexers corresponding to the data input signal with the highest arrangement, and obtain an arrangement quantity value.
[0083] S113. If the value of the number of permutations is greater than 2, it is determined that a target selector exists in the multi-bit-width electronic forest, and the multiplexer corresponding to the data input signal with the highest permutation is used as the target selector.
[0084] In one mode of operation, a multi-bit wide electronic forest may be used to obtain a data input signal to each multiplexer in the input direction.
[0085] by Figure 3For example, the multiplexers in the input direction include: mux4, mux5, mux6, mux7, mux8, mux9. Then determine the input signal of each multiplexer, for example, the input signal of mux6 is a0 and a1; the input signal of mux7 is a0 and a2, and so on, to obtain the input signal of each multiplexer.
[0086] The object of arrangement is the common data input signal. For this example mux21 tree, the data input signals are a0 to a8. Since a0 appears in multiple positions, a0 is called the common data input signal.
[0087] Then, multiple data input signals can be arranged from high to low. Figure 3 The input signals are arranged from high to low as a0, a1, a2…a8. Then the number of multiplexers corresponding to the highest ranked data input signal can be determined to obtain the number of permutations. Figure 3 , the number of multiplexers corresponding to the data input signal of a0 is 4, namely mux6, mux7, mux8, and mux5.
[0088] At this time, if the value of the number of permutations is greater than 2, it is determined that there is a target selector in the multi-bit width electronic forest, and the multiplexer corresponding to the data input signal with the highest permutation is the target selector, that is, mux6, mux7, mux8, and mux5 are the target selectors.
[0089] In one embodiment, if the number of public data input signals is larger, the more resources can be optimized, and the effect of the method is better. When the optimization benefits obtained by a large number of public data input signals do not meet the benefit threshold corresponding to the resource benefits in the subsequent steps, the benefits obtained by a small number of public data input signals will definitely not meet the conditions, and the optimization can be terminated in advance without judging other public data input signals.
[0090] Reference Figure 3 , the structure and selection signal input of each bit of the multi-bit width mux21 tree are exactly the same, the difference is that the number of bits of data input for each bit is different. Therefore, the difference in the public data input signal in each bit mux21tree of the multi-bit width mux21 tree is only the difference in the number of bits. For this example multi-bit width mux21tree, the public data input signal in the 0th bit mux21 tree is a0[0], that is, the 0th bit of the a0 signal, ..., the public data input signal in the 9th bit mux21 tree is a0[9], that is, the 9th bit of the a0 signal. Among them, bit: bit, is the smallest unit of signal in digital circuits, that is, a binary digit.
[0091] After determining the target selector, the selection signal of the multiplexer (mux21) passing through the root node of the multi-bit wide electronic forest to the common data terminal can be recorded.
[0092] like Figure 3 In the multi-bit width electronic forest shown, a0 is a common data terminal, and mux21 with common data terminal a0 in the multi-bit width electronic forest is mux6, mux7, mux8, and mux5. Record the selection signal from the mux21 tree root node, i.e., mux0, to the common data terminal a0 through mux21.
[0093] For this example case, the selection signals that need to be recorded are:
[0094] The a0 data selection signal path from mux0 to mux6 is: !s9&&!s7&&!s4&&!s0;
[0095] The a0 data selection signal path from mux0 to mux7 is: !s9&&!s7&&s4&&!s1;
[0096] The a0 data selection signal path from mux0 to mux8 is: s9&&! s8&&! s5&&s2;
[0097] The a0 data selection signal path from mux0 to mux5 is: s9&&s8&&!s6.
[0098] S12, if the multi-bit-width electronic forest has a target selector, iteratively optimizing the multi-bit-width electronic forest according to the target selector to obtain a target electronic forest;
[0099] The iterative optimization is a process of adjusting the connection relationship of the input signal of the target selector in the multi-bit width electronic forest.
[0100] When a multi-bit width electronic forest has a target selector, it means that the more input signals of the public data, the more resources that can be optimized. At this time, the connection relationship of the input signals of the target selector in the multi-bit width electronic forest can be adjusted, thereby adjusting the structure of the multi-bit width electronic forest to be processed to simplify the multi-bit width electronic forest to be processed, and after adjusting the connection relationship, the target selector can be cleared, the number of multiplexers of the multi-bit width electronic forest can be reduced, and the cost can be reduced.
[0101] After completing an adjustment, it can be determined whether the adjusted multi-bit width electronic forest optimization benefit meets the corresponding benefit threshold. If the adjusted multi-bit width electronic forest optimization benefit meets the corresponding benefit threshold, it means that the optimization can continue, and the adjusted multi-bit width electronic forest can be used as the multi-bit width electronic forest to be processed, and the above operation can be re-executed. If the adjusted multi-bit width electronic forest optimization benefit does not meet the corresponding benefit threshold, it means that there is no benefit from this optimization, and the electronic forest to be processed before this optimization operation can be output.
[0102] Wherein, as an example, the iterative optimization of the multi-bit-width electronic forest according to the target selector to obtain the target electronic forest may include the following sub-steps:
[0103] S121. Connect the non-public input signal of each target selector in the multi-bit width electronic forest to the input end of the back-end selector, and clear the target selector to obtain an initial electronic forest, wherein the non-public input signal is the input signal of the non-public data in the target selector, and the back-end selector is a multi-way selector connected to the output end of the target selector.
[0104] S122: construct an electronic forest to be tested by using the initial electronic forest and a preset selector, and calculate resource benefit parameters of the electronic forest to be tested.
[0105] S123: If the resource benefit parameter does not meet the preset parameter condition, the multi-bit-width electronic forest to be processed before iterative optimization of the electronic forest to be tested is used as the target electronic forest.
[0106] S124: If the resource benefit parameter satisfies a preset parameter condition, the electronic forest to be tested is used as the multi-bit-width electronic forest to be processed, and the iterative optimization operation is re-executed.
[0107] In one operation mode, the input signal of the non-public data in the target selector can be determined to obtain the non-public input signal of the target selector, and the multiplexer connected to the output end of the target selector can be determined at the same time. Then, the non-public input signal of each target selector in the multi-bit wide electronic forest is connected to the input end of the back-end selector, and then the target selector is cleared.
[0108] like Figure 3In the multi-bit wide electronic forest shown in the figure, mux21 tree has mux6, mux7, mux8, and mux5 with public data terminal a0. The subsequent steps will extract the public data terminal a0 and reconnect it to the netlist, so the mux21 with public data terminal will be optimized in this step. The specific optimization method is to delete the target mux21 with public data and connect the data of the non-public data terminal in the target mux21 to the output mux21 of the mux21.
[0109] by Figure 3 Take mux6 and mux7 of the multi-bit wide electronic forest as an example. The i0 end of mux6 is connected to the public data a0, so mux6 is optimized and the i1 end data a1 of mux6 is reconnected to the output mux3 of mux6. Similarly, mux7 performs the same operation.
[0110] Reference Figure 5 , shows a schematic diagram of the connection structure of the iteratively optimized multiplexer provided by an embodiment of the present invention. This step is to optimize the mux with the common data input signal a0. After mux6 and mux7 are optimized, Figure 5 shown.
[0111] Reference Figure 6 , showing a schematic diagram of the structure of a multi-bit-width electronic forest that completes an iterative optimization provided by an embodiment of the present invention.
[0112] by Figure 3 The multi-bit wide electron forest shown is used as an example. Figure 3 The mux21 with common data input signal a0 is mux6, mux7, mux8, and mux5.
[0113] The i0 end of mux6 is connected to the common data input signal a0, mux6 is optimized, and the i1 end data a1 of mux6 is reconnected to the output mux3 of mux6.
[0114] The i0 end of mux7 is connected to the common data input signal a0, mux7 is optimized, and the i1 end data a2 of mux7 is reconnected to the output mux3 of mux7.
[0115] The i1 end of mux8 is connected to the common data input signal a0, mux8 is optimized, and the i0 end data a4 of mux8 is reconnected to the output mux4 of mux8.
[0116] The i0 end of mux5 is connected to the common data input signal a0, so mux5 is optimized and the i1 end data mux9 of mux5 is reconnected to the output mux2 of mux5. The netlist after the above operation is as follows Figure 6 As shown. The initial electron forest is obtained.
[0117] Next, the electronic forest to be tested can be constructed using the initial electronic forest and the preset selector, and the resource benefit parameter of the electronic forest to be tested can be calculated. The preset selector can also be a multi-way selector, that is, the initial electronic forest after the optimized connection relationship is connected to the preset selector to construct the electronic forest to be tested, thereby obtaining the electronic forest to be tested. In order to facilitate the comparison of resource changes before and after optimization, the resource benefit parameter can be the number of logic gate-level resources of the electronic forest to be tested.
[0118] If the resource benefit parameter does not meet the preset parameter conditions, it means that the electronic forest to be tested cannot be optimized any further, and the multi-bit-width electronic forest to be processed before the iterative optimization of the electronic forest to be tested can be used as the target electronic forest.
[0119] If the resource benefit parameter meets the preset parameter conditions, it means that the electronic forest to be tested can be optimized again, and the electronic forest to be tested can be used as the multi-bit width electronic forest to be processed, and the iterative optimization operation can be re-executed. That is, the electronic forest to be tested is used as the multi-bit width electronic forest to be processed, and it is re-determined whether the multi-bit width electronic forest has a target selector. If the multi-bit width electronic forest has a target selector, the multi-bit width electronic forest is iteratively optimized according to the target selector until the target electronic forest is obtained.
[0120] Through the above method, the multiplexers with public data in the multi-bit-width electronic forest to be processed can be extracted, and then the multiplexers with public data can be optimized and cleared, so that the number of multiplexers of the multi-bit-width electronic forest to be processed can be reduced, and the resource optimization of the multi-bit-width electronic forest to be processed can be achieved; especially for the mux21 tree with a large amount of public data and a large bit width, it can effectively reduce resources.
[0121] In one embodiment, the step of constructing the electronic forest to be tested by using the initial electronic forest and a preset selector may include the following sub-steps:
[0122] S21, connecting the preset selector to the selection signal end of the multiplexer of the initial electronic forest to obtain the electronic forest to be tested;
[0123] The preset selector is a selector that uses the selection signal terminals of a plurality of the target selectors to form a shared selection logic.
[0124] Specifically, in order to construct the electronic forest to be tested, in one embodiment, a multiplexer may be newly created as a preset selector to connect the public data, and the preset selector may be used to connect the public data of the cleared target selector.
[0125] Reference Figure 7 , showing a schematic diagram of the structure of the electronic forest to be tested provided by an embodiment of the present invention. After the above steps, the multiplexer with public data is optimized. In this step, a new multiplexer needs to be created to reconnect the public data to the netlist. Taking the example case as an example, the i0 terminal data of the newly created multiplexer is the initial electronic forest.
[0126] See Figure 7 , the data at the i1 end is the public data a0, and the selection end is all the selection paths from the root node of the multi-bit width electronic forest to the public data through the multiplexer recorded in the above steps. For the multi-bit width electronic forest, the structure of each bit of the multi-bit width electronic forest is exactly the same, and the selection signal is exactly the same. The difference is that the data end takes different bits, so the selection signal of the newly created multiplexer can be shared.
[0127] Will Figure 3 The netlist of the multi-bit wide electronic forest after the above operation is as follows Figure 7 As shown. The preset selector is a newly created multi-way selector, and the selection signal of the preset selector is a shared selection logic. After the electronic forest to be tested is constructed, the resource benefit parameter of the electronic forest to be tested can be calculated to determine whether the optimization process can be continued.
[0128] In one embodiment, the calculating of the resource benefit parameter of the electronic forest to be tested may include the following sub-steps:
[0129] S31 , respectively determining the number of logic gates of the multi-bit width electronic forest and the electronic forest to be tested, and obtaining the number of multi-bit width gates and the initial number of gates.
[0130] S32, calculating the difference between the multi-bit width gate number and the initial gate number to obtain a gate number difference.
[0131] S33, calculating the ratio of the gate number difference to the multi-bit width gate number to obtain a resource benefit parameter.
[0132] In one embodiment, the number of logic gates of the multi-bit width electronic forest may be determined to obtain the multi-bit width gate number; the number of logic gates of the electronic forest to be tested may also be determined to obtain the initial gate number.
[0133] Next, the difference between the number of multi-bit width gates and the initial number of gates can be calculated to obtain the gate number difference. Finally, the ratio of the gate number difference to the number of multi-bit width gates can be calculated to obtain the resource benefit parameter.
[0134] Specifically, the formula for calculating resource benefits can be shown as follows:
[0135] Resource benefit parameter = (gate resources before optimization - gate resources after optimization) / gate resources before optimization * 100%.
[0136] In one embodiment, the calculation of the number of logic gates may include the following sub-steps:
[0137] S1311, respectively counting the number of data end bits, the number of multiplexers, the number of AND gates, and the number of AND gates of the forest.
[0138] S1312, after calculating the number of AND gates and the sum of the number of AND gates, calculate the product of the sum, the number of data end bits and the number of multiplexers to obtain the number of logic gates.
[0139] In one embodiment, when calculating the number of logic gates of a multi-bit width electronic forest, the number of data end bits, the number of multiplexers, the number of AND gates, and the number of AND gates of the multi-bit width electronic forest can be counted. After calculating the number of AND gates of the multi-bit width electronic forest and the number of AND gates of the multi-bit width electronic forest, the product of the number of multi-bit width electronic forests, the number of data end bits, and the number of multiplexers is calculated to obtain the number of logic gates of the multi-bit width electronic forest. The number of logic gates of the electronic forest to be tested can also be calculated in accordance with the above method.
[0140] In order to facilitate the comparison of resource changes before and after optimization, the number of logic gate-level resources in the netlist is used as the calculation standard.
[0141] Taking the example case as an example, the netlist before optimization is as follows Figure 3 The multi-bit wide electronic forest shown in the figure, the optimized netlist is as follows Figure 7 The electronic forest under test is shown.
[0142] Calculate the resources of the multi-bit width electronic forest before optimization. Before optimization, there are 10 mux21s in each bit mux21 tree. For example, there are 10 bits, so there will be 10 mux21 trees with exactly the same structure and selection signals, but only different data bits. Therefore, the netlist resources before optimization are 10*10=100 mux21 resources. From the previous explanation, we can know that each mux21 consists of 2 and gates, an or gate, and a not gate. The not gate is not included, that is, the resources of each mux21 are 3 logic gates, that is, the netlist resources before optimization are 10*10*3=300 logic gate resources.
[0143] Calculate the resources of the electronic forest to be tested after optimization. After optimization, there are 7 mux21s in each bit mux21 tree. For example, there are 10 bits in total, so there are 10*7=70 mux21 resources in the optimized netlist. In addition, there are 11 and gates, 3 or gates, and 10 not gate logics in the selection end signal of the newly created mux21 in the optimized netlist. Since the 10 mux21 tree structures in the netlist are exactly the same, the selection signals are also the same, and only the data end bits are different, so the selection signals of the newly created mux21 can be shared, such as Figure 7 As shown, the 10 optimized mux21 trees share the selection signal. Therefore, the netlist resources after optimization in this example case are 10*7*3+14=224 logic gate resources.
[0144] It should be noted that since the logic elements used in the present invention are only logic gates and mux21, the resources described in the present invention are the number of logic gates and mux21 used in the circuit. Since the logic elements are converted into LUT (lookup table) through "logic mapping" in the FPGA design process, when the NOT gate and other logic elements exist at the same time, the NOT gate will not occupy the LUT (lookup table) resources alone, and there will be no scenario in which the NOT gate exists alone in this patent, so the NOT gate will not be counted when counting resources in this patent.
[0145] Reference Figure 8 , showing a schematic diagram of a circuit with a resource amount of 3 logic gates provided by an embodiment of the present invention, with “ Figure 8 Taking the "MUX21 gate-level implementation" as an example, the resource amount of this circuit is 3 logic gates (two AND gates, one OR gate, and NOT gate is not included).
[0146] Referring to the table below, the resource statistics before and after optimization are as follows:
[0147] mux21 number Number of gates Total number of gates Resources before optimization 100 0 300 Optimized resources 70 14 224
[0148] According to the resource benefit calculation formula, the resource benefit parameter can be calculated based on the logic gate resources before and after the optimization, and it can be obtained that the resource benefit parameter is 25.3%, indicating that the optimization is acceptable. The optimization process can be continued iteratively, and can be continued in the above manner until the resource benefit parameter does not meet the threshold requirement.
[0149] Reference Fig. 9 , shows an operation flow chart of an optimization method for a multi-bit-width electronic forest provided by an embodiment of the present invention.
[0150] Specifically, the operation of the optimization method of the multi-bit width electronic forest may include the following steps:
[0151] In the first step, a multi-bit wide electron forest to be processed is obtained.
[0152] In the second step, all public data of the multi-bit wide electronic forest to be processed are counted into a container and sorted from high to low according to the quantity.
[0153] The third step is to determine whether there is public data in the multi-bit wide electronic forest to be processed.
[0154] In the fourth step, if there is public data in the multi-bit-width electronic forest to be processed, take the first data in the container, that is, the public data with the highest number of repetitions in the current multi-bit-width electronic forest to be processed, and delete it from the container.
[0155] The fifth step is to find the multiplexer where the public data exists, and record the selection signal of the multiplexer (mux21) from the root node of the multi-bit wide electronic forest to the public data end.
[0156] In the sixth step, the multiplexer (mux21) with the common data terminal is optimized, and the other data terminal of the multiplexer (mux21) is reconnected to a subsequent multiplexer (mux21).
[0157] In the seventh step, a multiplexer (mux21) is newly built after the root node, the i0 terminal of the multiplexer (mux21) is connected to the processed multi-bit width electronic forest, and the i1 terminal is connected to the public data terminal to obtain the electronic forest to be tested.
[0158] Step 8: If the electronic forest to be tested meets the resource benefit condition, the electronic forest to be tested is used as the multi-bit width electronic forest to be processed and the operation is returned to the first step again. If the electronic forest to be tested does not meet the resource benefit condition, the multi-bit width electronic forest to be processed before the electronic forest to be tested is output.
[0159] In this embodiment, the embodiment of the present invention provides an optimization method for a multi-bit-width electronic forest, and its beneficial effect is that: after obtaining the multi-bit-width electronic forest to be processed, the present invention can determine whether there is a multiplexer in the multi-bit-width electronic forest where one of the input signals is public data; if there is a multiplexer in the multi-bit-width electronic forest where one of the input signals is public data, the connection relationship of the multiplexers in the multi-bit-width electronic forest where the input signals are public data is adjusted, and the multiplexer is cleared, thereby simplifying the structure of the multi-bit-width electronic forest, reducing the number of multiplexers, and improving computing resources on the basis of reducing circuit costs to meet existing application needs.
[0160] The embodiment of the present invention also provides an optimization device for a multi-bit width electronic forest, see Fig.10, showing a schematic structural diagram of an optimization device for a multi-bit-width electronic forest provided by an embodiment of the present invention.
[0161] Wherein, as an example, the optimization device of the multi-bit width electronic forest may include:
[0162] A determination module 201 is used to determine whether a target selector exists in the multi-bit-width electronic forest after obtaining the multi-bit-width electronic forest to be processed, wherein the target selector is a multiplexer in which one input signal is public data;
[0163] An optimization module 202 is configured to iteratively optimize the multi-bit-width electronic forest according to the target selector to obtain a target electronic forest if the multi-bit-width electronic forest has a target selector;
[0164] The iterative optimization is a process of adjusting the connection relationship of the input signal of the target selector in the multi-bit width electronic forest.
[0165] Optionally, the optimization module is further used to:
[0166] Connecting the non-public input signal of each of the target selectors in the multi-bit width electronic forest to the input end of the back-end selector, and clearing the target selectors to obtain an initial electronic forest, wherein the non-public input signal is an input signal of non-public data in the target selector, and the back-end selector is a multiplexer connected to the output end of the target selector;
[0167] Using the initial electronic forest and a preset selector to construct an electronic forest to be tested, and calculating resource benefit parameters of the electronic forest to be tested;
[0168] If the resource benefit parameter does not meet the preset parameter condition, the multi-bit-width electronic forest to be processed before the iterative optimization of the electronic forest to be tested is used as the target electronic forest.
[0169] Optionally, the optimization module is further used to:
[0170] If the resource benefit parameter satisfies the preset parameter condition, the electronic forest to be tested is used as the multi-bit-width electronic forest to be processed, and the iterative optimization operation is re-executed.
[0171] Optionally, the optimization module is further used to:
[0172] Determining the number of logic gates of the multi-bit width electronic forest and the electronic forest to be tested respectively, and obtaining the number of multi-bit width gates and the initial number of gates;
[0173] Calculating the difference between the multi-bit width gate number and the initial gate number to obtain a gate number difference;
[0174] The ratio of the gate number difference to the multi-bit width gate number is calculated to obtain a resource benefit parameter.
[0175] Optionally, the optimization module is further used to:
[0176] Count the number of data-end bits, the number of multiplexers, the number of AND gates, and the number of AND gates in the forest respectively;
[0177] After calculating the number of AND gates and the sum of the number of AND gates, the product of the sum, the number of data end bits and the number of multiplexers is calculated to obtain the number of logic gates.
[0178] Optionally, the optimization module is further used to:
[0179] Connecting the preset selector to the selection signal terminal of the multiplexer of the initial electronic forest to obtain the electronic forest to be tested;
[0180] The preset selector is a selector that uses the selection signal terminals of a plurality of the target selectors to form a shared selection logic.
[0181] Optionally, the determining module is further used to:
[0182] Obtaining a data input signal of each multiplexer at an input end of the multi-bit width electronic forest;
[0183] After arranging the plurality of data input signals from high to low, determining the number of multiplexers corresponding to the data input signal with the highest arrangement, and obtaining an arrangement quantity value;
[0184] If the value of the number of permutations is greater than 2, it is determined that a target selector exists in the multi-bit-width electronic forest, and the multiplexer corresponding to the data input signal with the highest permutation is used as the target selector.
[0185] Those skilled in the art can clearly understand that, for the sake of convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0186] Furthermore, an embodiment of the present application also provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the optimization method of the multi-bit-width electronic forest as described in the above embodiment is implemented.
[0187] Furthermore, an embodiment of the present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer-executable program, and the computer-executable program is used to enable a computer to execute the optimization method of the multi-bit-width electronic forest as described in the above embodiment.
[0188] It should be noted that the orientation or positional relationship indicated by the terms "upper", "lower", etc. is based on the orientation or positional relationship shown in the accompanying drawings, which is only for the convenience of describing the embodiments of the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present invention. When an element such as a layer, region or substrate is referred to as being "on" or "above" another element, it can be directly on the other element, or there can also be an intermediate element. On the contrary, when an element is referred to as "directly on" or "above" another element, there is no intermediate element. It should also be understood that when an element is referred to as being "under" or "below" another element, it can be directly under or below the other element, or there can also be an intermediate element. On the contrary, when an element is referred to as being "directly under" or "below" another element, there is no intermediate element. Unless otherwise clearly specified and limited, the terms "installed", "connected" and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0189] Those skilled in the art will appreciate that the embodiments of the present application may also provide computer program products. Therefore, the present application may adopt the form of complete hardware embodiments, complete software embodiments, or embodiments in combination with software and hardware. Moreover, the present application may adopt the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program codes.
[0190] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), apparatuses, and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0191] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0192] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0193] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for optimizing a multi-bit width electronic forest, characterized in that: The method comprises: After obtaining a multi-bit-wide electronic forest to be processed, determining whether the multi-bit-wide electronic forest has a target selector, the target selector being a multiplexer in which one input signal is public data; If the multi-bit-width electronic forest has a target selector, iteratively optimizing the multi-bit-width electronic forest according to the target selector to obtain a target electronic forest; The iterative optimization is a process of adjusting the connection relationship of the input signal of the target selector in the multi-bit width electronic forest.
2. The optimization method of multi-bit width electronic forest according to claim 1, characterized in that: The iterative optimization of the multi-bit-width electronic forest according to the target selector to obtain a target electronic forest includes: Connecting the non-public input signal of each of the target selectors in the multi-bit width electronic forest to the input end of the back-end selector, and clearing the target selectors to obtain an initial electronic forest, wherein the non-public input signal is an input signal of non-public data in the target selector, and the back-end selector is a multiplexer connected to the output end of the target selector; Using the initial electronic forest and a preset selector to construct an electronic forest to be tested, and calculating resource benefit parameters of the electronic forest to be tested; If the resource benefit parameter does not meet the preset parameter condition, the multi-bit-width electronic forest to be processed before the iterative optimization of the electronic forest to be tested is used as the target electronic forest.
3. The optimization method of multi-bit width electronic forest according to claim 2, characterized in that: The iterative optimization of the multi-bit-width electronic forest according to the target selector to obtain a target electronic forest also includes: If the resource benefit parameter satisfies the preset parameter condition, the electronic forest to be tested is used as the multi-bit-width electronic forest to be processed, and the iterative optimization operation is re-executed.
4. The optimization method of multi-bit width electronic forest according to claim 2, characterized in that: The calculating of the resource benefit parameters of the electronic forest to be tested includes: Determining the number of logic gates of the multi-bit width electronic forest and the electronic forest to be tested respectively, and obtaining the number of multi-bit width gates and the initial number of gates; Calculating the difference between the multi-bit width gate number and the initial gate number to obtain a gate number difference; The ratio of the gate number difference to the multi-bit width gate number is calculated to obtain a resource benefit parameter.
5. The optimization method of multi-bit width electronic forest according to claim 4, characterized in that: The calculation of the number of logic gates includes: Count the number of data-end bits, the number of multiplexers, the number of AND gates, and the number of AND gates in the forest respectively; After calculating the number of AND gates and the sum of the number of AND gates, the product of the sum, the number of data end bits and the number of multiplexers is calculated to obtain the number of logic gates.
6. The optimization method of multi-bit width electronic forest according to claim 2, characterized in that: The method of constructing the electronic forest to be tested by using the initial electronic forest and the preset selector includes: Connecting the preset selector to the selection signal terminal of the multiplexer of the initial electronic forest to obtain the electronic forest to be tested; The preset selector is a selector that uses the selection signal terminals of a plurality of the target selectors to form a shared selection logic.
7. The optimization method of multi-bit width electronic forest according to claim 1, characterized in that: The determining whether the multi-bit width electronic forest has a target selector comprises: Obtaining a data input signal of each multiplexer at an input end of the multi-bit width electronic forest; After arranging the plurality of data input signals from high to low, determining the number of multiplexers corresponding to the data input signal with the highest arrangement, and obtaining an arrangement quantity value; If the value of the number of permutations is greater than 2, it is determined that a target selector exists in the multi-bit-width electronic forest, and the multiplexer corresponding to the data input signal with the highest permutation is used as the target selector.
8. An optimization device for a multi-bit width electronic forest, characterized in that: The device comprises: A determination module, configured to determine whether a target selector exists in the multi-bit-width electronic forest after obtaining the multi-bit-width electronic forest to be processed, wherein the target selector is a multiplexer in which one input signal is public data; an optimization module, configured to iteratively optimize the multi-bit-width electronic forest according to the target selector to obtain a target electronic forest if the multi-bit-width electronic forest has a target selector; The iterative optimization is a process of adjusting the connection relationship of the input signal of the target selector in the multi-bit width electronic forest.
9. An electronic device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the optimization method for a multi-bit-width electronic forest as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer-executable program, and the computer-executable program is used to enable a computer to execute the optimization method of a multi-bit-width electronic forest as described in any one of claims 1 to 7.