Data bit number conversion circuit and method

By designing a data bit conversion circuit and performing calculations successively using the calculation unit, high-precision bit conversion is achieved, solving the problems of low accuracy or complex implementation in the prior art, and is suitable for in-memory computing and neural networks.

CN114168192BActive Publication Date: 2024-11-29BEIJING PINGXIN TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202010944770.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-10
Publication Date
2024-11-29
Estimated Expiration
2040-09-10

AI Technical Summary

Technical Problem

When the prior art reduces the number of input data bits, the accuracy is low or the implementation is complex, making it difficult to meet the needs of high precision, low cost and simple implementation.

Method used

Design a data bit conversion circuit, perform calculations successively through n calculation units, and use shifters, multiplexers and subtractors to perform bit conversion. The conversion factor CE can be arbitrarily set to achieve high-precision bit conversion. .

Benefits of technology

It realizes high-precision data bit conversion, reduces the circuit design area, simplifies the implementation process, and is suitable for application scenarios such as in-memory computing and neural networks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114168192B_ABST
    Figure CN114168192B_ABST
Patent Text Reader

Abstract

The present invention relates to a data bit number conversion circuit, wherein the input data X0 and the output data Y are respectively m-bit and n-bit binary integers, and m is greater than n, wherein the i-th computing unit among the n computing units comprises the following components, wherein 1≤i≤n: a shifter, which is configured to shift the conversion factor CE to the right by i bits, wherein CE≤2 m ‑1; Multiplexer, the first input terminal of which inputs input data X i‑1 The control input of the multiplexer is connected to the sign output of the subtractor, and the selection output of the multiplexer outputs the input data X. i and a subtractor, whose second input terminal is connected to the output terminal of the shifter, and whose sign output terminal outputs the n-ith bit of the output data Y. The present invention also relates to a method for converting the number of bits of data. Through the present invention, the number of bits of input data can be converted with high precision with any conversion factor CE.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention generally relates to the field of integrated circuits, and more particularly to a data bit number conversion circuit. In addition, the present invention also relates to a method for converting the number of bits of input data. Background Art

[0002] When processing data, in some occasions where the processing accuracy is not high, it is necessary to transform the number of bits of the input data, especially to reduce the number of bits of the input data to reduce the computational overhead. For example, in a neural network, the result of each layer (such as the input layer, hidden layer, and output layer) is the sum of the product results of multiple neural units, which causes the number of bits of the output result of each layer to increase with the number of input bits, so the number of bits of data must be reduced. For example, the input data of each layer is an 8-bit binary number, but after multiplication and addition operations, the output result becomes 16 bits. At this time, the number of bits of the output result must be reduced to 8 bits before it can participate in the calculation of the next layer. In addition, in a storage and calculation integrated memory, when performing a cyclic calculation, the precision of the input and output of the calculation results of different columns may be different, so a quantization operation, that is, the conversion of the number of bits of input data, is required to unify the input and output precision for subsequent operations.

[0003] Existing input data bit conversion (reducing m bits to n bits after quantization) includes the following solutions:

[0004] 1. Direct shifting: The advantage is that the circuit is simple, but the disadvantage is that the accuracy is low. This is because the maximum possible value of input data in application areas such as in-memory computing and neural networks is usually not 2. m -1, so if we shift directly (i.e. remove the last mn bits) to 2 n -1 value, the result cannot correspond to integer divisibility, which greatly reduces the accuracy of the output result, and the number of digits cannot be converted according to any factor.

[0005] Directly implanting traditional floating-point-based quantization circuits on the chip: The advantages are high on-chip integration and fast computing speed, but the disadvantages are complex implementation and high power consumption. The implementation of dedicated hardware requires the use of floating-point computing units, which have the disadvantages of large area and high power consumption. For example, in-memory computing processors are often used in high-energy-efficiency and low-power implementation scenarios. The high power consumption of traditional floating-point-based quantization is not suitable for in-memory computing processors with high parallelism (a huge number of quantization calculations need to be performed simultaneously).

[0006] Performing floating-point-based quantization and bit reduction calculations in an off-chip processor (such as outside the memory): The advantage is that the processor can be programmed through software to implement the calculations, thereby reducing hardware costs. The disadvantage is that the implementation is complex and has very high latency, because this solution does not use dedicated circuits but sends all the results of the in-memory calculations to an additional external processor for floating-point-based quantization calculations. In addition to consuming more bandwidth to transmit data (the data stream is m bits, while only n bits are required after conversion), each result also needs to be calculated by an external processor, which brings considerable additional latency.

[0007] A simple, low-cost, high-precision data bit reduction or quantization scheme is currently needed. Summary of the invention

[0008] Based on the prior art, the task of the present invention is to provide a data bit number conversion circuit and method, through which the input data can be converted into a high-precision bit number with an arbitrary conversion factor CE, wherein the conversion result can be scaled by the conversion factor CE.

[0009] In a first aspect of the present invention, the task is solved by a data bit number conversion circuit, wherein the input data X0 of the circuit is an m-bit binary integer, and the output data Y of the circuit is an n-bit binary integer, m and n are both natural numbers, and m>n, the circuit comprises n computing units, wherein the i-th computing unit of the n computing units comprises the following components, wherein i is an integer and 1≤i≤n:

[0010] A shifter configured to shift the conversion factor CE right by i bits, where CE is an integer and CE≤2 m -1;

[0011] The first input terminal of the multiplexer receives the input data X i-1 The first input terminal of the multiplexer is connected to the difference output terminal of the subtractor, the control input terminal of the multiplexer is connected to the sign output terminal of the subtractor, and the selection output terminal of the multiplexer outputs the input data X. i ;as well as

[0012] A subtractor, whose second input terminal is connected to the output terminal of the shifter, and whose sign output terminal outputs the ni-th bit of the output data Y.

[0013] In one embodiment of the invention, it is provided that the multiplexer is a 2-way multiplexer.

[0014] In another extended solution of the present invention, it is provided that the conversion factor CE is the maximum possible value of the input data X0 or a value defined according to the application scenario. In the present invention, CE is an integer that can be set arbitrarily, for example, it can be set according to the application scenario. In a preferred embodiment, CE is the maximum possible value of the input data X0. By doing so, the input data X0 can be normalized while reducing the number of bits, which is advantageous, for example, in the scenario of a neural network. By adjusting the size of the conversion factor CE, the conversion result can be scaled, that is, how much of X is converted into Y.

[0015] In a second aspect of the present invention, the aforementioned task is solved by a circuit for neural network calculation, the circuit comprising:

[0016] a plurality of layers, each layer comprising a plurality of neural units; and

[0017] A data bit number conversion circuit is configured to receive input data X0 from a neural unit of a first layer and output output data Y as input data of a neural unit of a second layer adjacent to the first layer.

[0018] Here, the "neural network" in the neural network circuit can be implemented by software, hardware, firmware or a combination thereof. When the neural network is hardware, the data bit conversion circuit according to the present invention receives data from the corresponding neural network hardware and processes the data, and then sends the data to the corresponding neural network hardware. When the neural network is software or firmware, the data bit conversion circuit according to the present invention receives data from the corresponding hardware running the software or firmware and processes the data, and then sends the data to the hardware, and then the data is further processed by the neural network software or firmware running on the hardware.

[0019] The present invention also relates to a memory having a data bit number conversion circuit according to the present invention. The memory is preferably a storage-computation integrated memory, which is configured to perform both calculation and storage functions. When the memory is performing a calculation function, such as a cyclic calculation, the data bit number conversion circuit according to the present invention is used to perform data bit number conversion so as to perform data shaping on the intermediate calculation result.

[0020] In a third aspect of the present invention, the aforementioned task is solved by a method for converting the number of bits of input data, wherein the input data X0 is an m-bit binary integer, and the output data Y is an n-bit binary integer, m and n are both natural numbers, and m>n, the method comprising the following steps:

[0021] Provides a conversion factor CE, where CE is an integer and CE≤2 m -1; and

[0022] Perform n calculations to respectively calculate the n-1th bit to the 0th bit of the output data Y, wherein the i-th calculation of the n calculations comprises the following steps, wherein i is an integer and 1≤i≤n:

[0023] Divide CE by 2 i As a reference value Ref;

[0024] Input data X i-1 compared with a reference value Ref; and

[0025] If the input data X i-1 is greater than the reference value Ref, then 1 is output as the nith bit of the output data Y and the input data X is selected i-1 As input data X i Otherwise, 0 is output as the nith bit of the output data Y and the input data X is selected. i-1 The difference between the reference value Ref is used as the input data X i .

[0026] In one embodiment of the invention, it is provided that the conversion factor CE is the maximum possible value CE of X0.

[0027] In another embodiment of the invention, it is provided that the maximum possible value CE of the input data X is determined by the following steps:

[0028] Set CE=2 m -1; or

[0029] Set CE based on experience, where CE<2 m -1; or

[0030] Determine the maximum possible value of the input data X according to the previous and next circuits as CE, where CE<2 m -1.

[0031] In a further embodiment of the invention, it is provided that the input data X i-1 The comparison with the reference value Ref includes:

[0032] Input data X i-1 Subtracting from the reference value Ref to obtain a difference value and a sign bit; and

[0033] Determine X based on the sign bit i-1 Is it greater than the reference value Ref?

[0034] In another embodiment of the invention, it is provided that CE is divided by 2 i The reference value Ref includes:

[0035] Shift CE right by i bits to obtain the reference value Ref.

[0036] In a fourth aspect of the invention, the aforementioned task is solved by a method for converting the number of bits of input data in a neural network, wherein the neural network comprises a plurality of layers, each layer comprising a plurality of neural units, the method comprising the following steps:

[0037] Receive input data X0 from the neural unit of the first layer;

[0038] Determine the maximum possible value CE of the input data X0, where CE≤2 m -1;

[0039] Perform n calculations to respectively calculate the n-1th bit to the 0th bit of the output data Y, wherein the i-th calculation of the n calculations comprises the following steps, wherein i is an integer and 1≤i≤n:

[0040] Divide CE by 2 i As a reference value Ref;

[0041] Input data X i-1 compared with a reference value Ref; and

[0042] If the input data X i-1 is greater than the reference value Ref, then 1 is output as the nith bit of the output data Y and the input data X is selected i-1 As input data X i Otherwise, 0 is output as the nith bit of the output data Y and the input data X is selected. i-1 The difference between the reference value Ref is used as the input data X i ;as well as

[0043] The output data Y is output to the neural units of the second layer adjacent to the first layer.

[0044] In one embodiment of the present invention, it is provided that the input data X0 is the sum of output data D of a plurality of neural units of the first layer, and the number of bits of the output data D is n.

[0045] In a fifth aspect of the present invention, the aforementioned task is solved by a data bit number conversion circuit, wherein the input data X0 of the circuit is an m-bit binary integer, and the output data Y of the circuit is an n-bit binary integer, m and n are both natural numbers, and m>n, and the circuit comprises:

[0046] One or more computing units, each of which includes the following components:

[0047] A shifter configured to shift the conversion factor CE right by i bits, where CE is an integer and CE≤2 m -1, where i is an integer and 1≤i≤n;

[0048] The first input terminal of the multiplexer receives the input data X i-1 The first input terminal of the multiplexer is connected to the difference output terminal of the subtractor, the control input terminal of the multiplexer is connected to the sign output terminal of the subtractor, and the selection output terminal of the multiplexer outputs the input data X. i ;as well as

[0049] A subtractor, whose second input terminal is connected to the output terminal of the shifter, and whose sign output terminal outputs the ni-th bit of the output data Y;

[0050] A controller configured to increment i by 1 after each calculation by the calculation unit and to output the input data X of the calculation unit. i sent to the computing unit.

[0051] Here, the one or more computing units preferably include a single computing unit, wherein the computing unit performs n operations, and the controller increments the number of operations i and re-inputs the current calculation result of the computing unit into the computing unit for the next iteration. In this way, the maximum utilization of the computing unit can be achieved, thereby minimizing the chip area. However, compared with the solution of n computing units, this solution has a longer delay time because the next X0 must be input after all n calculations are completed; in the case of n computing units, X0 can be continuously input for each calculation and the corresponding results can be continuously obtained.

[0052] In a preferred embodiment of the present invention, the controller comprises:

[0053] a counter configured to be incremented by 1 each time the calculation unit completes calculation and to be reset after reaching an upper limit value n; and

[0054] A register configured to store input data X output by a computing unit i And it is transmitted to the computing unit during the next calculation of the computing unit.

[0055] The present invention has at least the following beneficial effects:

[0056] (1) The solution of the present invention is greatly simplified by avoiding floating-point calculation circuits, thereby minimizing the design area of ​​the circuit;

[0057] (2) The circuit of the present invention can easily achieve alignment (pitch match) with the output circuit wiring, reducing the difficulty of layout design, which is very important in the design of in-memory computing based on large-area storage units. In-memory computing output signal processing requires repeated cyclic calculations, and the use of a specific quantization circuit can greatly reduce the power consumption of each calculation result output;

[0058] (3) The conversion accuracy of the scheme of the present invention is greatly improved compared with the prior art, ensuring the accuracy of the output result. For example, the accuracy of the present invention is comparable to that of the analog division method or the quantization circuit, but the implementation is simpler;

[0059] (4) The number of conversion bits in the solution of the present invention is adjustable. For example, the number of output bits can be set to any number from 1 to m (1≤n≤m) through a command signal. This is more suitable for applications where the input and output will produce different numbers of bits, such as in-memory computing, neural networks, etc. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] The present invention will be further described below in conjunction with specific embodiments with reference to the accompanying drawings.

[0061] Figure 1 A circuit diagram of a data bit number conversion circuit according to the present invention is shown;

[0062] Figure 2 A circuit diagram showing a calculation unit of a data bit number conversion circuit according to the present invention;

[0063] Figure 3 A schematic diagram of a solution according to the present invention is shown;

[0064] Figure 4 The application of the solution according to the present invention in the field of neural networks is shown; and

[0065] Figure 5 The application of the solution according to the present invention in the field of in-memory computing is shown. DETAILED DESCRIPTION

[0066] It should be noted that the components in the figures may be shown exaggeratedly for the sake of illustration and are not necessarily true to scale. In the figures, identical or functionally identical components are provided with the same reference numerals.

[0067] In the present invention, unless otherwise specified, "arranged on...", "arranged above..." and "arranged above..." do not exclude the existence of an intermediate between the two. In addition, "arranged on or above..." merely indicates the relative positional relationship between two components, and in certain cases, such as after reversing the product direction, it can also be converted into "arranged below or below...", and vice versa.

[0068] In the present invention, each embodiment is only intended to illustrate the aspects of the present invention and should not be construed as limiting.

[0069] In the present invention, unless otherwise specified, the quantifiers "a", "an" and "an" do not exclude the presence of a plurality of elements.

[0070] It should also be noted that in the embodiments of the present invention, for the sake of clarity and simplicity, only a portion of the parts or components may be shown, but those of ordinary skill in the art will understand that under the teachings of the present invention, the required parts or components may be added according to the needs of the specific scenario. In addition, unless otherwise specified, the features in different embodiments of the present invention may be combined with each other. For example, a feature in the second embodiment may be used to replace a corresponding or functionally identical or similar feature in the first embodiment, and the resulting embodiment also falls within the disclosure scope or recorded scope of the present application.

[0071] It should also be noted that within the scope of the present invention, the terms "same", "equal", "equal to" and the like do not mean that the values ​​of the two are absolutely equal, but allow a certain reasonable error, that is, the terms also cover "substantially the same", "substantially equal", "substantially equal to". By analogy, in the present invention, the terms "perpendicular to", "parallel to" and the like indicating directions also cover the meanings of "substantially perpendicular to" and "substantially parallel to".

[0072] In addition, the numbering of the steps of the methods of the present invention does not limit the execution order of the method steps. Unless otherwise specified, the method steps can be executed in different orders.

[0073] First, the principle of the present invention is described. In the present application, a data bit conversion circuit or method converts an input data X with m bits (which can be expressed as X[m-1:0]) into an output data Y with n bits (which can be expressed as Y[n-1:0]), where m>n. Here, the conversion factor is CE, where CE is an integer and CE≤2 m -1, CE can be regarded as a scaling factor, that is, CE determines how much of X is converted into Y. Here, in the solution according to the present invention, the ideal mathematical relationship between X, Y and CE is as follows:

[0074]

[0075] In the present application, the above formula is approximated by n computing units successively performing the following calculations (here y is a certain bit of Y, that is, y=Y[0], Y[1], ... Y[n-1]):

[0076]

[0077] From the above formula, it can be seen that the solution of the present invention can achieve high conversion accuracy while using a simple circuit, and the conversion result can be scaled by adjusting the size of CE. Figure 3 .like Figure 3 As shown, the solution of the present invention is to divide the input data X with a number of bits m into 2 m-n The result is n-bit output data.

[0078] The present invention will be further described below in conjunction with specific embodiments with reference to the accompanying drawings.

[0079] Figure 1 FIG. 1 is a circuit diagram of a data bit number conversion circuit 100 according to the present invention.

[0080] like Figure 1 As shown, the data bit number conversion circuit 100 according to the present invention is used to convert input data X0 into output data Y, wherein the input data X0 is an m-bit binary integer, and the output data Y of the circuit is an n-bit binary integer, m and n are both natural numbers, and m>n. In this embodiment, m=16, n=8, but it should be noted that other numbers of m and n are also conceivable under the teachings of the present invention, such as m=16, 20, 32, 40, 128, 200, 256, 500, 512, n=16, 20, 32, 40, 128, 200, 256, 500, 512, etc. The data bit number conversion circuit 100 includes n computing units 101, 8 computing units in this case. Here, the first calculation unit 101 receives the input signal X0 and the conversion factor CE, and after calculation, outputs the 8th bit of Y, i.e., Y[7] and X1; the second calculation unit 101 receives the input signal X1 and the conversion factor CE, and after calculation, outputs the 7th bit of Y, i.e., Y[6] and X2; and so on, until all the bits of Y, i.e., Y[0] to Y[7], are obtained. Figure 1 It can be seen that the output Y is an 8-bit binary number. X0 is converted from a 16-bit binary number to an 8-bit binary number Y.

[0081] In a preferred embodiment, the data bit number conversion circuit 100 according to the present invention includes only a single calculation unit, wherein the calculation unit is configured to perform n calculations, and the input data X in each calculation is the result of the previous calculation, and each calculation outputs one bit of Y. In the preferred embodiment, the data bit number conversion circuit 100 according to the present invention further includes a controller (not shown), which is configured to increment i by 1 after the calculation unit completes each calculation and output the input data X of the calculation unit. iThe controller may include a counter and a temporary register (such as a latch, etc.). Thus, the maximum utilization of the computing unit can be achieved, thereby minimizing the chip area. However, compared with the solution with n computing units, this solution has a longer delay time because the next X0 can only be input after all n calculations are completed; in the case of n computing units, X0 can be continuously input for each calculation and the corresponding results can be obtained continuously.

[0082] Figure 2 FIG. 1 is a circuit diagram showing a calculation unit 101 of a data bit number conversion circuit 100 according to the present invention.

[0083] like Figure 2 As shown, each data bit conversion circuit 100 includes the following components:

[0084] A shifter (not shown) configured to shift the conversion factor CE to the right by i bits, where CE is an integer and CE≤2 m -1, i∈[1,2,...8]. In this embodiment, each computing unit has a shifter, but in other embodiments, all computing units can share a single shifter.

[0085] Multiplexer 202, whose first input terminal (1) inputs input data X i-1 The multiplexer is connected to the first input terminal (+) of the subtractor, the second input terminal (0) of the multiplexer is connected to the difference output terminal (S) of the subtractor, the control input terminal of the multiplexer is connected to the sign output terminal (C) of the subtractor, and the selection output terminal of the multiplexer outputs the input data X. i The multiplexer is preferably a 2-way multiplexer, that is, it selectively outputs one of the two input terminals according to the signal (0 or 1) of the control input.

[0086] A subtractor 201, whose second input terminal (-) is connected to the output terminal of the shifter, and whose sign output terminal (C) outputs the ni-th bit of the output data Y. The subtractor 201 is configured to subtract the data of the first output terminal from the second output segment, and output the difference and the sign bit.

[0087] Figure 4 The application of the solution according to the present invention in the field of neural networks is shown.

[0088] like Figure 4As shown, the neural network 400 includes an input layer 401, a hidden layer 402 and an output layer 403. The neural network 400 can be implemented by software, hardware or a combination thereof. The input layer 401 includes three neural units 401a-401c, the hidden layer 402 includes four neural units 402a-402d, and the output layer package 403 includes two neural units 403a-403b. It should be noted here that the number of layers and the number of neural units are only schematic, and in other embodiments, there may be different numbers of layers and neural units. In the neural network 400, each neural unit performs weighted summation on multiple output data from multiple neural units in the previous layer, that is, each output data is multiplied by a certain coefficient and then summed, which results in: the number of bits of each output result increases compared with the number of bits of the input result, which requires additional software or hardware overhead to process the data with increased bits. In order to avoid the above-mentioned overhead, the data bit conversion circuit 100 according to the present invention can be arranged between two adjacent layers, thereby converting the output results of the neural unit into a uniform number of bits, thereby saving additional overhead. Here, a plurality of data bit number conversion circuits 100 are arranged between the hidden layer 402 and the output layer 403 to convert the bit number of the output data of each neural unit 402a-402b of the hidden layer 402 into data of a uniform bit number, which is then transmitted to the neural units 403a-403b of the output layer 403.

[0089] Figure 5 The application of the solution according to the present invention in the field of in-memory computing is shown.

[0090] like Figure 5 As shown, in the application of the storage-computation integrated memory, the input data is first calculated in the in-memory calculation array or memory 501, and then amplified and / or analog-to-digital converted by the read amplifier or analog-to-digital converter 502, and the processed data is then transmitted to the shift accumulator 503. During this processing, the number of bits of the input data is likely to change, especially increase. If the number of bits of the input data is reduced, additional software or hardware overhead is required to process the data with increased bits. Here, by arranging the data bit conversion circuit 100 according to the present invention after the shift accumulator 503, the data output by the shift accumulator 503 can be converted in bit number, that is, reduced to, for example, the same number of bits as the input data. Finally, the data after the bit conversion continues to participate in subsequent operations, such as loop operations through the in-memory calculation array or memory 501.

[0091] Although some embodiments of the present invention have been described in this application document, it will be appreciated by those skilled in the art that these embodiments are merely shown as examples. Those skilled in the art may conceive of numerous variations, alternatives, and improvements under the teachings of the present invention without departing from the scope of the present invention. The appended claims are intended to define the scope of the present invention and thus cover methods and structures within the scope of these claims themselves and their equivalents.

Claims

1. A data bit number conversion circuit, wherein the input data X0 of the circuit is an m-bit binary integer, and the output data Y of the circuit is an n-bit binary integer, m and n are both natural numbers, and m>n, the circuit comprises n calculation units, which respectively calculate the n-1th bit to the 0th bit of the output data Y, wherein the i-th calculation unit of the n calculation units comprises the following components, wherein i is an integer and 1≤i≤n: A shifter configured to shift the conversion factor CE right by i bits, where CE is an integer and CE≤2 m -1, which divides CE by 2 i as a reference value Ref, wherein the conversion factor CE is the maximum possible value of the input data X0 or a value defined according to an application scenario; The first input terminal of the multiplexer receives the input data X i-1 The first input terminal of the multiplexer is connected to the difference output terminal of the subtractor, the control input terminal of the multiplexer is connected to the sign output terminal of the subtractor, and the selection output terminal of the multiplexer outputs the input data X. i ; as well as A subtractor, whose second input terminal is connected to the output terminal of the shifter, and whose sign output terminal outputs the nith bit of the output data Y, wherein the input data X i-1 Compared with the reference value Ref, and if the input data X i-1 is greater than the reference value Ref, then 1 is output as the nith bit of the output data Y and the input data X is selected i-1 As input data X i Otherwise, 0 is output as the nith bit of the output data Y and the input data X is selected. i-1 The difference between the reference value Ref is used as the input data X i .

2. The circuit of claim 1, wherein the multiplexer is a 2-way multiplexer.

3. A circuit for neural network calculation, comprising: Multiple layers, each layer includes multiple neural units; as well as The data bit number conversion circuit according to any one of claims 1 to 2, wherein the data bit number conversion circuit is configured to receive input data X0 from a neural unit of a first layer and output output data Y as input data of a neural unit of a second layer adjacent to the first layer.

4. A memory comprising the data bit number conversion circuit according to any one of claims 1 to 2.

5. A method for converting the number of bits of input data, wherein the input data X0 is an m-bit binary integer, and the output data Y is an n-bit binary integer, m and n are both natural numbers, and m>n, the method comprising the following steps: Provides a conversion factor CE, where CE is an integer and CE≤2 m -1, wherein the conversion factor CE is the maximum possible value CE of X0; and Perform n calculations to respectively calculate the n-1th bit to the 0th bit of the output data Y, wherein the i-th calculation of the n calculations comprises the following steps, wherein i is an integer and 1≤i≤n: Divide CE by 2 i As a reference value Ref; Input data X i-1 compared with a reference value Ref; and If the input data X i-1 is greater than the reference value Ref, then 1 is output as the nith bit of the output data Y and the input data X is selected i-1 As input data X i Otherwise, 0 is output as the nith bit of the output data Y and the input data X is selected. i-1 The difference between the reference value Ref is used as the input data X i .

6. The method according to claim 5, wherein the maximum possible value CE of the input data X is determined by the following steps: Set CE=2 m -1; or Set CE based on experience, where CE<2 m -1; or Determine the maximum possible value of the input data X according to the previous and next circuits as CE, where CE<2 m -1.

7. The method according to claim 5, wherein the input data X i-1 The comparison with the reference value Ref includes: Input data X i-1 Subtract from the reference value Ref to obtain the difference and the sign bit; as well as Determine X based on the sign bit i-1 Is it greater than the reference value Ref? 8. The method according to claim 5, wherein CE is divided by 2 i The reference value Ref includes: Shift CE right by i bits to obtain the reference value Ref.

9. A method for converting the number of bits of input data in a neural network, wherein the neural network comprises a plurality of layers, each layer comprising a plurality of neural units, the method comprising the following steps: Receive input data X0 from the neural unit of the first layer; Determine the maximum possible value CE of the input data X0, where CE≤2 m -1; Perform n calculations to respectively calculate the n-1th bit to the 0th bit of the output data Y, wherein the i-th calculation of the n calculations comprises the following steps, wherein i is an integer and 1≤i≤n: Divide CE by 2 i As a reference value Ref; Input data X i-1 compared with a reference value Ref; and If the input data X i-1 is greater than the reference value Ref, then 1 is output as the nith bit of the output data Y and the input data X is selected i-1 As input data X i Otherwise, 0 is output as the nith bit of the output data Y and the input data X is selected. i-1 The difference between the reference value Ref is used as the input data X i ;as well as The output data Y is output to the neural units of the second layer adjacent to the first layer.

10. The method according to claim 9, wherein the input data X0 is the sum of output data D of multiple neural units in the first layer, and the number of bits of the output data D is n.

11. A data bit number conversion circuit, wherein the input data X0 of the circuit is an m-bit binary integer, and the output data Y of the circuit is an n-bit binary integer, m and n are both natural numbers, and m>n, the circuit comprising: One or more computing units, which calculate the n-1th bit to the 0th bit of the output data Y, wherein each computing unit includes the following components: A shifter configured to shift the conversion factor CE right by i bits, where CE is an integer and CE≤2 m -1, where i is an integer and 1≤i≤n, where CE is divided by 2 i as a reference value Ref, wherein the conversion factor CE is the maximum possible value of the input data X0 or a value defined according to an application scenario; The first input terminal of the multiplexer receives the input data X i-1 The first input terminal of the multiplexer is connected to the difference output terminal of the subtractor, the control input terminal of the multiplexer is connected to the sign output terminal of the subtractor, and the selection output terminal of the multiplexer outputs the input data X. i ; as well as The subtractor has a second input terminal connected to the output terminal of the shifter, and the sign output terminal of the subtractor outputs the nith bit of the output data Y, wherein the input data X i-1 Compared with the reference value Ref, and if the input data X i-1 is greater than the reference value Ref, then 1 is output as the nith bit of the output data Y and the input data X is selected i-1 As input data X i Otherwise, 0 is output as the nith bit of the output data Y and the input data X is selected. i-1 The difference between the reference value Ref is used as the input data X i ; A controller configured to increment i by 1 after each calculation by the calculation unit and to output the input data X of the calculation unit. i sent to the computing unit.

12. The circuit of claim 11, wherein the controller comprises: a counter configured to be incremented by 1 each time the calculation unit completes calculation and to be reset after reaching an upper limit value n; as well as A register configured to store input data X output by a computing unit i And it is transmitted to the computing unit during the next calculation of the computing unit.

Citation Information

Patent Citations

  • Variable length fft system and method

    CN101340414A

  • Conversion method of electric voltage identification code and computer system

    CN101452332A

  • Energy-saving switch switching circuit suitable for low-voltage SAR ADC design and method of energy-saving switch switching circuit

    CN110995269A

  • Device for transforming numbers from decimal to binary notation scale

    RU2248094C2