Bit reverse shifting method, device, processor and electronic device

By exOR operation of the shift control signal and the bit inversion control signal in a computer and input it to the inverse butterfly network, the bit inversion and cyclic shift results are directly obtained, and the median bit inversion and shift are solved in the prior art. The problem of long-term operation is achieved efficient parallel computing.

CN115276958BActive Publication Date: 2024-11-19ARM TECH CHINA CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210839927.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-18
Publication Date
2024-11-19
Estimated Expiration
2042-07-18

AI Technical Summary

Technical Problem

The operations used for digital inversion and shifting of data in existing computers take a long time and are serial operations, which affects the calculation efficiency.

Method used

By exOR operation of the shift control signal and the bit inversion control signal, inputting it into the inverse butterfly network, the result of bit inversion and cyclic shift is directly obtained, avoiding the permutation and shift circuit operation in the traditional method, and realizing parallel computing.

Benefits of technology

It improves computing efficiency, reduces the time-consuming operation of computer binary digital inversion and shifting of data, and improves the operation speed of computers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115276958B_ABST
    Figure CN115276958B_ABST
Patent Text Reader

Abstract

The present application relates to the field of computers, and discloses a bit reversal shifting method, device, processor, and electronic device. The method comprises: obtaining data to be processed; generating a shift control signal according to the shift type and the number of shift bits of the data to be processed, and generating a bit reversal control signal according to the number of bits of the data to be processed; performing an XOR operation on the shift control signal and the bit reversal control signal to obtain a bit reversal shifting control signal; inputting the bit reversal shifting control signal and the data to be processed into an inverse butterfly network to obtain a result of bit reversal and circular shifting of the data to be processed; post-processing the result of bit reversal and circular shifting to obtain a result of bit reversal and shifting of the data to be processed. Therefore, the computer can perform bit reversal and shifting operations on the binary number of the data in parallel, thereby improving the computing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to a bit inversion shifting method, device, processor and electronic equipment. Background Art

[0002] The operation of bit reversing and shifting a binary number of data is a commonly used operation in computers. For example, the VBRSR instruction is an instruction to bit-reverse and right-shift a binary number of data. It is used in cryptography, digital signal processing, image processing, etc.

[0003] At present, the computing unit in the computer used to implement the bit reversal and shift operation on the binary number of data usually first exchanges the positions of the digits in the binary number to be calculated through a permutation circuit, completes the bit reversal operation on the binary number, and then shifts the bit-reversed binary number through a shift circuit to obtain the final calculation result. In this way, the computing unit performs the bit reversal and shift operation on the binary number of data serially, and the calculation takes a long time. Summary of the invention

[0004] In view of this, the embodiments of the present application provide a bit reversal and shifting method, device, processor and electronic device. By performing an XOR operation on a shift control signal and a bit reversal control signal to obtain a bit reversal and shift control signal, and inputting the bit reversal and shift control signal and the data to be processed into an inverse butterfly network (Inverse Butterfly Network), the result of bit reversal and circular shift of the data to be processed can be directly obtained, and then the result of bit reversal and circular shift of the processed data can be obtained by post-processing the result of bit reversal and circular shift, thereby avoiding the computer from serially performing bit reversal and shift operations on the binary number of the data, thereby improving the computing efficiency.

[0005] In a first aspect, the present application provides a bit inversion shifting method, which is applied to an electronic device, comprising:

[0006] Get the data to be processed;

[0007] Generate a shift control signal according to the shift type and the number of shift bits of the data to be processed, and generate a bit reversal control signal according to the number of bits of the data to be processed;

[0008] Performing an XOR operation on the shift control signal and the bit inversion control signal to obtain a bit inversion shift control signal;

[0009] Inputting the bit inversion shift control signal and the data to be processed into the inverse butterfly network to obtain the result of bit inversion and cyclic shift of the data to be processed;

[0010] The result of the bit inversion and circular shift is post-processed according to the shift type and the shift bit number to obtain the result of the bit inversion and shift of the data to be processed.

[0011] It can be understood that by performing an XOR operation on the shift control signal and the bit reversal control signal to obtain a bit reversal shift control signal, and inputting the bit reversal shift control signal and the data to be processed into the inverse butterfly network, the result of bit reversal and circular shift of the data to be processed can be directly obtained, thereby avoiding the problem of first exchanging the positions of each number in the binary number to be calculated through permutation and other circuits, completing the bit reversal operation on the binary number, and then shifting the bit-reversed binary number through a shift circuit to obtain the final calculation result, thereby improving the calculation efficiency.

[0012] It can be understood that in some embodiments of the present application, the shift control signal is a circular shift control signal, and the bit inversion shift control signal is a bit inversion circular shift control signal. When the shift direction is left shift or circular left shift, the obtained shift control signal is a circular left shift control signal, and the corresponding bit inversion shift control signal is a bit inversion circular left shift control signal. When the shift direction is right shift or circular right shift, the obtained shift control signal is a circular right shift control signal, and the corresponding bit inversion shift control signal is a bit inversion circular right shift control signal.

[0013] It can be understood that in some embodiments of the present application, the data to be processed is input data.

[0014] In a possible implementation of the first aspect, the inverse butterfly network includes a K-level network, and the binary number of the data to be processed is 2 K The shift control signal includes K shift control signals corresponding to the K-level networks of the inverse butterfly network, and the number of bits of the shift control signal corresponding to the N-th level network of the inverse butterfly network is 2 N-1 bits, the number of shifts is H bits, the binary number corresponding to H is M, where K ≥ N; and

[0015] Generate a shift control signal according to the shift type and the number of shift bits of the data to be processed, including:

[0016] When the shift type is left shift or circular left shift, the first 2 bits of the binary number after the first signal is circularly shifted left by J bits are N-1 bits, as the shift control signal corresponding to the Nth level network of the inverse butterfly network, where the first signal is high 2 N-1 Bit is 0, low 2 N-1 Bit 1 of 2 N The binary number of M is 1, and J is the decimal number corresponding to the last N digits of M.

[0017] When the shift type is right shift or circular right shift, the first 2 bits of the binary number after the first signal is circularly right shifted by J bits are N-1 The number of bits is used as the shift control signal corresponding to the Nth level network of the inverse butterfly network.

[0018] It can be understood that the inverse butterfly network is a novel circuit structure. By cyclically shifting the first signal through the shift type and shift direction, it is more convenient to obtain a shift control signal corresponding to the inverse butterfly network structure, thereby preparing for the subsequent bit reversal and cyclic shift results obtained through the inverse butterfly network.

[0019] It can be understood that in some embodiments of the present application, the first signal is a specific signal.

[0020] It can be understood that in some embodiments of the present application, the inverse butterfly network includes a 3-level network.

[0021] In a possible implementation of the first aspect, the bit reversal control signal includes K bit reversal control signals corresponding to K-level networks of the inverse butterfly network, and the number of bits of the bit reversal control signal corresponding to the N-th level network of the inverse butterfly network is 2 N-1 and

[0022] Generate a bit reversal control signal according to the number of bits of the data to be processed, including:

[0023] The second signal is set to be a bit inversion control signal corresponding to the Nth level network of the inverse butterfly network, wherein the second signal is 2 N-1 A binary number whose bits are all 1.

[0024] It can be understood that the bit inversion control signal corresponding to the inverse butterfly network can be directly and conveniently obtained through the number of bits of the data to be processed, and preparation is made for the subsequent bit inversion and cyclic shift results obtained through the inverse butterfly network.

[0025] In a possible implementation of the first aspect, the bit inversion shift control signal includes K bit inversion shift control signals corresponding to K-level networks of the inverse butterfly network respectively; and performing an XOR operation on the shift control signal and the bit inversion control signal to obtain the bit inversion shift control signal includes:

[0026] The result of performing an XOR operation on the shift control signal and the bit reversal control signal corresponding to the Nth level network of the inverse butterfly network is used as the bit reversal shift control signal corresponding to the Nth level network of the inverse butterfly network.

[0027] It can be understood that by performing bit-by-bit XOR operations on the shift control signal and the bit reversal control signal corresponding to the Nth level network of the inverse butterfly network, a control signal having bit reversal and circular shift functions for the data to be processed input to the inverse butterfly network can be obtained. This can avoid the computer serially performing bit reversal and shift operations on the binary numbers of the data, thereby improving computing efficiency.

[0028] In a possible implementation of the first aspect, post-processing the result of bit inversion and cyclic shift according to the shift type and the shift number includes:

[0029] When the shift type is left shift and the number of shift bits is H bits, the low H bits of the result of bit inversion and circular shift are set to zero;

[0030] When the shift type is right shift and the number of shift bits is H bits, the high H bits of the result of bit inversion and circular shift are set to zero;

[0031] When the shift type is circular right shift or circular left shift and the shift bit number is H bits, each bit of the result of bit inversion and circular shift remains unchanged.

[0032] It can be understood that by setting the high or low bit of the bit inversion and circular shift result to 0 according to the shift type and the shift number, the result of bit inversion and shifting the data to be processed can be easily obtained when the shift type is not circular shift.

[0033] In a possible implementation of the first aspect, when the shift type is left shift and the number of shift bits is H bits, setting the low H bits of the result of bit inversion and circular shift to zero includes:

[0034] The result of bit inversion and cyclic shift is bitwise ANDed with the first mask code, wherein the number of bits of the first mask code and the number of bits of the result of bit inversion and cyclic shift is P, and the low H bit of the first mask code is 0 and the high PH bit is 1.

[0035] It can be understood that when the shift type is left shift and the shift bit number is H bits, the result of bit inversion and circular shift can be easily obtained by performing a bitwise AND operation on the result of bit inversion and circular shift with the first mask code, which is easy to operate.

[0036] In a possible implementation of the first aspect, when the shift type is right shift and the number of shift bits is H bits, setting high H bits of the result of bit inversion and circular shift to zero includes:

[0037] The result of bit inversion and cyclic shift is bitwise ANDed with the second mask code, wherein the number of bits of the second mask code and the number of bits of the result of bit inversion and cyclic shift is Q, and the high H bit of the second mask code is 0 and the low QH bit is 0.

[0038] It can be understood that when the shift type is right shift and the shift bit number is H bits, the result of bit inversion and circular shift can be easily obtained by performing a bitwise AND operation on the result of bit inversion and circular shift with the second mask code, which is easy to operate.

[0039] In a second aspect, the present application provides a bit inversion shifting device, comprising:

[0040] A control signal generating unit, used to generate a shift control signal according to the shift type and the number of shift bits of the data to be processed, and to generate a bit reversal control signal according to the number of bits of the data to be processed, and to perform an XOR operation on the shift control signal and the bit reversal control signal to obtain a bit reversal shift control signal;

[0041] An inverse butterfly network is used to obtain the result of bit inversion and cyclic shift of the data to be processed according to the bit inversion shift control signal and the data to be processed;

[0042] The post-processing unit is used to post-process the result of bit inversion and circular shift according to the shift type and the shift bit number to obtain the result of bit inversion and shift of the data to be processed.

[0043] It can be understood that the bit reversal and shifting device provided by the present application is a parallel device that can realize various bit reversal and shifting operations of bit data. The original method of first completing the bit reversal calculation of the binary number through permutation circuits and then completing the shifting operation of the bit-reversed binary number through circular shift-related circuits is changed to using bit reversal and shift-related circuits to realize the bit reversal and shifting operations of the binary number, which can reduce calculation time and improve the running speed of the computer.

[0044] It can be understood that in some embodiments of the present application, when the shift direction is left shift, the obtained shift control signal is a circular left shift control signal, and the corresponding bit-reversed shift control signal is a bit-reversed circular left shift control signal; when the shift direction is right shift, the obtained shift control signal is a circular right shift control signal, and the corresponding bit-reversed shift control signal is a bit-reversed circular right shift control signal.

[0045] It can be understood that in some embodiments of the present application, the data to be processed is input data.

[0046] It can be understood that in some embodiments of the present application, the inverse butterfly network is an inverse butterfly network unit.

[0047] In a possible implementation of the second aspect, the inverse butterfly network includes a K-level network, and the binary number of the data to be processed is 2 K The shift control signal includes K shift control signals corresponding to the K-level networks of the inverse butterfly network, and the number of bits of the shift control signal corresponding to the N-th level network of the inverse butterfly network is 2 N-1 bits, the number of shifts is H bits, the binary number corresponding to H is M, where K ≥ N; and

[0048] The control signal generating unit generates a shift control signal according to the shift type and the shift bit number of the data to be processed in the following manner:

[0049] When the shift type is left shift or circular left shift, the control signal generating unit shifts the first 2 bits of the binary number of the first signal circularly left by J bits. N-1 bits, as the shift control signal corresponding to the Nth level network of the inverse butterfly network, where the first signal is high 2 N-1 Bit is 0, low 2 N-1 Bit 1 of 2 N The binary number of M is 1, and J is the decimal number corresponding to the last N digits of M.

[0050] When the shift type is right shift or circular right shift, the control signal generating unit shifts the first 2 bits of the binary number of the first signal circularly right shifted by J bits. N-1 The number of bits is used as the shift control signal corresponding to the Nth level network of the inverse butterfly network.

[0051] It can be understood that the inverse butterfly network is a novel circuit structure. By cyclically shifting the first signal through the shift type and shift direction, it is more convenient to obtain a shift control signal corresponding to the inverse butterfly network structure, thereby preparing for the subsequent bit reversal and cyclic shift results obtained through the inverse butterfly network.

[0052] It can be understood that in some embodiments of the present application, the first signal is a specific signal.

[0053] It can be understood that in some embodiments of the present application, the inverse butterfly network includes a 3-level network.

[0054] In a possible implementation of the second aspect, the bit reversal control signal includes K bit reversal control signals corresponding to the K-level networks of the inverse butterfly network, and the number of bits of the bit reversal control signal corresponding to the N-th level network of the inverse butterfly network is 2 N-1 and

[0055] The control signal generating unit generates a bit inversion control signal according to the number of bits of the data to be processed in the following manner:

[0056] The control signal generating unit sets the second signal to be a bit inversion control signal corresponding to the Nth level network of the inverse butterfly network, wherein the second signal is 2 N-1 A binary number whose bits are all 1.

[0057] It can be understood that the control signal generating unit can directly and conveniently obtain the bit reversal control signal corresponding to the inverse butterfly network through the number of bits of the data to be processed, and prepare for the subsequent bit reversal and cyclic shift results obtained through the inverse butterfly network.

[0058] In a possible implementation of the second aspect, the bit inversion shift control signal includes K bit inversion shift control signals corresponding to the K-level networks of the inverse butterfly network respectively; and the control signal generation unit performs an XOR operation on the shift control signal and the bit inversion control signal to obtain the bit inversion shift control signal in the following manner:

[0059] The control signal generating unit performs bit-wise XOR operation on the shift control signal and the bit reversal control signal corresponding to the Nth level network of the inverse butterfly network as the bit reversal shift control signal corresponding to the Nth level network of the inverse butterfly network.

[0060] It can be understood that the control signal generating unit can obtain a control signal with bit inversion and cyclic shift functions for the to-be-processed data input to the inverse butterfly network by performing bit-by-bit XOR operations on the shift control signal and the bit inversion control signal corresponding to the Nth level network of the inverse butterfly network, thereby avoiding the computer from serially performing bit inversion and shift operations on the binary numbers of the data, thereby improving the calculation efficiency. This method can be extended to XORing a plurality of control signals that implement different functions to generate a control signal with bit inversion and cyclic shift functions, as long as a plurality of bit inversion control signals and cyclic shift control signals are XORed to generate a control signal with corresponding bit inversion and cyclic shift functions.

[0061] In a possible implementation of the second aspect, the number of shift bits is H bits, the number of bits of the result of bit inversion and cyclic shift is Y bits; and

[0062] The post-processing unit post-processes the result of the bit-reversal and circular shift according to the shift type and the number of shift bits in the following way:

[0063] When the shift type is left shift, the bit inversion and circular shift result is bitwise ANDed with the first mask code to obtain the bit inversion and shift result, wherein the number of bits of the first mask code is Y, and the low H bits of the first mask code are 0, and the high YH bits are 1;

[0064] When the shift type is right shift, the bit inversion and circular shift result is bitwise ANDed with the second mask code to obtain the bit inversion and shift result, wherein the number of bits of the second mask code is Y, the high H bits of the second mask code are 0, and the low YH bits are 1;

[0065] When the shift type is circular right shift or circular left shift, the result of bit inversion and circular shift is bitwise ANDed with the third mask code to obtain the result of bit inversion and shift, wherein the number of bits of the third mask code is Y, and all bits of the third mask code are 1.

[0066] It can be understood that the post-processing unit can easily obtain the result of bit reversing and shifting the data to be processed by phase ANDing the result of bit reversing and cyclic shifting with the mask code corresponding to the shift type and the shift number under different shift types and shift number conditions.

[0067] In a third aspect, the present application provides a processor, comprising the bit inversion shifting device of the second aspect and any one of the possible implementations of the second aspect.

[0068] In a fourth aspect, the present application provides an electronic device comprising the processor of the third aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0069] Figure 1 According to some embodiments of the present application, a schematic diagram of the structure of an inverse butterfly network is shown;

[0070] Figure 2 According to some embodiments of the present application, a bit inversion shifting device 200 is shown;

[0071] Figure 3A According to some embodiments of the present application, a control signal generating unit 202 is shown;

[0072] Figure 3B According to some embodiments of the present application, a data flow schematic diagram of bit-reversing input data of an inverse butterfly network using a bit-reversal control signal is shown;

[0073] Figure 3C According to some embodiments of the present application, a data flow schematic diagram of cyclically right-shifting input data of an inverse butterfly network using a cyclic right-shift control signal is shown;

[0074] Figure 3D According to some embodiments of the present application, a data flow schematic diagram of cyclically left-shifting input data of an inverse butterfly network using a cyclic left-shift control signal is shown;

[0075] Figure 3EAccording to some embodiments of the present application, a data flow schematic diagram of bit-reversing and cyclically right-shifting input data of an inverse butterfly network using a bit-reversing cyclic right-shift control signal is shown;

[0076] Figure 3F According to some embodiments of the present application, a data flow schematic diagram of bit-reversing and cyclically left-shifting input data of an inverse butterfly network using a bit-reversing cyclic left-shift control signal is shown;

[0077] Figure 4A According to some embodiments of the present application, a schematic diagram of the structure of a post-processing unit 204 is shown;

[0078] Figure 4B According to some embodiments of the present application, a mask code corresponding to a shift bit number between 0 and 7 is shown;

[0079] Figure 5 According to some embodiments of the present application, a flow chart of a method for bit-reversing data is shown;

[0080] Figure 6 According to some embodiments of the present application, a schematic structural diagram of an electronic device 100 is shown. DETAILED DESCRIPTION

[0081] Illustrative embodiments of the present application include, but are not limited to, bit-reversal shifting methods, apparatuses, processors, and electronic devices.

[0082] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the embodiment of the present application is further described in detail below in combination with the accompanying drawings and implementation schemes. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0083] In order to more clearly illustrate the solutions of the embodiments of the present application, some terms involved in the embodiments of the present application are explained below.

[0084] 1. Shift operation:

[0085] There are four types of shifts: left shift, right shift, circular left shift, and circular right shift.

[0086] Specifically, left shift means that all binary bits of a number are shifted to the left by a specified number of bits, and the vacant bits on the right are filled with 0. If the high bits overflow, the high bits are discarded. For example, if the binary number 00001111 with a bit width of 8 is shifted to the left by 1 bit, 00011110 is obtained, and the vacant bits on the right are filled with 0.

[0087] Right shift is to shift all the binary bits of a number right by a specified number of bits, fill the vacant bits on the left with 0, and discard the low bits if the right shift overflows. For example, if the binary number 00001111 with a bit width of 8 is shifted right by 1 bit, 00000111 is obtained, and the vacant bits on the left are filled with 0.

[0088] Circular left shift is to shift all the binary bits of a number to the left by a specified number of bits, and put the high bits shifted out to the low bits of the number. For example, if the binary number 10001111 with a bit width of 8 is circularly shifted to the left by 1 bit, 00011111 will be obtained.

[0089] Circular right shift is to shift all the binary bits of a number right by a specified number of bits, and put the shifted low bits into the high bits of the number. For example, if the binary number 10001111 with a bit width of 8 is circularly shifted right by 1 bit, the result is 11000111.

[0090] 2. Bit reversal operation

[0091] The bit reversal operation is to swap the high and low bits of a binary number. For example, for a binary number 10001111 with a bit width of 8, the 0th and 7th bits, the 1st and 6th bits, the 2nd and 5th bits, and the 3rd and 4th bits of the number are swapped to get 11110001.

[0092] 3. Bit reversal and shift operation

[0093] The bit reversal and shift operation swaps the high and low bits of a number's binary bits and then shifts the number left or right by a specified number of bits.

[0094] 4. Inverse Butterfly Network:

[0095] The inverse butterfly network is a novel circuit structure that can rearrange the positions of the digits in the binary number of the input data according to the control signal input to the network to obtain binary output data. The output data contains the same digits as the input data, but the arrangement order of the digits is different.

[0096] To facilitate understanding, we first introduce the logic of the inverse butterfly network adjusting the arrangement order of each digit in the input binary number according to the control signal.

[0097] The inverse butterfly network is a multi-level network. For a K-level inverse butterfly network, the input of the first-level network is the input of the inverse butterfly network, and the input of the Nth (K≥N≥2)-level network is the output of the N-1th-level network. K Rearrange the order of the digits in a binary number.

[0098] It can be understood that the control signal of the Nth level network is 2 N-1 The Nth (K≥N≥1) level network divides the input data of this level network into 2 K-N sub-butterfly networks (clusters), each cluster includes 2 N digits, and the first 2 N-1 The first digit is the first subcluster, the last 2 N-1 The first digit of the control signal is the second sub-cluster. After receiving the control signal, the N-th level network adjusts the position of the first digit of the first sub-cluster and the second digit of the second sub-cluster in each cluster according to the value of the ith digit of the control signal. Specifically, if the ith digit of the control signal is a binary number 1, the ith digit of the first sub-cluster and the ith digit of the second sub-cluster in each cluster are exchanged; if the ith digit of the control signal is a binary number 0, the ith digit of the first sub-cluster and the ith digit of the second sub-cluster in each cluster remain unchanged.

[0099] For example, Figure 1 As shown, for a 3-level inverse butterfly network, the order of the digits in an 8-bit binary number can be rearranged.

[0100] refer to Figure 1 , the second-level network divides the input data into 2 sub-networks (clusters), each cluster includes 4 digits, and the first 2 digits of each cluster are the first sub-cluster, and the last 2 digits are the second sub-cluster. The control signal of the second-level network is a 2-bit binary number, for example, 2'b10 ("b" refers to binary, and the 2 in front of "b" represents the bit width of the binary number after "b", that is, 2'b10 represents the binary number 10 with a bit width of 2). And the input of the second-level network is the output of the first-level network. After the second-level network receives the control signal 2'b10, the value of the 0th bit of the control signal is 0, then the 0th bit in the first sub-cluster and the 0th bit in the second sub-cluster in each cluster remain unchanged, that is Figure 1 The 0th digit a7 in the first sub-cluster and the 0th digit a5 in the second sub-cluster remain unchanged; according to the value of the first digit of the control signal being 1, the first digit in the first sub-cluster and the first digit in the second sub-cluster in each cluster are exchanged, that is, Figure 1 The first digit a6 in the first subcluster is swapped with the first digit a4 in the second subcluster.

[0101] In this way, by inputting different control signals to each level of the inverse butterfly network, the arrangement order of each number in the input data input to the inverse butterfly network can be adjusted.

[0102] The scheme of the embodiment of the present application is described below in conjunction with the drawings.

[0103] As mentioned above, the bit reversal and shift operation is usually calculated by serial calculation at present. In order to improve the calculation efficiency of bit reversal and shift, the embodiment of the present application provides a bit reversal shift device, which uses an inverse butterfly network to complete the operation of bit reversal and shifting of input data, so that the bit reversal and shift operation can be performed in parallel, which improves the speed of bit reversal and shifting. The device first determines the control signal corresponding to the shift type and the shift number according to the type of shift and the number of shifts, and then inputs the input data and the control signal into the inverse butterfly network, so as to obtain the result of bit reversal and circular shift of the input data. Then, according to the type of shift and the number of shifts, the result of the inverse butterfly network output is post-processed to obtain the calculation result of bit reversal and shift. For example, when the shift operation is not a circular shift, the device sets the high or low bit of the inverse butterfly network output result to zero according to the direction of the shift, so as to obtain the result of bit reversal and shift of the output data.

[0104] In this way, the present application transforms the traditional serial structure for bit reversal and shifting of input data into a parallel structure, which shortens the calculation time and improves the computer's operating speed; the inverse butterfly network has a simple structure, can reduce the circuit area, and the structure is easy to expand, and is very suitable for application to other operations of expandable vectors; this structure can be easily integrated with other shift instructions, for example, bit reversal and shift operations of different shift types can be executed in parallel, so that all simple shift operations can be realized by the bit reversal and shifting device of the present application.

[0105] Specifically, Figure 2 A bit inversion shifting device 200 in some embodiments of the present application is shown. The device comprises a data acquisition unit 201, a control signal generation unit 202, an inverse butterfly network unit 203 and a post-processing unit 204.

[0106] The data acquisition unit 201 is used to acquire input parameters, including input data that needs to be bit-reversed and shifted, a shift type, and a shift number, and sends the shift type and the shift number in the input parameters to the control signal generation unit 202 and the post-processing unit 204, and sends the input data to the inverse butterfly network unit 203;

[0107] The control signal generating unit 202 is used to obtain a control signal according to the shift type and the number of shifts given by the data acquisition unit 201, and send the control signal to the inverse butterfly network unit 203. The control signal is used to control the input data of the inverse butterfly network unit 203 to realize the functions of bit inversion and shifting. For example, it is used to obtain a control signal with a bit inversion and cyclic shift function (hereinafter referred to as a bit inversion cyclic shift control signal) according to the received shift type and the number of shifts, and send the bit inversion cyclic shift control signal to the inverse butterfly network unit 203, so that the input data of the inverse butterfly network unit 203 realizes the function of bit inversion and cyclic shift. The generation logic of the bit inversion cyclic shift control signal will be introduced below, and will not be repeated here.

[0108] The inverse butterfly network unit 203 is used to receive the control signal given by the control signal generating unit 202, and rearrange the positions of the digits in the binary number of the input data given by the data acquiring unit 201 according to the acquired control signal, obtain an intermediate calculation result, and provide the intermediate calculation result to the post-processing unit 204. For example, when the control signal is a bit inversion cyclic shift control signal, the inverse butterfly network unit 203 exchanges the high and low digits in the binary number of the input data according to the acquired bit inversion cyclic shift control signal, and cyclically shifts the exchanged result to obtain a bit inversion and cyclic shift result, and provides the bit inversion and cyclic shift result to the post-processing unit 204.

[0109] The post-processing unit 204 is used to post-process the intermediate calculation result given by the inverse butterfly network unit 203 according to the shift type and the number of shifts given by the data acquisition unit 201, and obtain the output result. Specifically, when the shift type is right shift, the post-processing unit 204 sets the high position of the intermediate calculation result to 0 according to the number of shifts; when the shift type is left shift, the post-processing unit 204 sets the low position of the intermediate calculation result to 0 according to the number of shifts, and when the shift type is circular right shift or circular left shift, the output result is the intermediate calculation result. In some embodiments, the mask code obtained according to the shift type and the number of shifts can be post-processed by bitwise ANDing with the intermediate calculation result to obtain the output result. For example, when the intermediate calculation result is a bit-reversed and circularly shifted result, when the shift operation is not a circular shift, the corresponding mask code is obtained according to the shift type and the number of shifts, and the high or low bit of the bit-reversed and circularly shifted result is set to 0 according to the bitwise ANDing method of the mask code and the bit-reversed and circularly shifted result to obtain the bit-reversed and shifted result.

[0110] It can be understood that the parallel bit reversal and shifting device provided by the present application can realize various bit reversal and shifting operations of bit data. The original method of first completing the bit reversal calculation of the binary number through permutation circuits and then completing the shifting operation of the bit-reversed binary number through circular shift-related circuits is changed to a method of completing the bit reversal and shifting operations of the binary number through bit reversal and shift-related circuits, which can reduce the calculation time, improve the computer's operating speed, and is simple to operate.

[0111] The logic of the control signal generating unit 202 generating the bit inversion and circular shift control signal is described below.

[0112] like Figure 3A As shown, the control signal generating unit 202 includes a bit inversion control signal generating unit 202a, a cyclic shift control signal generating unit 202b and a control signal XOR unit 202c.

[0113] Specifically, the bit reversal control signal generating unit 202a is used to generate the bit reversal control signal corresponding to each level of the inverse butterfly network. The value of each bit on the bit reversal control signal corresponding to each level of the inverse butterfly network is a binary number 1. For example, for a 3-level inverse butterfly network, the first-level bit reversal control signal is a 1-bit binary number 1, that is, 1'b1, the second-level bit reversal control signal is a 2-bit binary number 11, that is, 2'b11, and the third-level bit reversal control signal is a 4-bit binary number 1111, that is, 4'b1111.

[0114] The specific control process of the bit inversion control signal is introduced below. Figure 3B It shows the specific process in which the bit reversal control signal acts on the inverse butterfly network to achieve bit reversal of the 8-bit data input data of the inverse butterfly network.

[0115] For the first-level network, the input data is divided into four sub-networks (clusters), cluster1 to cluster4 ( Figure 3BOnly cluster1 is shown in the figure, the first digit of each cluster is the first sub-cluster, and the last digit is the second sub-cluster. The control signal of the first level is 1'b1, and the positions of the 0th digit in the first sub-cluster and the 0th digit in the second sub-cluster in each cluster are exchanged. For the sub-butterfly network (cluster) cluster1, the 0th digit a7 in the first sub-cluster1 and the 0th digit a6 in the second sub-cluster1 in the sub-butterfly network (cluster) cluster1 are exchanged, and the corresponding bits in the other sub-butterfly networks (clusters) of the first level are also exchanged under the control signal, that is, the data a5 and a4 in cluster2 are exchanged, the data a3 and a2 in cluster3 are exchanged, and the data a1 and a0 in cluster4 are exchanged, and the output data of the first level are a6, a7, a4, a5, a2, a3, a0, a1.

[0116] For the second-level network, the input data is divided into two sub-networks (clusters), cluster1' and cluster2' ( Figure 3B Only cluster1' is shown in the figure, the first two digits of each cluster are the first sub-cluster, and the last two digits are the second sub-cluster. The control signal of the second stage is 2'b11, and the positions of the 0th digit in the first sub-cluster and the 0th digit in the second sub-cluster in each cluster are swapped, and the positions of the 1st digit in the first sub-cluster and the 1st digit in the second sub-cluster are swapped. For the sub-butterfly network (cluster) cluster1', the 0th bit a7 in the first sub-cluster1' and the 0th bit a5 in the second sub-cluster1' in the sub-butterfly network (cluster) cluster1' are exchanged, and the 1st bit a6 in the first sub-cluster1' and the 1st bit a4 in the second sub-cluster1' are exchanged; under the control signal, the corresponding bits in the other sub-clusters (clusters) of the second level are also exchanged, that is, the data a3 and a1 in cluster2' are exchanged, and the data a2 and a0 are exchanged; finally, the output data of the second level is a4, a5, a6, a7, a0, a1, a2, a3.

[0117] For the third-level network, the input data is divided into one sub-butterfly network (cluster), denoted as cluster1. The first 4 digits of each cluster are the first sub-cluster, and the last 2 digits are the second sub-cluster. The control signal of the third level is 4'b1111. The positions of the 0th digit in the first sub-cluster and the 0th digit in the second sub-cluster are swapped, the positions of the 1st digit in the first sub-cluster and the 1st digit in the second sub-cluster are swapped, the positions of the 2nd digit in the first sub-cluster and the 2nd digit in the second sub-cluster are swapped, the positions of the 3rd digit in the first sub-cluster and the 3rd digit in the second sub-cluster are swapped, and the positions of the 4th digit in the first sub-cluster and the 3rd digit in the second sub-cluster are swapped. For the butterfly network (cluster) cluster1", the 0th digit a7 in the first sub-cluster1" and the 0th digit a3 in the second sub-cluster1" in the butterfly network (cluster) cluster1" are exchanged, the 1st digit a6 in the first sub-cluster1" and the 1st digit a2 in the second sub-cluster1" are exchanged, the 2nd digit a5 in the first sub-cluster1" and the 2nd digit a1 in the second sub-cluster1" are exchanged, the 3rd digit a4 in the first sub-cluster1" and the 3rd digit a0 in the second sub-cluster1" are exchanged, and the output data a0, a1, a2, a3, a4, a5, a6, a7 of the third level are obtained.

[0118] That is to say, for an N-bit binary number, the inverse butterfly network can reverse the input data through a log2(N)-level network, and the control signal of the i-th level is 2 i-1 The bit inversion control signal generating unit 202a generates a binary signal with all bits 1. By using this control signal, the inverse butterfly network can achieve bit inversion of the input data. Therefore, the bit inversion control signal generated by the bit inversion control signal generating unit 202a can achieve bit inversion of the input data in the inverse butterfly network.

[0119] The cyclic shift control signal generating unit 202b is used to generate the bit cyclic shift control signal corresponding to each stage of the inverse butterfly network.

[0120] The following is an introduction to the cyclic shift control signal.

[0121] Assuming that the inverse butterfly network is a K-level network, the binary numbers input to the network include 2 K bit number, then the number of bits of the control signal of the Nth level is 2 N-1 If the binary number corresponding to the number of bits shifted is M, the control signal of the Nth level can be obtained in the following way: a.2 NA specific signal of a bit binary number (where the specific signal is high by 2 N-1 Bit is 0, low 2 N-1 b. Circularly shift left (operation instruction is circular left shift) or circularly shift right (operation instruction is circular right shift) by J bits (J is the decimal number corresponding to the last N bits of M) to obtain the intermediate control signal P; b. N-1 bit as the control signal for the Nth stage.

[0122] For example, taking a 5-bit circular right shift and a 3-level inverse butterfly network as an example, the binary number input to the network includes 8 digits. If you want to circularly shift 5 bits, you only need to generate a control signal for a 5-bit circular right shift. The binary number corresponding to the 5-bit circular right shift is 3'b101.

[0123] like Figure 3C As shown, the specific signal corresponding to the first stage is a 2-bit binary number 01, that is, 2'b01. The specific signal 2'b01 is cyclically shifted right by 1 bit, where the right shift "1 bit" is the decimal number corresponding to the lowest binary number 1 in 3'b101, 2'b01>>>1'b1=2'b10 (">>>" represents cyclic right shift). The high 1-bit data of the result of the cyclic right shift of the specific signal is selected as the cyclic right shift control signal of the first stage, that is, the cyclic right shift control signal of the first stage is 1'b1; the specific signal corresponding to the second stage is 4'b0011, and the specific signal 4'b0011 is cyclically shifted right by 1 bit, that is, the lowest 2 bits "01" of the binary number 3'b101 corresponding to the number of shifted bits, 4'b0011>>>2'b01=4'b1001, the high 2 bits of the result of the circular right shift of the specific signal are selected as the circular right shift control signal of the second stage, that is, the circular right shift control signal of the second stage is 2'b10; the specific signal corresponding to the third stage is 8'b00001111, the specific signal 8'b00001111 is circularly shifted right by 5 bits, that is, the corresponding shift bit number 3'b101 value, 8'b00001111>>>3'b101=8'b01111000, the high 4 bits of the result of the circular right shift of the specific signal are selected as the circular right shift control signal of the third stage, that is, the circular right shift control signal of the third stage is 4'b0111.

[0124] The following takes the effect of the above-obtained 5-bit cyclic right shift control signal on the inverse butterfly network as an example to introduce the specific process of making the inverse butterfly network input data realize bit cyclic right shift, wherein the input data of the inverse butterfly network takes 8-bit data as an example.

[0125] like Figure 3C As shown in the figure, for the first-level network, the input data is divided into four sub-butterfly networks (clusters), namely cluster1 to cluster4 ( Figure 3COnly cluster1 is shown in the figure. The first digit of each cluster is the first sub-cluster, and the last digit is the second sub-cluster. The control signal of the first level is 1'b1. The positions of the 0th digit in the first sub-cluster and the 0th digit in the second sub-cluster in each cluster are exchanged. For the sub-butterfly network (cluster) cluster1, the 0th digit a7 in the first sub-cluster1 and the 0th digit a6 in the second sub-cluster1 in the sub-butterfly network (cluster) cluster1 are exchanged. Under the control signal, the corresponding bits in each sub-cluster of other sub-butterfly networks (clusters) of the first level are also exchanged, that is, the data a5 and a4 in cluster2 are exchanged, the data a3 and a2 in cluster3 are exchanged, and the data a1 and a0 in cluster4 are exchanged, and the output data of the first level are a6, a7, a4, a5, a2, a3, a0, a1.

[0126] For the second-level network, the input data is divided into two sub-networks (clusters), cluster1' and cluster2' ( Figure 3C Only cluster1' is shown in the figure. The first two digits of each cluster are the first sub-cluster, and the last two digits are the second sub-cluster. The control signal of the second level is 2'b10. The numbers at the positions of the 0th digit in the first sub-cluster and the 0th digit in the second sub-cluster in each cluster remain unchanged, and the numbers at the positions of the 1st digit in the first sub-cluster and the 1st digit in the second sub-cluster are exchanged. For the sub-butterfly network (cluster) cluster1', the 0th digit a7 in the first sub-cluster1' and the 0th digit a5 in the second sub-cluster1' in the sub-butterfly network (cluster) cluster1' remain unchanged, and the 1st digit a6 in the first sub-cluster1' and the 1st digit a4 in the second sub-cluster1' are exchanged; for the other sub-butterfly networks (clusters) of the second level, under the control signal, the data a3 and a1 in cluster2' remain unchanged, and the data a2 and a0 are exchanged; finally, the output data of the second level are a4, a7, a6, a5, a0, a3, a2, a1.

[0127] For the third-level network, the input data is divided into 1 sub-butterfly network (cluster) cluster, which is cluster1. The first 4 digits of each cluster are the first sub-cluster, and the last 2 digits are the second sub-cluster. The control signal of the third level is 4'b0111. The positions of the 0th digit in the first sub-cluster and the 0th digit in the second sub-cluster are swapped in each cluster, the 1st digit in the first sub-cluster and the 1st digit in the second sub-cluster are swapped, the 2nd digit in the first sub-cluster and the 2nd digit in the second sub-cluster are swapped, the 3rd digit in the first sub-cluster and the 3rd digit in the second sub-cluster are swapped. The number of digits remains unchanged. For the butterfly network (cluster) cluster1", the 0th digit a5 in the first sub-cluster1" and the 0th digit a1 in the second sub-cluster1" in the butterfly network (cluster) cluster1" are exchanged, the 1st digit a6 in the first sub-cluster1" and the 1st digit a2 in the second sub-cluster1" are exchanged, the 2nd digit a7 in the first sub-cluster1" and the 2nd digit a3 in the second sub-cluster1" are exchanged, the 3rd digit a4 in the first sub-cluster1" and the 3rd digit a0 in the second sub-cluster1" remain unchanged, and the output data a4, a3, a2, a1, a0, a7, a6, a5 of the third level are obtained.

[0128] For another example, taking a 5-bit circular left shift and a 3-level inverse butterfly network as an example, the binary number input to the network is an 8-bit binary number. If you want to circularly shift left by 5 bits, you only need to generate a control signal for a 5-bit circular left shift. The binary number corresponding to the 5-bit circular left shift is 3'b101.

[0129] like Figure 3DAs shown, the specific signal corresponding to the first level is 2'b01, and the specific signal 2'b01 is cyclically shifted left by 1 bit, where "1 bit" is the decimal number corresponding to the lowest binary number 1 in 3'b101, 2'b01<<<1'b1=2'b10 ("<<<" indicates cyclic left shift), and the high 1 of the result of cyclic left shift of the specific signal is selected The data of the first-level circular left shift is used as the circular left shift control signal of the first level, that is, the circular left shift control signal of the first level is 1'b1; the specific signal corresponding to the second level is 4'b0011, and the specific signal 4'b0011 is circularly shifted left by 1 bit, that is, the lowest 2 bits "01" corresponding to the shift bit number 3'b101, 4'b0011<<<2'b01=4'b0110, and the high 2 bits of the result of the circular left shift of the specific signal are selected as the circular left shift control signal of the second level, that is, the circular left shift control signal of the second level is 2'b01; the specific signal corresponding to the third level is 8'b00001111, and the specific signal 8'b00001111 is circularly shifted left by 5 bits, that is, the corresponding shift bit value 3'b101, 8'b00001111<<<3'b101=8'b11100001, the upper 4 bits of the result of the cyclic left shift of the specific signal are selected as the cyclic left shift control signal of the third stage, that is, the cyclic left shift control signal of the third stage is 4'b1110.

[0130] like Figure 3D As shown in the figure, for the first-level network, the input data is divided into four sub-butterfly networks (clusters), namely cluster1 to cluster4 ( Figure 3D Only cluster1 is shown in the figure. The first digit of each cluster is the first sub-cluster, and the last digit is the second sub-cluster. The control signal of the first level is 1'b1. The positions of the 0th digit in the first sub-cluster and the 0th digit in the second sub-cluster in each cluster are exchanged. For the sub-butterfly network (cluster) cluster1, the 0th digit a7 in the first sub-cluster1 and the 0th digit a6 in the second sub-cluster1 in the sub-butterfly network (cluster) cluster1 are exchanged. Under the control signal, the corresponding bits in each sub-cluster of other sub-butterfly networks (clusters) of the first level are also exchanged, that is, the data a5 and a4 in cluster2 are exchanged, the data a3 and a2 in cluster3 are exchanged, and the data a1 and a0 in cluster4 are exchanged, and the output data of the first level are a6, a7, a4, a5, a2, a3, a0, a1.

[0131] For the second-level network, the input data is divided into two sub-networks (clusters), cluster1' and cluster2' ( Figure 3DOnly cluster1' is shown in the figure. The first two digits of each cluster are the first sub-cluster, and the last two digits are the second sub-cluster. The control signal of the second level is 2'b01. For each cluster, the 0th digit in the first sub-cluster and the 0th digit in the second sub-cluster are exchanged, and the 1st digit in the first sub-cluster and the 1st digit in the second sub-cluster remain unchanged. For the sub-butterfly network (cluster) cluster1', the 0th digit a7 in the first sub-cluster1' and the 0th digit a5 in the second sub-cluster1' in the sub-butterfly network (cluster) cluster1' are exchanged, and the 1st digit a6 in the first sub-cluster1' and the 1st digit a4 in the second sub-cluster1' remain unchanged; for the other sub-butterfly networks (clusters) of the second level, under the control signal, the data a3 and a1 in cluster2' are exchanged, and the data a2 and a0 remain unchanged; finally, the output data of the second level are a6, a5, a4, a7, a2, a1, a0, a3.

[0132] For the third-level network, the input data is divided into 1 sub-butterfly network (cluster) cluster, which is cluster1. The first 4 digits of each cluster are the first sub-cluster, and the last 2 digits are the second sub-cluster. The control signal of the third level is 4'b1110. For each cluster, the 0th digit in the first sub-cluster and the 0th digit in the second sub-cluster remain unchanged, the 1st digit in the first sub-cluster and the 1st digit in the second sub-cluster are swapped, and the 2nd digit in the first sub-cluster and the 2nd digit in the second sub-cluster are swapped. The positions of the digits are swapped, and the 3rd digit in the first sub-cluster is swapped with the 3rd digit in the second sub-cluster. For the butterfly network (cluster) cluster1", the 0th digit a7 in the first sub-cluster1" and the 0th digit a3 in the second sub-cluster1" remain unchanged, the 1st digit a4 in the first sub-cluster1" and the 1st digit a0 in the second sub-cluster1" are swapped, the 2nd digit a5 in the first sub-cluster1" and the 2nd digit a1 in the second sub-cluster1" are swapped, the 3rd digit a6 in the first sub-cluster1" and the 3rd digit a2 in the second sub-cluster1" are swapped, and the output data a2, a1, a0, a7, a6, a5, a4, a3 of the third level are obtained.

[0133] Therefore, the cyclic shift control signal generating unit 202b can obtain the corresponding cyclic shift control signal according to the number of shift bits and the shift type, and cyclically shift the input data in the inverse butterfly network according to the cyclic shift control signal, so that the numbers at various positions of the input data of the inverse butterfly network can be adjusted to the corresponding positions.

[0134] The control signal XOR unit 202c is used to perform an XOR operation on the bit inversion control signal generated by the bit inversion control signal generating unit 202a and the cyclic shift control signal generated by the cyclic shift control signal generating unit 202b to generate a bit inversion cyclic shift control signal, which is the control signal output by the control signal generating unit 202.

[0135] The following introduces the XOR operation of the bit inversion control signal and the cyclic shift control signal.

[0136] The bit inversion cyclic shift control signal can be obtained by performing an XOR operation on the bit inversion control signal and the cyclic shift control signal generated by the cyclic shift control signal generating unit 202b. Then the control signal of the Nth level can be obtained in the following manner: obtaining the bit inversion control signal and the cyclic shift control signal of the Nth level; performing an XOR operation on the binary value of the i-th bit of the bit inversion control signal of the Nth level and the binary value of the i-th bit of the cyclic shift control signal of the Nth level, that is, if the value of the i-th bit of the bit inversion control signal is the same as the value of the i-th bit of the cyclic shift control signal, the value of the i-th bit of the obtained bit inversion cyclic shift control signal is 0, and if the value of the i-th bit of the bit inversion control signal is different from the value of the i-th bit of the cyclic shift control signal, the value of the i-th bit of the obtained bit inversion cyclic shift control signal is 1.

[0137] like Figure 3E As shown, Figure 3B The bit inversion control signal shown and Figure 3C The shift type shown is right shift, and the shift bit number is 5 bits. The obtained circular right shift control signal is subjected to an XOR operation to obtain a bit-reversed circular right shift control signal for explanation.

[0138] For the first-level network, the bit reversal control signal is 1'b1, and the cyclic right shift control signal is 1'b1. The binary value 1 of the 0th bit of the bit reversal control signal of the first level is XORed with the value 1 of the 0th bit of the cyclic shift control signal. The two values ​​are the same, and the value of the 0th bit of the bit reversal cyclic shift control signal of the first level is 0. Then the bit reversal cyclic shift control signal of the first-level network is 1'b0;

[0139] For the second-stage network, the bit reversal control signal is 2'b11, and the cyclic right shift control signal is 2'b10. The binary value 1 of the 0th bit of the second-stage bit reversal control signal is XORed with the value 0 of the 0th bit of the cyclic shift control signal. The two values ​​are different, so the value of the 0th bit of the second-stage bit reversal cyclic shift control signal is 1. The binary value 1 of the 1st bit of the second-stage bit reversal control signal is XORed with the value 1 of the 1st bit of the cyclic shift control signal. The two values ​​are the same, so the value of the 1st bit of the second-stage bit reversal cyclic shift control signal is 0. The bit reversal cyclic shift control signal of the second-stage network is 2'b01.

[0140] For the third-level network, the bit inversion control signal is 4'b1111, and the cyclic right shift control signal is 4'b0111. The binary value 1 of the 0th bit of the bit inversion control signal of the third level is XORed with the value 1 of the 0th bit of the cyclic shift control signal. The two values ​​are the same, so the value of the 0th bit of the bit inversion and cyclic shift control signal of the third level is 0. The binary value 1 of the 1st bit of the bit inversion control signal of the third level is XORed with the value 1 of the 1st bit of the cyclic shift control signal. The two values ​​are the same, so the value of the 1st bit of the bit inversion and cyclic shift control signal of the third level is 0. The binary value 1 of the 2nd bit of the bit inversion control signal of the third level is XORed with the value 1 of the 2nd bit of the cyclic shift control signal. The two values ​​are the same, so the value of the 2nd bit of the bit inversion and cyclic shift control signal of the third level is 0. The binary value 1 of the bit is XORed with the value 0 of the third bit of the cyclic shift control signal. The two values ​​are different, and the value of the third bit of the third-level bit reversal cyclic shift control signal is 1. The bit reversal cyclic shift control signal of the third-level network is 4'b1000.

[0141] The following takes the effect of the above-mentioned 5-bit circular right shift control signal on the inverse butterfly network as an example, and introduces the bit reversal and circular right shift control signal obtained by performing an XOR operation on the bit reversal control signal and the circular shift control signal, so that the input data of the inverse butterfly network can achieve the effect of bit reversal and circular right shift.

[0142] Figure 3E The specific process of using the bit-reversal cyclic shift signal to bit-reverse the input data and cyclically right-shift it by 5 bits is shown, taking the input data of the inverse butterfly network as 8-bit data as an example.

[0143] For the first-level network, the input data is divided into four sub-networks (clusters), cluster1 to cluster4 ( Figure 3EOnly cluster1 is shown in the figure. The first digit of each cluster is the first sub-cluster, and the last digit is the second sub-cluster. The control signal of the first level is 1'b0, so the 0th digit in the first sub-cluster and the 0th digit in the second sub-cluster of each cluster remain unchanged. For the butterfly network (cluster) cluster1, the 0th digit a7 in the first sub-cluster1 and the 0th digit a6 in the second sub-cluster1 of the butterfly network (cluster) cluster1 remain unchanged. Under the control signal, the corresponding bits in each sub-cluster of other butterfly networks (clusters) of the first level also remain unchanged, that is, the data a5 and a4 in cluster2 remain the original values, the data a3 and a2 in cluster3 remain the original values, and the data a1 and a0 in cluster4 remain the original values. The output data of the first level are a7, a6, a5, a4, a3, a2, a1, and a0.

[0144] For the second-level network, the input data is divided into two sub-networks (clusters), cluster1' and cluster2' ( Figure 3E Only cluster1' is shown in the figure. The first two digits of each cluster are the first sub-cluster, and the last two digits are the second sub-cluster. The control signal of the second level is 2'b01. For each cluster, the 0th digit in the first sub-cluster and the 0th digit in the second sub-cluster are exchanged, and the 1st digit in the first sub-cluster and the 1st digit in the second sub-cluster remain unchanged. For the sub-butterfly network (cluster) cluster1', the 0th digit a6 in the first sub-cluster1' and the 0th digit a4 in the second sub-cluster1' in the sub-butterfly network (cluster) cluster1' are exchanged, and the 1st digit a7 in the first sub-cluster1' and the 1st digit a5 in the second sub-cluster1' remain unchanged; for the other sub-butterfly networks (clusters) of the second level, under the control signal, the data a2 and a0 in cluster2' are exchanged, and the data a3 and a1 remain unchanged; finally, the output data of the second level are a7, a4, a5, a6, a3, a0, a1, and a2.

[0145] For the third-level network, the input data is divided into one sub-butterfly network (cluster), cluster1", the first 4 digits of each cluster are the first sub-cluster, and the last 2 digits are the second sub-cluster. The control signal of the third level is 4'b1000. For each cluster, the 0th digit in the first sub-cluster and the 0th digit in the second sub-cluster remain unchanged, the 1st digit in the first sub-cluster and the 1st digit in the second sub-cluster remain unchanged, the 2nd digit in the first sub-cluster and the 2nd digit in the second sub-cluster remain unchanged, and the 3rd digit in the first sub-cluster and the 3rd digit in the second sub-cluster are exchanged. For the sub-butterfly network (cluster) cluster1", the 0th digit a6 in the first sub-cluster1" and the 0th digit a2 in the second sub-cluster1" in the sub-butterfly network (cluster) cluster1" remain unchanged, the 1st digit a5 in the first sub-cluster1" and the 1st digit a1 in the second sub-cluster1" remain unchanged, and the 2nd digit a4 in the first sub-cluster1" The second digit a0 in the second sub-cluster1" remains unchanged, the third digit a7 in the first sub-cluster1" and the third digit a3 in the second sub-cluster1" are exchanged, and the third-level output data a3, a4, a5, a6, a7, a0, a1, and a2 are obtained.

[0146] For bit-reversed circular left shift, Figure 3F Shown Figure 3B 3D , the shift type is left shift, and the shift number is 5 bits. The specific process of using the obtained bit-reversal and cyclic left shift control signal to perform bit-reversal and cyclic shift on the input data of the inverse butterfly network, wherein the bit-reversal control signal and the cyclic left shift control signal are XORed and XORed, respectively. Figure 3F The specific process of the bit reversal cyclic left shift control signal shown is similar to that shown in FIG. Figure 3E The process of obtaining the bit-reversal cyclic right shift control signal is the same as shown in FIG. Figure 3F As shown, each stage performs XOR on the bit inversion control signal and the cyclic left shift control signal to obtain the bit inversion cyclic left shift control signal of each stage, the first stage is 1'b0, the second stage is 2'b10, and the third stage is 4'b0001.

[0147] The obtained bit inversion and cyclic left shift control signal is used to control the input data of the inverse butterfly network, so that the bit inversion and cyclic left shift of the input data can be achieved. Figure 3FThe control process of the bit-reversal cyclic left-shift control signal corresponding to a 5-bit left shift on the input data of the inverse butterfly network is shown. The specific control process is the same as the above-mentioned bit-reversal cyclic right-shift control process, which will not be repeated here. Figure 3F The result of bit-reversing the input data a7, a6, a5, a4, a3, a2, a1, a0 and cyclically shifting them left by 5 bits is a5, a6, a7, a0, a1, a2, a3, a4.

[0148] It can be understood that the bit inversion and cyclic shift control signal obtained by performing an XOR operation on the bit inversion control signal and the cyclic shift control signal to implement bit inversion and cyclic shift on the input data of the inverse butterfly network is only an example.

[0149] Through the aforementioned control signal generating unit 202, a control signal for bit-reversing and cyclically shifting the input data using the inverse butterfly network can be directly generated, so that the inverse butterfly network can directly obtain the bit-reversal and cyclic shift result of bit-reversing and shifting the input data based on the control signal and the input data, thereby realizing parallel operations of bit-reversing and shifting the data, which is beneficial to speeding up the calculation speed and reducing the calculation time.

[0150] Below Figure 2 The logic of the post-processing unit 204 in the embodiment of the present invention for post-processing the bit inversion and circular shift result obtained by the inverse butterfly network unit 203 based on the shift type and the shift bit number is introduced.

[0151] As mentioned above, the inverse butterfly network outputs the intermediate calculation result of bit reversal and shifting, and the final result of bit reversal and shifting can be obtained. The intermediate calculation result obtained by the inverse butterfly network unit 203 can be post-processed by the post-processing unit 204. For example, the mask film and the intermediate calculation result can be bitwise ANDed to obtain the final result of bit reversal and shifting.

[0152] Specifically, Figure 4A According to some embodiments of the present application, a schematic diagram of a parallel post-processing unit 204 structure is shown. Figure 4A As shown, the post-processing unit 204 includes a mask code generating unit 204a and a bitwise AND unit 204b.

[0153] The mask code generating unit 204a is used to generate a mask code according to the shift type and the shift bit number;

[0154] The bit AND unit 204b is used to perform a bit AND operation on the intermediate calculation result obtained by the inverse butterfly network unit 203 and the mask code obtained by the mask code generation unit 204a, and set the high or low position to 0, thereby obtaining an output result. For example, if the intermediate calculation result obtained is a bit inversion and cyclic shift result, the bit inversion and cyclic shift result obtained is performed on the mask code obtained according to the shift type and the shift number, and the high or low position is set to 0, thereby obtaining a bit inversion and shift result.

[0155] The logic of the mask code generating unit 204a generating the mask code according to the shift type and the shift bit number is introduced below.

[0156] The bit width of the mask code is the same as the bit width of the intermediate calculation result obtained by the inverse butterfly network unit 203. When the shift type is cyclic shift, the binary values ​​of each bit of the mask code are all 1; when the shift type is not cyclic shift, for right shift, starting from the high bit, the values ​​of the high shift bits of the mask code are all 0, and the values ​​of the remaining bits are all 1. For left shift, starting from the low bit, the values ​​of the low shift bits of the mask code are all 0, and the values ​​of the remaining bits are all 1.

[0157] The following is an introduction using an 8-bit bit width of the mask code. When the shift type is a cyclic left shift or a cyclic right shift, all bits of the mask code value obtained by the mask code generating unit 204a are 1, i.e., 8'b11111111, which means that the value of the 8-bit binary number is 11111111. When the shift type is not a cyclic shift, i.e., a left shift or a right shift, Figure 4B It shows that the decimal value corresponding to the number of shift bits is between 0 and 7, and the mask code generating unit 204a obtains an 8-bit binary mask code value according to the number of shift bits and the shift type.

[0158] The 3-bit positions corresponding to the number of shifts are B2, B1 and B0 from high to low, the 8-bit mask code corresponding to the right shift is A7, A6, A5, A4, A3, A2, A1, A0 from high to low, and the 8-bit mask code corresponding to the left shift is A7, A6, A5, A4, A3, A2, A1, A0 from high to low. Figure 4BAs shown, when the number of shift bits is 3'b000, the right shift mask code is 8'b11111111, and the left shift mask code is 8'b11111111; when the number of shift bits is 3'b001, the right shift mask code is 8'b01111111, and the left shift mask code is 8'b11111110; when the number of shift bits is 3'b010, the right shift mask code is 8'b00111111, and the left shift mask code is 8'b11111100; when the number of shift bits is 3'b011, the right shift mask code is 8'b00011111, and the left shift mask code is 8'b1111100 0; when the number of shift bits is 3'b100, the right shift mask code is 8'b00001111, and the left shift mask code is 8'b11110000; when the number of shift bits is 3'b101, the right shift mask code is 8'b00000111, and the left shift mask code is 8'b11100000; when the number of shift bits is 3'b110, the right shift mask code is 8'b00000011, and the left shift mask code is 8'b11000000; when the number of shift bits is 3'b111, the right shift mask code is 8'b00000001, and the left shift mask code is 8'b10000000. Figure 4A The bit AND unit 204b shown performs an AND operation on each bit of the intermediate calculation result obtained by the inverse butterfly network unit 203 and each bit of the mask code obtained by the mask code generation unit 204a, thereby obtaining a bit inversion and shift result, that is, an output result.

[0159] Take bit inversion and right shift 5 bits as an example, Figure 4A The mask code generating unit 204a in the embodiment can phase-match the intermediate calculation results obtained in FIG. 3E , i.e., the bit-reversed and cyclically right-shifted results a3, a4, a5, a6, a7, a0, a1, a2, with the mask code 8'b00000111 corresponding to the right shift of 5 bits to obtain the bit-reversed and right-shifted results 0, 0, 0, 0, 0, a0, a1, a2.

[0160] In some embodiments, the process of the mask code generation unit 204a generating the mask code can be executed in parallel with the process of the control signal generation unit 202 generating the control signal and the inverse butterfly network unit 203 bit-reversing the input data and cyclically shifting to obtain the intermediate calculation result, thereby speeding up the calculation speed and reducing the calculation time. In some implementations, the mask code generation unit 204a can adopt the circuit structure of the temperature code, which has a simple circuit structure and is easy to implement.

[0161] It can be understood that the control signal generating unit 202 includes a parallel bit reversal control signal generating unit 202a and a cyclic shift control signal generating unit 202b structure. The control signals generated by the above two control signal generating units are XORed through the control signal XOR unit 202c to obtain a control signal that can realize two control functions, thereby speeding up the calculation time and reducing the time consumption. The method can be extended to XORing a plurality of control signals that realize different functions to generate a control signal with bit reversal and cyclic shift functions. As long as a method, circuit or device is used to XOR a plurality of bit reversal control signals and cyclic shift control signals to generate corresponding control signals with corresponding bit reversal and cyclic shift functions, it is within the protection scope of the present application.

[0162] It can be understood that the above-mentioned bit reverse shifting device 200 is only a schematic diagram. The structure of the bit reverse shifting device 200 shown in the embodiment of the present application does not constitute a specific limitation on the bit reverse shifting device 200. In some other embodiments of the present application, it can also include fewer or more units, or combine certain components, or split certain components, or arrange the components differently. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.

[0163] The embodiment of the present application also provides a bit reverse shifting method, which can use the bit reverse shifting device 200 shown above to implement bit reverse and shifting of data. Since the bit reverse shifting device 200 has a corresponding functional unit to implement the bit reverse shifting method, it can be combined with Figure 2 The bit inversion shifting device 200 shown in FIG. Figure 3A The structure of the control signal generating unit 202 is shown as well as Figure 4A The structure of the post-processing unit 204 is introduced as shown.

[0164] Specifically, Figure 5 According to some embodiments of the present application, a schematic flow chart of a bit reverse shifting method is shown. Figure 5 As shown, the method includes the following steps.

[0165] S501: The data acquisition unit 201 acquires input parameter data, wherein the input parameter data includes input data, shift type and shift bit number.

[0166] In some embodiments, the data acquisition unit 201 acquires bit-reversed and shifted input parameter data, and sends the shift type and the number of shift bits in the input parameter data to the control signal generation unit 202 and the post-processing unit 204 , and sends the input data to the inverse butterfly network unit 203 .

[0167] It can be understood that the bit-reversed and shifted input parameter data acquired by the data acquisition unit 201 can be the input parameter data of the bit-reversed and shifted related instructions, wherein the input data is a binary number that needs to be bit-reversed and shifted, and the shift type is circular left shift, circular right shift, left shift or right shift.

[0168] For example, taking the binary number that needs to be bit reversed and shifted as 8-bit data as an example, the data acquisition unit 201 acquires the input parameter data that is bit reversed and shifted, including the input data 8'b00001111, the shift type is right shift, the number of shift bits is 5, and the corresponding binary number is 3'b101, and sends the right shift type and the number of shift bits 3'b101 in the input parameter data to the control signal generation unit 202 and the post-processing unit 204, and sends the input data 8'b00000111 to the inverse butterfly network unit 203.

[0169] S502: The control signal generating unit 202 generates a control signal according to the shift type and the shift bit number.

[0170] In some embodiments, the control signal generating unit 202 generates a control signal according to the shift type and the shift bit number, so as to implement binary bit inversion and cyclic shift of the input data of the inverse butterfly network unit 203 .

[0171] Specifically, for generating the bit inversion cyclic shift control signal, the control signal generating unit 202 includes a bit inversion control signal generating unit 202a, a cyclic shift control signal generating unit 202b and a control signal XOR unit 202c.

[0172] The bit reversal control signal generating unit 202a is used to generate the bit reversal control signal corresponding to each level of the inverse butterfly network, and send the obtained bit reversal control signal to the control signal XOR unit 202c. The value of each bit on the bit reversal control signal corresponding to each level of the inverse butterfly network is a binary number 1. For example, for a 3-level inverse butterfly network, the first-level bit reversal control signal is 1'b1, the second-level bit reversal control signal is 2'b11, and the third-level bit reversal control signal is 4'b1111.

[0173] The cyclic shift control signal generating unit 202b is used to generate the cyclic shift control signal corresponding to each level of the inverse butterfly network according to the shift bit number and the shift type, and send the obtained cyclic shift control signal to the control signal XOR unit 202c. For example, for a 3-level inverse butterfly network, the shift type is right shift, the shift bit number is 5, and the corresponding binary number is 3'b101. Figure 3CThe corresponding cyclic right shift control signal obtained in the manner shown is: first level 1'b1, second level 2'b10, third level 4'b0111, and the generated cyclic right shift control signal is sent to the control signal XOR unit 202c.

[0174] The control signal XOR unit 202c receives the bit inversion control signal sent by the bit inversion control signal generating unit 202a and the cyclic shift control signal sent by the cyclic shift control signal generating unit 202b, performs XOR on the received bit inversion control signal of the corresponding level and the corresponding bit of the cyclic shift control signal of the corresponding level, obtains the bit inversion cyclic shift control signal of the corresponding level, and uses the generated bit inversion cyclic shift control signal as the output of the control signal generating unit 202. For example, the bit inversion control signal sent by the bit inversion control signal generating unit 202a is received. Figure 3B The bit inversion control signal shown in FIG. 1 is 1'b1 at the first level, 2'b11 at the second level, and 4'b1111 at the third level. The receiving cyclic shift control signal generating unit 202b sends Figure 3C The circular right shift control signal shown in the figure has the first stage 1'b1, the second stage 2'b10, and the third stage 4'b0111. Figure 3E As shown, the first-level bit inversion control signal 1'b1 is XORed with the first-level cyclic right shift control signal 1'b1 to obtain the first-level bit inversion cyclic right shift control signal 1'b0; the second-level bit inversion control signal 2'b11 is XORed with the second-level cyclic right shift control signal 2'b10 to obtain the second-level bit inversion cyclic right shift control signal 2'b01; the third-level bit inversion control signal 4'b1111 is XORed with the third-level cyclic right shift control signal 4'b0111 to obtain the third-level bit inversion cyclic right shift control signal 4'b1000. The control signal XOR unit 202c sends the generated bit inversion cyclic right shift control signals 1'b0, 2'b01 and 4'b1000 to the inverse butterfly network unit 203.

[0175] S503: The inverse butterfly network unit 203 obtains an intermediate calculation result according to the input data and the acquired control signal.

[0176] In some embodiments, the inverse butterfly network unit 203 is used to receive the control signal from the control signal generation unit 202, and perform bit inversion and circular shift on the input data from the data acquisition unit 201 according to the acquired control signal to obtain an intermediate calculation result, and provide the intermediate calculation result to the post-processing unit 204.

[0177] For example, the reverse butterfly network unit 203 receives the control signal generation unit 202 as follows: Figure 3EThe bit inversion and circular right shift control signal shown in FIG. 1 is used to perform bit inversion and circular right shift of 5 bits on the input data 8'b00001111 provided by the data acquisition unit 201 according to the acquired bit inversion and circular right shift control signal, and the following is obtained: Figure 3E The binary number (bit inversion and circular shift result) after bit inversion and circular shift of the input data is shown, that is, the intermediate calculation result is 8′b10000111, and the intermediate calculation result 8′b10000111 is given to the post-processing unit 204.

[0178] S504: The post-processing unit 204 generates a mask code according to the shift type and the shift bit number, and post-processes the intermediate calculation result to obtain output data.

[0179] In some embodiments, the post-processing unit 204 generates a mask code according to the shift type and the shift bit number provided by the data acquisition unit 201, and obtains output data by post-processing the intermediate calculation result provided by the inverse butterfly network unit 203 and the mask code bitwise AND.

[0180] Specifically, the post-processing unit 204 includes a mask code generating unit 204 a and a bitwise AND unit 204 b .

[0181] The mask code generating unit 204a is used to generate a mask code according to the shift type and the number of shift bits given by the data acquisition unit 201. The number of bits of the generated mask code is the same as the number of bits of the intermediate calculation result. When the shift type is a circular shift, the binary value of each bit of the mask code is all 1. When the shift type is a right shift, starting from the high bit, the values ​​of the bits of the mask code before the shift number are all binary 0, and the values ​​of the remaining bits are all binary 1. When the shift type is a left shift, starting from the low bit, the values ​​of the bits of the mask code after the shift number are all binary 0, and the values ​​of the remaining bits are all binary 1, that is, starting from the low bit, the number of 0s is the number of bits of the left shift. For example, Figure 4B It is shown that for 8-bit input data, the mask code generation unit 204 obtains the corresponding mask code according to the shift type and the number of shift bits. In some implementations, the data acquisition unit 201 can generate the corresponding mask code according to the logic of the thermometer code.

[0182] The bitwise AND unit 204b is used to perform a bitwise AND operation on the intermediate calculation result obtained by the inverse butterfly network unit 203 and the mask code obtained by the mask code generation unit 204a, thereby obtaining a bit-reversed and shifted result, that is, an output result.

[0183] For example, the shift bit number is 5 bits and the shift type is right shift. The bitwise AND unit 204b performs a bitwise AND operation on the corresponding mask code 8'b00000111 obtained by the mask code generation unit 204a and the intermediate calculation result 8'b10000111 provided by the inverse butterfly network unit 203 to obtain a bit-reversed and right-shifted result 8'b00000111.

[0184] It can be understood that the execution order of the above steps S501 to S504 is only an example. In other embodiments, other execution orders may be adopted, and some steps may be split or combined, which is not limited here.

[0185] It can be understood that the bit inversion shifting device proposed in the present application can be used in a processor of an electronic device.

[0186] To facilitate understanding of the technical solutions of each implementation of the present application, the hardware structure of the electronic device 100 is introduced below.

[0187] further, Figure 6 According to some embodiments of the present application, a schematic diagram of the structure of an electronic device 100 is shown. Figure 6 The electronic device 100 shown includes one or more processors 101, a system memory 102, a non-volatile memory (NVM) 103, a communication interface 104, an input / output (I / O) device 105, and a system control logic 106 for coupling the processor 101, the system memory 102, the non-volatile memory 103, the communication interface 104 and the input / output (I / O) device 105.

[0188] Wherein: the processor 101 may include one or more processing units, for example, it may include a central processing unit CPU (Central Processing Unit), an image processor GPU (Graphics Processing Unit), a digital signal processor DSP (Digital Signal Processor), a neural network processor (Neural Network Processing Unit, NPU), a microprocessor MCU (Micro-programmed Control Unit), an AI (Artificial Intelligence) processor or, a processing module or processing circuit of a programmable logic device FPGA (Field Programmable Gate Array) or other processors including a data bit inversion shifting device, and implementing data bit inversion and shifting according to a shift instruction. The specific processor type is not specifically required here.

[0189] In some embodiments, the processor 101 may include the aforementioned bit reversal and shifting device, so that when data needs to be bit reversed and shifted, the bit reversal and shifting device can be used to process the instructions related to the bit reversal and shifting. Since the device adopts a parallel structure, the computing efficiency is high.

[0190] The system memory 102 is a volatile memory, such as a random-access memory (RAM), a double data rate synchronous dynamic random access memory (DDR SDRAM), etc. The system memory is used to temporarily store data and / or instructions. For example, in some embodiments, the system memory 102 can be used to store the above-mentioned instructions for reversing and shifting data bits.

[0191] The non-volatile memory 103 may include one or more tangible, non-temporary computer-readable media for storing data and / or instructions. In some embodiments, the non-volatile memory 103 may include any suitable non-volatile memory such as flash memory and / or any suitable non-volatile storage device, such as a hard disk drive (HDD), a compact disc (CD), a digital versatile disc (DVD), a solid-state drive (SSD), etc. In some embodiments, the non-volatile memory 103 may also be a removable storage medium, such as a secure digital (SD) memory card, etc.

[0192] In particular, the system memory 102 and the non-volatile memory 103 may respectively include: a temporary copy and a permanent copy of the instruction 107. The instruction 107 may include: being executed by at least one of the processors 101 to enable the electronic device 100 to implement the binary number after the data is bit-reversed and shifted according to the instructions related to bit-reversing and shifting the data provided in the embodiments of the present application.

[0193] The communication interface 104 may include a transceiver for providing a wired or wireless communication interface for the electronic device 100, thereby communicating with any other suitable device through one or more networks. In some embodiments, the communication interface 104 may be integrated into other components of the electronic device 100, for example, the communication interface 104 may be integrated into the processor 101A. In some embodiments, the electronic device 100 may communicate with other devices through the communication interface 104.

[0194] The input / output (I / O) device 105 may include input devices such as a keyboard, a mouse, etc., and output devices such as a display, etc. A user may interact with the electronic device 100 via the input / output (I / O) device 105 .

[0195] System control logic 106 may include any suitable interface controller to provide any suitable interface with other modules of terminal 100. For example, in some embodiments, system control logic 106 may include one or more memory controllers to provide interfaces to system memory 102 and non-volatile memory 103.

[0196] In some embodiments, at least one of the processors 101 may be packaged together with the logic of one or more controllers for the system control logic 106 to form a system in package (SiP). In other embodiments, at least one of the processors 101 may also be integrated with the logic of one or more controllers for the system control logic 106 on the same chip to form a system-on-chip (SoC).

[0197] Understandably, Figure 6 The structure of the electronic device 100 shown is only an example. In other embodiments, the electronic device 100 may include more or fewer components than shown, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0198] The various embodiments of the mechanism disclosed in the present application can be implemented in hardware, software, firmware or a combination of these implementation methods. The embodiments of the present application can be implemented as a computer program or program code executed on a programmable system, which includes at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device and at least one output device.

[0199] Program code can be applied to input instructions to perform the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.

[0200] Program code can be implemented with high-level programming language or object-oriented programming language to communicate with the processing system. When necessary, program code can also be implemented with assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any specific programming language. In either case, the language can be a compiled language or an interpreted language.

[0201] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, instructions may be distributed over a network or through other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine (e.g., computer) readable form, including, but not limited to, floppy disks, optical disks, optical disks, read-only memories (CD-ROMs), magneto-optical disks, read-only memories (ROM), random access memories (RAM), erasable programmable read-only memories (EPROM), electrically erasable programmable read-only memories (EEPROM), magnetic cards or optical cards, flash memory, or tangible machine-readable memories for transmitting information (e.g., carrier waves, infrared signal digital signals, etc.) using the Internet in electrical, optical, acoustic, or other forms of propagation signals. Accordingly, machine-readable media include any type of machine-readable media suitable for storing or transmitting electronic instructions or information in a form readable by a machine (eg, a computer).

[0202] In the accompanying drawings, some structural or method features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be required. Instead, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of structural or method features in a particular figure does not mean that such features are required in all embodiments, and in some embodiments, these features may not be included or may be combined with other features.

[0203] It should be noted that the units / modules mentioned in the various device embodiments of the present application are all logical units / modules. Physically, a logical unit / module can be a physical unit / module, or a part of a physical unit / module, or can be implemented in a combination of multiple physical units / modules. The physical implementation of these logical units / modules themselves is not the most important. The combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed by the present application. In addition, in order to highlight the innovative part of the present application, the above-mentioned device embodiments of the present application do not introduce units / modules that are not closely related to solving the technical problems proposed by the present application, which does not mean that there are no other units / modules in the above-mentioned device embodiments.

[0204] It should be noted that in the examples and description of this patent, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of more restrictions, an element defined by the sentence "comprises one" does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0205] Although the present application has been illustrated and described with reference to certain preferred embodiments thereof, it will be apparent to those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the present application.

Claims

1. A bit inversion shifting method, applied to electronic equipment, characterized in that: include: Get the data to be processed; A shift control signal is generated according to the shift type and the number of shift bits of the data to be processed, and a bit inversion control signal is generated according to the number of bits of the data to be processed, wherein: The generation process of the shift control signal comprises: shifting the first signal to the left or right by J bits, and shifting the first two bits of the binary number by J bits. N-1 The first signal is high 2, as the shift control signal corresponding to the Nth level network in the K-level network of the inverse butterfly network. N-1 Bit is 0, low 2 N-1 Bit 1 of 2 N The binary number of the shifted bits, K≥N, J is the decimal number corresponding to the last N digits of the binary number corresponding to the shifted bits, and, The generation process of the bit inversion control signal includes: setting the second signal to be the bit inversion control signal corresponding to the Nth level network of the inverse butterfly network, wherein the second signal is 2 N-1 A binary number whose bits are all 1; performing an XOR operation on the shift control signal and the bit inversion control signal to obtain a bit inversion shift control signal; Inputting the bit inversion shift control signal and the data to be processed into an inverse butterfly network to obtain a result of bit inversion and cyclic shift of the data to be processed; The result of the bit inversion and circular shift is post-processed according to the shift type and the shift bit number to obtain the result of the bit inversion and circular shift of the data to be processed.

2. The method according to claim 1, characterized in that The inverse butterfly network includes a K-level network, and the binary number of the data to be processed is 2 K The shift control signal includes K shift control signals corresponding to the K-level networks of the inverse butterfly network, and the number of bits of the shift control signal corresponding to the N-th level network of the inverse butterfly network is 2 N-1 bits, the number of shift bits is H bits, the binary number corresponding to H is M, where K≥N; and The first 2 bits of the binary number after the first signal is cyclically shifted left or right by J bits are N-1 The number of bits, as the shift control signal corresponding to the Nth level network in the K-level network of the inverse butterfly network, includes: When the shift type is left shift or circular left shift, the first 2 bits of the binary number after the first signal is circularly shifted left by J bits are N-1 digits, as a shift control signal corresponding to the Nth level network of the inverse butterfly network, wherein J is a decimal number corresponding to the last N digits of M; When the shift type is right shift or circular right shift, the first 2 N-1 The number of bits is used as a shift control signal corresponding to the Nth level network of the inverse butterfly network.

3. The method according to claim 2, characterized in that The bit reversal control signal includes K bit reversal control signals corresponding to the K-level networks of the inverse butterfly network, and the number of bits of the bit reversal control signal corresponding to the N-th level network of the inverse butterfly network is 2 N-1 Bit.

4. The method according to claim 3, characterized in that The bit reverse shift control signal includes K bit reverse shift control signals corresponding to the K-level networks of the inverse butterfly network respectively; and performing an XOR operation on the shift control signal and the bit inversion control signal to obtain the bit reverse shift control signal includes: The result of performing an XOR operation on the shift control signal and the bit reversal control signal corresponding to the Nth level network of the inverse butterfly network is used as the bit reversal shift control signal corresponding to the Nth level network of the inverse butterfly network.

5. The method according to any one of claims 1 to 4, characterized in that in, Post-processing the result of the bit inversion and circular shift according to the shift type and the shift number includes: When the shift type is left shift and the shift number is H bits, the low H bits of the result of the bit inversion and circular shift are set to zero; When the shift type is right shift and the shift number is H bits, the high H bits of the result of the bit inversion and circular shift are set to zero; When the shift type is a circular right shift or a circular left shift and the shift bit number is H bits, each bit of the result of the bit inversion and circular shift remains unchanged.

6. The method according to claim 5, characterized in that in, When the shift type is left shift and the number of shift bits is H bits, setting the low H bits of the result of the bit inversion and circular shift to zero includes: A bitwise AND operation is performed on the result of the bit inversion and circular shift and the first mask code, wherein the number of bits of the first mask code and the number of bits of the result of the bit inversion and circular shift is P, and the low H bit of the first mask code is 0 and the high PH bit is 1.

7. The method according to claim 5, characterized in that in, When the shift type is right shift and the shift number is H bits, setting the high H bits of the result of the bit inversion and circular shift to zero includes: A bitwise AND operation is performed on the result of the bit inversion and circular shift and the second mask code, wherein the number of bits of the second mask code and the number of bits of the result of the bit inversion and circular shift is Q, and the high H bit of the second mask code is 0 and the low QH bit is 0.

8. A bit inversion shifting device, characterized in that: include: A control signal generating unit is used to generate a shift control signal according to the shift type and the number of shift bits of the data to be processed, and to generate a bit reversal control signal according to the number of bits of the data to be processed, and to perform an XOR operation on the shift control signal and the bit reversal control signal to obtain a bit reversal shift control signal, wherein: The generation process of the shift control signal includes: the control signal generation unit shifts the first signal to the left or right by J bits, and the first two bits of the binary number are shifted to the left or right by J bits. N-1 The first signal is high 2, as the shift control signal corresponding to the Nth level network in the K-level network of the inverse butterfly network. N-1 Bit is 0, low 2 N-1 Bit 1 of 2 N The binary number of the shifted bits, K≥N, J is the decimal number corresponding to the last N digits of the binary number corresponding to the shifted bits, and, The process of generating the bit inversion control signal includes: the control signal generating unit sets the second signal as the bit inversion control signal corresponding to the Nth level network of the inverse butterfly network, wherein the second signal is 2 N-1 A binary number with all bits set to 1; An inverse butterfly network, used for obtaining a result of bit inversion and cyclic shift of the data to be processed according to the bit inversion shift control signal and the data to be processed; A post-processing unit is used to post-process the result of the bit inversion and circular shift according to the shift type and the shift bit number to obtain the result of the bit inversion and shift of the data to be processed.

9. The device according to claim 8, characterized in that The inverse butterfly network includes a K-level network, and the binary number of the data to be processed is 2 K The shift control signal includes K shift control signals corresponding to the K-level networks of the inverse butterfly network, and the number of bits of the shift control signal corresponding to the N-th level network of the inverse butterfly network is 2 N-1 bits, the number of shift bits is H bits, the binary number corresponding to H is M, where K≥N; and The control signal generating unit shifts the first signal to the left or right by J bits. N-1 The number of bits, as the shift control signal corresponding to the Nth level network in the K-level network of the inverse butterfly network, includes: The control signal generating unit, when the shift type is left shift or circular left shift, shifts the first 2 bits of the binary number of the first signal circularly left shifted by J bits. N-1 digits, as a shift control signal corresponding to the Nth level network of the inverse butterfly network, wherein J is a decimal number corresponding to the last N digits of M; When the shift type is right shift or circular right shift, the control signal generating unit generates the first two bits of the binary number of the first signal after circular right shift by J bits. N-1 The number of bits is used as a shift control signal corresponding to the Nth level network of the inverse butterfly network.

10. The device according to claim 9, characterized in that The bit reversal control signal includes K bit reversal control signals corresponding to the K-level networks of the inverse butterfly network, and the number of bits of the bit reversal control signal corresponding to the N-th level network of the inverse butterfly network is 2 N-1 Bit.

11. The device according to claim 10, characterized in that The bit reverse shift control signal includes K bit reverse shift control signals corresponding to the K-level networks of the inverse butterfly network respectively; and the control signal generating unit performs an XOR operation on the shift control signal and the bit reverse control signal to obtain the bit reverse shift control signal in the following manner: The control signal generating unit performs bit-by-bit XOR operation on the shift control signal and the bit reversal control signal corresponding to the Nth level network of the inverse butterfly network, and uses the result as the bit reversal shift control signal corresponding to the Nth level network of the inverse butterfly network.

12. The device according to any one of claims 9 to 11, characterized in that The number of shift bits is H bits, and the number of bits of the result of the bit inversion and circular shift is Y bits; and The post-processing unit performs post-processing on the result of the bit inversion and circular shift according to the shift type and the shift number in the following manner: When the shift type is left shift, performing a bitwise AND operation on the result of the bit inversion and circular shift and the first mask code to obtain the result of the bit inversion and shift, wherein the number of bits of the first mask code is Y, and the lower H bits of the first mask code are 0, and the upper YH bits are 1; When the shift type is right shift, performing a bitwise AND operation on the result of the bit inversion and circular shift and the second mask code to obtain the result of the bit inversion and shift, wherein the number of bits of the second mask code is Y, the high H bits of the second mask code are 0, and the low YH bits are 1; When the shift type is a circular right shift or a circular left shift, a bitwise AND operation is performed on the result of the bit inversion and circular shift and the third mask code to obtain the result of the bit inversion and shift, wherein the number of bits of the third mask code is Y, and all bits of the third mask code are 1.

13. A processor, characterized in that: The processor comprises the bit inversion shifting device according to any one of claims 8 to 12.

14. An electronic device, characterized in that: The electronic device comprises the processor of claim 13.