Data transmission method, data transmission device and electronic device
By sequentially reading and dividing data units in the memory and writing them into buffer units in a specified order, the problem of extra time taken by data rearrangement in matrix operations is solved, and data reading efficiency is improved.
Patent Information
- Application Number
- CN202311700987.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-12
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2043-12-12
AI Technical Summary
During matrix operations, in the prior art, when data is read from an external memory into a local memory and rearranged, additional time and steps are required, resulting in low data reading efficiency.
By sequentially reading the storage unit data in the depth of the memory, dividing it into sub-data units, and writing it into the buffer unit in a specified order, the data is finally rearranged in a step without adding extra time for storage in the row direction, thereby improving reading efficiency.
This achieves data rearrangement during data transmission, avoids extra time consumption, and improves data reading efficiency.
Smart Images

Figure CN117725002B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to a data transmission method, a data transmission device, and an electronic device. Background Art
[0002] In matrix operations, due to the reusability of the data of two input matrices (for example, matrix A and matrix B), the data is generally first read from an external memory such as double-data-rate synchronous dynamic random-access memory (DDR) into a local data memory (LSM, or simply referred to as "local memory") during the operation process, and then read from the local data memory into a general register, and then sent to the matrix operation unit for operation. After the operation is completed, the result is written back to the external memory DDR. Summary of the Invention
[0003] At least one embodiment of the present disclosure provides a data transmission method for transmitting data from a first memory to a second memory, wherein the first memory includes a memory bank with a depth of N, and a first storage unit of the memory bank at each depth has a width of K bits, and the second memory includes a plurality of consecutively arranged second storage units, and the width of the second storage unit is K bits. The method comprises: sequentially reading data stored in the first storage unit at each depth of the N depths, and sequentially storing the data of the N depths into a buffer unit, wherein the data is m bits, and each first storage unit is divided into K / m sub-data units according to m bits from low to high bits, wherein N, K and m are all positive integers; and writing the data in the memory bank from the buffer unit to the second memory in a specified order, wherein the specified order comprises: K / m data at the same position in adjacent K / m first storage units in the memory bank are stored in the same second storage unit of the second memory.
[0004] For example, in a method provided in an embodiment of the present disclosure, data stored in a first storage unit with a low depth among K / m adjacent first storage units in a memory bank is located in a low bit of the second storage unit.
[0005] For example, in a method provided in an embodiment of the present disclosure, the data stored in the first storage unit at each of the N depths is read in sequence, including: reading the data stored in the first storage unit at each of the N depths in sequence according to the depth order, and reading the data in the K / m sub-data units stored in the same first storage unit in parallel.
[0006] For example, in a method provided in an embodiment of the present disclosure, the buffer unit includes a plurality of buffers, each buffer is used to store one of the m-bit data, and the number of the plurality of buffers is greater than or equal to K / m.
[0007] For example, in the method provided in one embodiment of the present disclosure, the buffer unit includes (K / m) 2 A continuously arranged buffer zone is provided, and data in the storage body is written from the buffer unit to the second memory in a specified order, including: after sequentially storing data in first storage units of K / m depths into the buffer unit, starting to read data in K / m sub-data units at the same position in adjacent K / m first storage units in the storage body from the buffer unit.
[0008] For example, in a method provided in an embodiment of the present disclosure, after the data in the first storage units of K / m depths are sequentially stored in the buffer unit, data in the K / m sub-data units at the same position in the adjacent K / m first storage units in the storage body are started to be read from the buffer unit, including: after the data in the first storage units of K / m depths are sequentially stored in the buffer unit, the data in the K / m sub-data units at the same position in the adjacent K / m first storage units in the storage body are read in parallel; and the data in the K / m sub-data units at the same position in the adjacent K / m first storage units are written into the same second storage unit of the second memory.
[0009] For example, in a method provided in an embodiment of the present disclosure, multiple sub-data units in the storage body are continuously indexed in order of depth from small to large and position from small to large, and after the data in the first storage units of K / m depths are sequentially stored in the buffer unit, the data in the K / m sub-data units at the same position in the adjacent K / m first storage units in the storage body are read in parallel, including: from the first cycle to the K / m-th cycle, in each cycle, the data in the sub-data units with index numbers (i-1)×K / m, ...K / m×i-1 are read out from the storage body and stored in the buffer unit, where i represents the cycle count value; and starting from the K / m+1-th cycle, for each cycle, while reading out the data in the sub-data units with index numbers (i-1)×K / m, ...K / m×i-1 and storing them in the buffer unit, the K / m data at the same position in the adjacent K / m first storage units in the storage body are read in parallel from the buffer unit.
[0010] At least one embodiment of the present disclosure provides a data transmission device for transmitting data from a first memory to a second memory, wherein the first memory includes a memory bank with a depth of N, and a first storage unit of the memory bank at each depth has a width of K bits, and the second memory includes a plurality of consecutively arranged second storage units, and a width of the second storage unit has K bits, and the device includes: a buffer unit; a reading unit configured to sequentially read data stored in the first storage unit at each depth of N depths, and sequentially store the data of the N depths into the buffer unit, wherein the data is m bits, and each first storage unit is divided into K / m sub-data units according to m bits from low to high bits; and a writing unit configured to write the data in the memory bank from the buffer unit to the second memory in a specified order, wherein the specified order includes: K / m data at the same position in adjacent K / m first storage units in the memory bank are stored in the same second storage unit of the second memory, wherein N, K and m are all positive integers.
[0011] For example, in the device provided in one embodiment of the present disclosure, the buffer unit includes: a plurality of registers, each register is configured to store the data read from the first storage unit, the reading unit includes: a plurality of first multiplexers, the plurality of first multiplexers are configured to read the data stored in the first storage unit at each depth of the N depths of each of the storage bodies, and sequentially store the data stored in the first storage unit at each depth into K / m registers in the plurality of registers, the writing unit includes: a plurality of second multiplexers, the plurality of second multiplexers are configured to select K / m data located at the same position in adjacent K / m first storage units in the storage body from the plurality of registers, and write them into the same second storage unit of the second memory.
[0012] For example, in the device provided in one embodiment of the present disclosure, the first memory includes P storage bodies, the number of the buffer units is P, each buffer unit includes a preset number of registers, and the P storage bodies and the P buffer units correspond one to one, where P is a positive integer.
[0013] For example, in the device provided in one embodiment of the present disclosure, the preset number is a positive integer greater than or equal to K / m.
[0014] At least one embodiment of the present disclosure provides an electronic device, comprising the data transmission device provided in any embodiment of the present disclosure, a first memory, and a second memory, wherein the first memory is coupled to the data transmission device, and the data transmission device is coupled to the second memory. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings of the embodiments will be briefly introduced below. Obviously, the drawings in the following description only relate to some embodiments of the present disclosure, rather than limiting the present disclosure.
[0016] Figure 1A A schematic diagram showing a dot product of the rows of matrix A and the columns of matrix B in a matrix multiplication operation is shown;
[0017] Figure 1B A schematic diagram of matrix operation data flow is shown;
[0018] Figure 1C A schematic diagram showing the arrangement of matrix data in an external memory and a local memory in a column direction is shown;
[0019] Figure 1D A schematic diagram showing a matrix data in a storage bank in a local memory arranged in a column direction;
[0020] Figure 2A A flowchart of a data transmission method provided by at least one embodiment of the present disclosure is shown;
[0021] Figure 2B A schematic system architecture diagram for executing a data transmission method provided by at least one embodiment of the present disclosure is shown;
[0022] Figure 3A to Figure 3G A schematic diagram of a method for rearranging data in a 16-bit data format is provided for at least one embodiment of the present disclosure;
[0023] Figures 4A to 4M A schematic diagram of a method for rearranging data in an 8-bit format is provided for at least one embodiment of the present disclosure;
[0024] Figure 5 A schematic block diagram of a data transmission device provided by at least one embodiment of the present disclosure is shown;
[0025] Figure 6A At least one embodiment of the present disclosure provides a Figure 5 A schematic structural diagram of a data transmission device;
[0026] Figure 6B A schematic structural diagram showing another data transmission device provided by at least one embodiment of the present disclosure; and
[0027] Figure 7 A schematic diagram of an electronic device provided by at least one embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0028] To make the purpose, technical solutions, and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the described embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0029] Unless otherwise defined, the technical or scientific terms used in this disclosure should have the usual meanings understood by people with ordinary skills in the field to which this disclosure belongs. The words "first", "second" and similar words used in this disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, words such as "one", "an" or "the" do not indicate a quantity limitation, but rather indicate the existence of at least one. Words such as "include" or "comprise" mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. Words such as "connect" or "connected" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the object being described changes, the relative positional relationship may also change accordingly.
[0030] Figure 1A A schematic diagram showing a dot product of rows of matrix A and columns of matrix B in a matrix multiplication operation is shown.
[0031] The data required for matrix operations are generally arranged linearly in the external memory along the matrix rows or columns, such as Figure 1A As shown in the figure, in the matrix multiplication operation C=C+A*B, it is necessary to perform a dot product between each row of matrix A and each column of matrix B, and then update the elements at the corresponding positions in matrix C. Therefore, if the data in matrix A is linearly arranged in the column direction in the external memory, the data in matrix A needs to be rearranged so that the dot product of each row of matrix A and each column of matrix B is obtained.
[0032] Figure 1B A schematic diagram of matrix operation data flow is shown.
[0033] like Figure 1BAs shown, for example, the external memory DDR stores matrix A. Matrix A is read from the external memory DDR into the local data memory, and then read from the local data memory into the read and data reordering unit. The read and data reordering unit reorganizes and reorders the matrix, for example, reorganizing the data organized in the column direction in the row direction. The reorganized and reordered data is sent to the vector general register (also called "vector register") array, and then sent to the matrix operation unit for operation. After the operation is completed, the result is written back to the external memory DDR. The local data memory is usually a static random access memory (SRAM) array composed of multiple memory banks, which can support a larger read and write data bit width.
[0034] Figure 1C A schematic diagram showing the arrangement of matrix data in an external memory and a local memory in a column direction is shown; Figure 1D A schematic diagram showing the arrangement of matrix data in a storage bank in a local memory in a column direction is shown.
[0035] like Figure 1C and 1D As shown, the local data memory generally includes multiple banks, such as bank 0, bank 1, bank 2, and bank 3, and the multiple banks are independent of each other. Each bank includes multiple storage units at different depths, and the bit width of each storage unit can be 32 bits, 16 bits, or 8 bits, etc. In the embodiment of the present disclosure, the bit width of each bank is 32 bits for illustration. For example, if the bit width of the storage unit is 32 bits, each storage unit can store two 16-bit data or matrix elements. In the embodiment of the present disclosure, the depth of the storage unit increases from right to left, Figure 1D The rightmost storage unit has a depth of 0. For example, the lower 16 bits P0 of the storage unit with a depth of 0 in storage bank 0 stores element 0 in matrix A, and the upper 16 bits P1 store element 1 in matrix A; the lower 16 bits P2 of the storage unit with a depth of 1 in storage bank 0 stores element 8 in matrix A, and the upper 16 bits P3 store element 9 in matrix A; the lower 16 bits P4 of the storage unit with a depth of 2 in storage bank 0 stores element 16 in matrix A, and the upper 16 bits P5 store element 17 in matrix A; the lower 16 bits P6 of the storage unit with a depth of 3 in storage bank 0 stores element 24 in matrix A, and the upper 16 bits P7 store element 25 in matrix A. Other storage banks of the local memory, such as storage bank 1, storage bank 2, and storage bank 3, are similar to storage bank 0 and will not be described in detail. Figure 1C and Figure 1D For example, element 2 in matrix A is stored in the lower 16 bits of the storage unit with a depth of 0 in memory bank 1, and the storage method of other elements is similar.
[0036] Similarly, the data format of the elements in matrix A can also be 8 bits. In this case, each storage cell can store 4 elements. For example, element 0 in matrix A is stored in the lower 8 bits P0 of the storage cell at depth 0 in memory bank 0. Element 1 is stored in bits P1 (8th to 15th bits) of the storage cell at depth 0 in memory bank 0. Element 2 is stored in bits P2 (16th to 23rd bits) of the storage cell at depth 0 in memory bank 0. Element 3 is stored in bits P3 (24th to 31st bits) of the storage cell at depth 0 in memory bank 0. For example, the lower 8 bits P4 of the storage cell at depth 1 in memory bank 0 store element 16 of matrix A. Similarly, bits P5 to P7 of the storage cell store elements 17 to 19 of matrix A, respectively. Similarly, bits P8 to P11 of the storage cell at depth 2 in memory bank 0 store the four elements of matrix A, respectively. Bits P12 to P15 of the storage cell at depth 3 in memory bank 0 store the four elements of matrix A, respectively.
[0037] like Figure 1C and 1D As shown, when the data of matrix A is stored in the external memory DDR in a column-oriented manner, after being read from the external memory DDR into the local data memory, the local data memory is still stored in a column-oriented manner. For example, when the data format of each element in matrix A is 16 bits, elements 0 to 15 occupy the storage space of two columns of the local memory; when the data format of each element in matrix A is 8 bits, elements 0 to 15 occupy the storage space of one column of the local memory. Similarly, when the data format of each element in matrix A is 4 bits, elements 0 to 15 occupy the storage space of 1 / 2 columns of the local memory. This requires reorganizing the data so that it can be read out in a row-oriented format and then sent to the operation unit to facilitate matrix multiplication operations.
[0038] like Figures 1B to 1D As shown, matrix operations require first reading the matrix data from the local memory and storing it in the reading and data rearrangement unit, and then the reading and data rearrangement unit rearranges the matrix data. Rearranging the matrix data takes extra time, and the matrix data reading efficiency is low.
[0039] It should be noted that although the embodiments of the present disclosure use matrices as an example to illustrate that data rearrangement takes additional time, this does not mean that the present invention is only applied to rearrangement of matrix data. The embodiments of the present disclosure can be applied to any data that needs to be rearranged, not limited to matrix data.
[0040] At least one embodiment of the present disclosure provides a data transmission method, a data transmission device, and an electronic device. The data transmission method is used to transmit data from a first memory to a second memory, wherein the first memory includes a memory bank of N depths, wherein a first storage unit at each depth of the memory bank has a width of K bits, and the second memory includes a plurality of consecutively arranged second storage units, wherein the second storage units have a width of K bits. The method comprises: sequentially reading data stored in the first storage units at each of the N depths, and sequentially storing the data at the N depths into a buffer unit, wherein the data is m bits, and each first storage unit is divided into K / m sub-data units from the lowest bit to the highest bit according to the m-bit structure; and writing the data in the memory bank from the buffer unit to the second memory in a specified order, wherein the specified order includes: K / m data at the same position in adjacent K / m first storage units in the memory bank are stored in the same second storage unit of the second memory, where N, K, and m are all positive integers. The data transmission method can simultaneously rearrange the data during the data reading process, so that the data rearrangement step does not take up additional time, thereby improving data reading efficiency.
[0041] Figure 2A A flowchart of a data transmission method provided by at least one embodiment of the present disclosure is shown.
[0042] like Figure 2A As shown, the method may include steps S10 to S20. The data transmission method is used to transmit data from a first memory to a second memory, wherein the first memory includes a memory bank with a depth of N, and a first memory cell at each depth of the memory bank has a width of K bits, and the second memory includes a plurality of consecutively arranged second memory cells, and the width of the second memory cell is K bits.
[0043] Step S10: Read the data stored in the first storage unit at each depth of N depths in turn, and store the data of N depths in the buffer unit in turn. The data is m bits, and each first storage unit is divided into K / m sub-data units according to m bits from low to high.
[0044] Step S20: Write the data in the storage body from the buffer unit to the second memory in a specified order, wherein the specified order includes K / m data at the same position in adjacent K / m first storage units in the storage body being stored in the same second storage unit of the second memory.
[0045] Figure 2B A schematic system architecture diagram for executing a data transmission method provided by at least one embodiment of the present disclosure is shown.
[0046] like Figure 2BAs shown, the system includes a memory 201, a buffer unit 202, and a memory 203. The memory 201 is an example of a first memory, and the memory 203 is an example of a second memory. The memory 201 is, for example, Figure 1C and 1D The local data memory shown, memory 203 is for example Figure 1B Vector general registers shown.
[0047] The memory 201 includes at least one memory bank 211 (an example of a memory bank) with a depth of N. Figure 2B Only one memory bank 211 is shown as an example. Figure 1D and 1C As shown, the local data memory may include multiple memory banks. Each depth is a memory cell, and N first memory cells are arranged, for example, along a row direction. For example, memory bank 211 includes memory cell B1, memory cell B2, memory cell B3, memory cell B4, ..., memory cell BN (hereinafter referred to as memory cells B1-BN), where memory cells B1-BN are examples of first memory cells, and memory cells B1-BN are arranged in sequence.
[0048] Each memory cell at a depth of N has a width of K bits, that is, a memory cell has a bit width of K bits and can store K bits of data. For example, memory cells B1 to BN each include K bits.
[0049] In some embodiments, for example, if the data format stored in memory 201 is m bits, each storage unit is divided into K / m sub-data units from low to high bits according to m bits, and each sub-data unit is used to store m bits of data. For example, if the data in matrix A is stored in memory 201, and each element in matrix A is in m-bit data format, then, for example, storage unit B1 is divided into K / m sub-data units from low to high bits, and each sub-data unit is used to store one element in matrix A. Bits 0 to (m-1) are the first sub-data unit, used to store one element in matrix A, and bits m to (2m-1) are the second sub-data unit, used to store another element in matrix A, and so on.
[0050] For example, in the example of K=32 and m=16, each storage unit is divided into two sub-data units. For example, storage unit B1 is divided into sub-data units B10 and B11, where sub-data unit B10 stores element 0 in matrix A, and sub-data unit B11 stores element 1 in matrix A; storage unit B2 is divided into sub-data units B20 and B21, where sub-data unit B20 stores element 8 in matrix A, and sub-data unit B21 stores element 9 in matrix A; storage unit B3 is divided into sub-data units B30 and B31, storage unit B4 is divided into sub-data units B40 and B41, and storage unit BN is divided into sub-data units BN0 and BN1.
[0051] Similarly, the second memory 203 includes a plurality of consecutive second storage units, such as storage unit C1, storage unit C2, storage unit C3, storage unit C4, ..., storage unit Cx, each of which is configured to store K bits of data. If the data format stored in the second memory 203 is m bits, then one storage unit can also store K / m data. The size of the second memory 203 can be the same as that of the first memory 201 (e.g., x = N), or it can be different.
[0052] The buffer unit 202 may include multiple buffers, and the number of buffers may be determined according to the data format of the matrix and whether parallel reading is performed. In some embodiments of the present disclosure, the multiple buffer units correspond to the multiple memory banks in a one-to-one manner.
[0053] In some embodiments of the present disclosure, each buffer is used to store m bits of data, and the number of buffers corresponding to each memory bank is greater than or equal to K / m.
[0054] For example, based on the condition that a single memory bank is 32 bits wide, each memory unit is 32 bits, and each includes two 16-bit data formats. In order to realize the matrix row torque array or the matrix column to matrix row conversion, it is necessary to operate on at least two 16-bits of each column. Each buffer unit can include (32 / 16) = 2 buffers. If the first memory includes M (M is a positive integer) memory banks, then a total of 2*M buffers are required. Accordingly, for an 8-bit data format, each buffer unit can include (32 / 8) = 4 buffers. Accordingly, for a 4-bit data format, each buffer unit can include (32 / 4) = 8 buffers.
[0055] In other embodiments of the present disclosure, in order to achieve parallel processing, the number of buffers can be increased, and the number of buffers in each buffer unit is greater than K / m. For example, each buffer unit includes (K / m) 2 A continuous array of buffers.
[0056] For example, for a 16-bit data format, each buffer unit 202 may include 4 buffers, each buffer storing 16 bits; for an 8-bit data format, each buffer unit 202 may include 16 buffers, each buffer storing 8 bits; for a 4-bit data format, each buffer unit 202 may include 64 buffers, each buffer storing 4 bits.
[0057] for Figure 2A In step S10, for example, the data stored in N storage units are read sequentially in order of the serial numbers of the storage units from small to large. In some embodiments of the present disclosure, the data stored in the first storage unit at each depth of the N depths are read sequentially in order of depth, and the data in the K / m sub-data units stored in the same first storage unit are read in parallel. That is, the data in the K / m sub-data units stored in the first storage unit at the same depth are read in parallel. For example, the data in storage units B1 to BN are read sequentially, and the two data in each storage unit are read out at the same time. For example, after the data in sub-data unit B10 and sub-data unit B11 are read out at the same time, the data in sub-data unit B20 and sub-data unit B21 are read out at the same time, and so on. Reading data at the same depth in parallel can improve reading efficiency.
[0058] For example, each cycle reads 32 bits of data and stores the 32 bits of data in the buffer unit. For example, each memory bank corresponds to four buffers. In the first cycle, the data of sub-data units B10 and B11 in memory unit B1 are read in parallel, and the data of sub-data units B10 and B11 are stored in buffers 212 and 222 of buffer unit 202, respectively. In the second cycle, the data of sub-data units B20 and B21 in memory unit B2 are read in parallel, and the data of sub-data units B20 and B21 are stored in buffers 232 and 242 of buffer unit 202, respectively.
[0059] for Figure 2A In step S20, K / m data are read from the buffer unit in a specified order and written into, for example, a vector general register. The specified order may be such that K / m data at the same position in K / m adjacent first storage units in the memory bank are stored in the same second storage unit of the vector general register. That is, K / m data are read from the buffer unit in each cycle, and these K / m data are located in K / m adjacent first storage units, and the positions of these K / m data in these K / m adjacent first storage units are the same. For example, these K / m data are all from the sth position to the tth position in the first storage unit. Both s and t are positive integers.
[0060] For example, if K bit = 32 bits and m bit = 16 bits, then two data are read from the buffer unit in each cycle, and these two data are located in two adjacent first storage units and have the same position in the first storage units. For example, in one cycle, two data located in storage units B1 and B2 are read from the buffer unit, and these two data are located in the sth to tth bits of storage units B1 and B2, respectively. For example, these two data are respectively in sub-data unit B10 (bits 0 to 15) and sub-data unit B20 (bits 0 to 15), or respectively in sub-data units B11 (bits 16 to 32) and B21 (bits 16 to 32).
[0061] For example, the data stored in the sub-storage unit B10 is a, and the data stored in the sub-storage unit B11 is b. The data a and b in the buffers 212 and 232 are read from the buffer unit 202 and stored in the second storage unit C1.
[0062] For example, the data stored in the first storage cell with the lowest depth among the K / m adjacent first storage cells in a memory bank is located in the lower bits of the second storage cell. A memory typically stores data in ascending order of depth, storing the data stored in the first storage cell with the lowest depth in the lower bits of the second storage cell, thereby maintaining the order of the K / m data.
[0063] For example, if the depth of sub-data unit B10 is lower than that of sub-data unit B20, data a in sub-data unit B10 is stored in the lower bits of storage unit C1, and data b in sub-data unit B20 is stored in the higher bits of storage unit C1.
[0064] In some embodiments of the present disclosure, the buffer unit includes (K / m) 2 Buffer units include (K / m) 2 A consecutive array of buffers can be read and written in parallel and can also save the number of buffers.
[0065] In some embodiments of the present disclosure, for example, after the data in the first storage units of K / m depth are sequentially stored in the buffer unit, the data in the K / m sub-data units at the same position in the adjacent K / m first storage units in the storage body are read from the buffer unit.
[0066] For example, in the example of K / m=2, after the data in the first storage units of 2 depths are sequentially stored in the buffer unit, the data in the two sub-data units at the same position in the two adjacent first storage units in the memory bank are read from the buffer unit. Figure 2BAs shown, in the first cycle, the two data a and c in the storage unit B1 are stored in the buffer 212 and the buffer 222 respectively, and in the second cycle, the two data b and d in the storage unit B2 are stored in the buffer 232 and the buffer 242 respectively. Then, after the second cycle, the data a and the data b are read from the buffer unit 202.
[0067] In some embodiments of the present disclosure, after storing K / m depths of data in the buffer unit in sequence, data in K / m sub-data units at the same position in adjacent K / m first storage units in the storage body are read in parallel; and data in K / m sub-data units at the same position in adjacent K / m first storage units are written into the same second storage unit of the second memory.
[0068] For example, multiple sub-data units in a storage body are indexed in order of depth from small to large and position from small to large, and after the data in the first storage units of K / m depths are sequentially stored in the buffer unit, the data in the K / m sub-data units at the same position in the adjacent K / m first storage units in the storage body are read in parallel, including: from the first cycle to the K / m cycle, each cycle reads out data with index numbers (i-1)×K / m, ...K / m×i-1 from the storage body and stores it in the buffer unit, where i represents the cycle count value; and starting from the K / m+1 cycle, for each cycle, while reading out data with index numbers (i-1)×K / m, ...K / m×i-1 and storing it in the buffer unit, K / m data at the same position in the adjacent K / m first storage units in the storage body are read in parallel from the buffer unit. The following is combined with Figures 3A to 3G The method is illustrated by an embodiment.
[0069] Figure 3A to Figure 3G A schematic diagram of a method for rearranging data in a 16-bit format is provided for at least one embodiment of the present disclosure. Figure 3A to Figure 3G Only a schematic diagram of one memory bank is shown in FIG. 1 , and similar operations are performed on each memory bank in the local data memory.
[0070] like Figure 3A As shown, multiple first storage units of a storage body in the local data memory are consecutively indexed in order of depth from small to large and position from small to large, for example, the index numbers are index 0, index 1, index 2, index 3, index 4, index 5, index 6 and index 7 respectively.
[0071] When the data format is m bit=16 bits and K bit=32 bits, K / m=2.
[0072] In the first cycle (ie, i=1), data of index 0 and index 1 are read out from each memory bank and sent to the buffer.
[0073] In the second cycle (ie, i=2), the data of index 2 and index 3 are read out from each memory bank and sent to the buffer.
[0074] In the third cycle (i.e., i=3), the data of index 4 and index 5 are read from each memory bank and sent to the buffer. Simultaneously, the data of index 0 and index 2 are read from the buffer and sent to the vector general register array.
[0075] In the fourth cycle (i.e., i=4), the data of index 6 and index 7 are read from each memory bank and sent to the buffer. Simultaneously, the data of index 1 and index 3 are read from the buffer and sent to the vector general register array.
[0076] In the fifth cycle (i.e., i=5), the data of index 8 and index 9 are read from each memory bank and sent to the buffer. Simultaneously, the data of index 4 and index 6 are read from the buffer and sent to the vector general register array.
[0077] In the sixth cycle (i.e., i=6), the data at index 10 and index 11 are read from each memory bank and sent to the buffer. Simultaneously, the data at index 5 and index 7 are read from the buffer and sent to the vector general register array.
[0078] In cycle 7 (i.e., i=7), the data at indexes 12 and 13 are read from each memory bank and sent to the buffer. Simultaneously, the data at indexes 8 and 10 are read from the buffer and sent to the vector general register array. Aside from the differences in the indexes used for reading and writing, the hardware control logic remains the same as in cycle 3.
[0079] During the entire execution process, data is read from the local data memory in the "column direction" of the matrix, combined together in the "row direction", and then written into the vector memory array.
[0080] Figures 4A to 4M A schematic diagram of a method for rearranging data in an 8-bit format is provided for at least one embodiment of the present disclosure. Figures 4A to 4M Only a schematic diagram of one memory bank is shown in FIG. 1 , and similar operations are performed on each memory bank in the local data memory.
[0081] When the data format is m=8 and K=32, K / m=4.
[0082] In the first cycle (ie, i=1), data of index 0, index 1, index 2, and index 3 are read from each memory bank and sent to the buffer.
[0083] In the second cycle (ie, i=2), data of index 4, index 5, index 6, and index 7 are read from each memory bank and sent to the buffer.
[0084] In the third cycle (ie, i=3), data at index 8, index 9, index 10, and index 11 are read from each memory bank and sent to the buffer.
[0085] In the fourth cycle (ie, i=4), data of index 12, index 13, index 14, and index 15 are read from each memory bank and sent to the buffer.
[0086] In the fifth cycle (i.e., i=5), the data at index 16, index 17, index 18, and index 19 are read from each memory bank and sent to the buffer. Simultaneously, the data at index 0, index 4, index 8, and index 12 are read from the buffer and sent to the vector general register array.
[0087] In the sixth cycle (i.e., i=6), the data at index 20, index 21, index 22, and index 23 are read from each memory bank and sent to the buffer. Simultaneously, the data at index 1, index 5, index 9, and index 13 are read from the buffer and sent to the vector general register array.
[0088] In the 7th cycle (i.e., i=7), the data at index 24, index 25, index 26, and index 27 are read from each memory bank and sent to the buffer. Simultaneously, the data at index 2, index 6, index 10, and index 14 are read from the buffer and sent to the vector general register array.
[0089] In the eighth cycle (i.e., i=8), the data at indexes 28, 29, 30, and 31 are read from each memory bank and sent to the buffer. Simultaneously, the data at indexes 3, 7, 11, and 15 are read from the buffer and sent to the vector general register array.
[0090] In the ninth cycle (i.e., i=9), the data at indexes 32, 33, 34, and 35 are read from each memory bank and sent to the buffer. Simultaneously, the data at indexes 16, 20, 24, and 28 are read from the buffer and sent to the vector general register array.
[0091] In the 10th cycle (i.e., i=10), the data at indexes 36, 37, 38, and 39 are read from each memory bank and sent to the buffer. Simultaneously, the data at indexes 17, 21, 25, and 29 are read from the buffer and sent to the vector general register array.
[0092] In the 11th cycle (i.e., i=11), the data at index 40, index 41, index 42, and index 43 are read from each memory bank and sent to the buffer. Simultaneously, the data at index 18, index 22, index 26, and index 30 are read from the buffer and sent to the vector general register array.
[0093] In cycle 12 (i.e., i=12), data at indexes 44, 45, 46, and 47 are read from each memory bank and sent to the buffer. Simultaneously, data at indexes 19, 23, 27, and 31 are read from the buffer and sent to the vector general register array.
[0094] In cycle 13 (i.e., i = 13), data at indexes 48, 49, 50, and 51 are read from each bank and sent to the buffer. Simultaneously, data at indexes 32, 36, 40, and 44 are read from the buffer and sent to the vector general register array. Aside from the differences in the indexes used for reading and writing, the hardware control logic remains the same as in cycle 5.
[0095] During the entire execution process, data is read from the local data memory in the "column direction" of the matrix, combined in the "row direction", and then written into the vector memory array.
[0096] In other embodiments of the present disclosure, when the data format is m=4 and K=32, K / m=8, and from the first cycle to the eighth cycle, data indexed by (i-1)×K / m, ...K / m×i-1 are read from the memory bank in each cycle and stored in the buffer unit, where i represents the cycle count value; and starting from the ninth cycle, for each cycle, while data indexed by (i-1)×K / m, ...K / m×i-1 are read and stored in the buffer unit, 8 data at the same position in 8 adjacent first storage cells in the memory bank are read from the buffer unit in parallel. For m=4 bits and K=32, the implementations of m=8 and m=16 are similar and will not be repeated here.
[0097] Another aspect of the present disclosure provides a data transmission device for transmitting data from a first memory to a second memory, wherein the first memory includes a memory body with a depth of N, and the width of the first storage unit of the memory body at each depth is K bits; the second memory includes a plurality of consecutively arranged second storage units, and the width of the second storage unit is K bits.
[0098] Figure 5 A schematic block diagram of a data transmission device 500 provided by at least one embodiment of the present disclosure is shown.
[0099] like Figure 5As shown, the data transmission device 500 includes a reading unit 501 , a buffer unit 502 , and a writing unit 503 .
[0100] The reading unit 501 is configured to read the data stored in the first storage unit at each depth of N depths in turn, and store the data of N depths in the buffer unit 502 in turn. The data is m bits, and each first storage unit is divided into K / m sub-data units according to m bits from low to high.
[0101] The write unit 503 is configured to write the data in the storage body from the buffer unit to the second memory in a specified order, and the specified order includes: K / m data at the same position in adjacent K / m first storage units in the storage body are stored in the same second storage unit of the second memory.
[0102] In some embodiments of the present disclosure, the buffer unit 502 includes a plurality of registers, the read unit 501 includes a plurality of first multiplexers, and the write unit 503 includes a plurality of second multiplexers. Each of the plurality of registers is configured to store data read from a first storage unit. The plurality of first multiplexers is configured to read data stored in a first storage unit at each depth of N depths of each storage body, and sequentially store the data stored in the first storage unit at each depth into K / m registers in the plurality of registers. The plurality of second multiplexers is configured to select K / m data at the same position in adjacent K / m first storage units in the storage body from the plurality of registers, and write them into the same second storage unit of the second memory.
[0103] Each of the multiple registers acts as a buffer as described above.
[0104] Figure 6A At least one embodiment of the present disclosure provides a Figure 5 Schematic structural diagram of the data transmission device 500.
[0105] like Figure 6A As shown, the reading unit 501 includes a plurality of multiplexers, such as multiplexer 511, multiplexer 521, multiplexer 531, multiplexer 541, multiplexer 551, and multiplexer 561. Multiplexer 511, multiplexer 521, multiplexer 531, multiplexer 541, multiplexer 551, and multiplexer 561 are all examples of first multiplexers.
[0106] The buffer unit 502 includes a plurality of registers, including, for example, a register 512, a register 522, a register 532, and a register 542. Each register is a buffer.
[0107] The writing unit 503 includes a plurality of multiplexers, such as multiplexers 513, 523, 533, 543, 553, and 563. Multiple multiplexers such as multiplexers 513, 523, 533, 543, 553, and 563 are examples of second multiplexers.
[0108] exist Figure 6A Each square represents a register and each trapezoid represents a multiplexer.
[0109] Figure 6A Data transmission device 500 in the example is an example of a hardware structure corresponding to a single memory bank for rearranging 16-bit data. As described above, a single memory bank can correspond to four buffers, or four registers, each storing a 16-bit piece of data. This enables parallel processing of the buffer unit for writing and reading 16-bit data.
[0110] For read unit 501, for example, multiplexers 511 and 521 are both one-to-many multiplexers, i.e., one input terminal and multiple output terminals. Multiplexers 531, 541, 551, and 561 can be many-to-one multiplexers, i.e., multiple input terminals and one output terminal.
[0111] For example, the input end of the multiplexer 511 is coupled to the sub-data units located in the first row in the storage body (for example, the sub-data units of index 0, index 2, index 4 and index 6), and the output end of the multiplexer 511 is coupled to the multiplexer 531, the multiplexer 541 and the multiplexer 551, thereby receiving the first data of the sub-data units located in the first row in the storage body and outputting the first data to one of the multiplexer 531, the multiplexer 541 and the multiplexer 551.
[0112] The input end of the multiplexer 521 is coupled to the sub-data units located in the second row of the storage body (for example, the sub-data units of index 1, index 3, index 5 and index 7), and the output end of the multiplexer 521 is coupled to the multiplexer 541, the multiplexer 551 and the multiplexer 561, thereby receiving the second data of the sub-data units located in the second row of the storage body and outputting the second data to one of the multiplexer 541, the multiplexer 551 and the multiplexer 561.
[0113] Multiplexer 531, multiplexer 541, multiplexer 551 and multiplexer 561 are coupled to register 512, register 522, register 532 and register 542 in a one-to-one correspondence, so that the data provided by multiplexer 531, multiplexer 541, multiplexer 551 and multiplexer 561 are written into the corresponding registers respectively.
[0114] For the write unit 503 , for example, multiplexers 513 , 523 , 533 , and 543 are one-to-many multiplexers; multiplexers 553 and 563 may be many-to-one multiplexers.
[0115] The input terminals of multiplexers 513, 523, 533, and 543 are coupled to registers 512, 522, 532, and 542 in a one-to-one correspondence. The output terminal of multiplexer 513 is coupled to the input terminal of multiplexer 553. The output terminal of multiplexer 523 is coupled to the input terminals of multiplexers 553 and 563, respectively. The output terminal of multiplexer 533 is coupled to the input terminals of multiplexers 553 and 563, respectively. The output terminal of multiplexer 543 is coupled to the input terminal of multiplexer 563. The output terminal of multiplexer 553 is coupled to the first row of sub-data units of the second memory, and the output terminal of multiplexer 563 is coupled to the second row of sub-data units of the second memory.
[0116] For example, in the first cycle, multiplexer 511 and multiplexer 521 receive data in the sub-data unit of index 0 and the sub-data unit of index 1 from the storage unit of depth 0 in the storage body of the first memory, respectively. For the sake of ease of description and understanding below, it is assumed that the data stored in index x is x, and x is a positive integer. In the first cycle, multiplexer 511 and multiplexer 521 receive data 0 in the sub-data unit of index 0 and data 1 in the sub-data unit of index 1 in the storage unit of depth 0. In addition, multiplexer 511 writes data 0 into register 512 via multiplexer 531; multiplexer 521 writes data 1 into register 522 via multiplexer 541.
[0117] In the second cycle, multiplexers 511 and 521 receive data 2 from the sub-data unit with index 2 and data 3 from the sub-data unit with index 3 in the memory unit with depth 1. Furthermore, multiplexer 511 writes data 2 into register 532 via multiplexer 551; multiplexer 521 writes data 3 into register 542 via multiplexer 561.
[0118] In the third cycle, multiplexer 513 receives data 0 from register 512 and provides data 0 to the lower 16 bits of the memory cell with a depth of 0 in the second memory via multiplexer 553. Multiplexer 533 receives data 2 from register 532 and provides data 2 to the upper 16 bits of the memory cell with a depth of 0 in the second memory via multiplexer 563. Simultaneously, multiplexers 511 and 521 receive data 4 from the sub-data unit with an index of 4 and data 5 from the sub-data unit with an index of 5 in the memory cell with a depth of 2. Multiplexer 511 writes data 4 to register 512 via multiplexer 531, and multiplexer 521 writes data 5 to register 532 via multiplexer 551.
[0119] In the fourth cycle, multiplexer 523 receives data 1 from register 522 and provides data 1 to the lower 16 bits of the storage unit with a depth of 1 in the second memory via multiplexer 553. Multiplexer 543 receives data 3 from register 542 and provides data 3 to the upper 16 bits of the storage unit with a depth of 1 in the second memory via multiplexer 563. At the same time, multiplexers 511 and 521 receive data 6 from the sub-data unit with an index of 6 and data 7 from the sub-data unit with an index of 7 in the storage unit with a depth of 3. Multiplexer 511 writes data 6 to register 522 via multiplexer 541, and multiplexer 521 writes data 7 to register 542 via multiplexer 561.
[0120] In each subsequent cycle, the multiplexer and the register cooperate to perform similar operations as above, so that the data transmission device 500 completes Figure 3A to Figure 3G The steps are not repeated here.
[0121] Figure 6B A schematic structural diagram of another data transmission device 600 provided by at least one embodiment of the present disclosure is shown.
[0122] Figure 6B Data transmission device 600 in the figure is an example of a hardware structure corresponding to a single memory bank for rearranging 8-bit data. As described above, a single memory bank can correspond to 16 buffers, or 16 registers, each storing an 8-bit piece of data. This enables parallel processing of the buffer unit for writing and reading 8-bit data.
[0123] Figure 6BIn the example of , the read unit 601 includes, for example, 4 one-to-many multiplexers 611 and 16 many-to-1 multiplexers 621; the buffer unit 602 includes, for example, 16 registers 612; the write unit 603 includes, for example, 16 one-to-many multiplexers 613 and 4 many-to-one multiplexers 623. Similarly, in Figure 6A Each square represents a register and each trapezoid represents a multiplexer.
[0124] The operations performed by the multiplexers 611 and the multiplexers 621 in the read unit 601 are similar to those performed by Figure 6A Multiple multiplexers in the read unit; the operations performed by the 16 registers 612 are similar to Figure 6A The operations performed by the registers 512, 522, 532, and 542 in the write unit 603 and the multiplexers 613 and 623 in the write unit 603 are similar to those performed by the registers 512, 522, 532, and 542 in the write unit 603. Figure 6A The write unit 503 includes multiple multiplexers. These multiplexers and registers work together to complete Figures 4A to 4M Describe the steps.
[0125] It should be noted that Figure 6A and Figure 6B This is only a schematic hardware structure diagram and does not limit the embodiments of the present disclosure. The hardware structure in actual application may be more or less than Figure 6A and Figure 6B The hardware structure is shown.
[0126] Figure 6A and Figure 6B The embodiment of the present disclosure is described by taking the example of transferring data in one memory bank in the first memory to the second memory. However, in actual applications, the first memory usually includes multiple memory banks, and each memory bank can be executed separately. Figure 6A or Figure 6B The described embodiment.
[0127] Figure 6A and Figure 6B The embodiments of the present disclosure are described using examples of simultaneous rearrangement of 16-bit data transmission and simultaneous rearrangement of 8-bit data transmission, respectively. However, this does not limit the present disclosure. The embodiments of the present disclosure are also applicable to, for example, 4-bit data transmission and rearrangement, 32-bit data transmission and rearrangement, etc. Those skilled in the art can adaptively modify the embodiments provided in the present disclosure for use in 4-bit data transmission and rearrangement, 32-bit data transmission and rearrangement, etc.
[0128] In some embodiments of the present disclosure, the first memory includes P memory banks, the number of buffer units is P, each buffer unit includes a preset number of registers, the P memory banks correspond to the P buffer units one-to-one, and P is a positive integer. The preset number is a positive integer greater than or equal to K / m. For example, each buffer unit includes K / m registers as K / m buffers, and P memory banks require P buffer units, which means P*(K / m) buffers are required. For example, each buffer unit may include (K / m) 2 registers.
[0129] The hardware structure in the embodiments of the present disclosure can simultaneously rearrange data during the data reading process, so that this step of rearranging data does not take up additional time, thereby improving the efficiency of data reading. In addition, the matrix rearrangement hardware structure of the present invention is applicable to local data memories with a configurable number of memory banks, meeting the needs of local data memories with different bit widths (bandwidths); and the hardware structure in the embodiments of the present disclosure is applicable to matrix operations in various data formats, including but not limited to 16-bit, 8-bit, and 4-bit.
[0130] In an embodiment of the present disclosure, the data transmission device hardware structure includes a hardware structure of P single memory banks, where the number P is consistent with the number of memory banks in the local data memory. The data transmission device input comes from the local data memory, and the data transmission device output is sent to the vector general register array.
[0131] The resources and connections of each single-bank hardware structure vary depending on whether the matrix data format is 16-bit, 8-bit, or 4-bit. If the data is 16-bit (such as Figure 6A As shown in the figure), the input data will be sent to 4*P 16-bit buffers in a specific cycle according to a specific connection relationship, and then output from the buffer in a specific order. Figure 6B As shown in Figure 1, input data is fed into 16*P 8-bit buffers at a specific cycle according to a specific connection relationship, and then output from the buffers in a specific order. Similarly, if the data is 4 bits, the input data is fed into 64*P 4-bit buffers at a specific cycle according to a specific connection relationship, and then output from the buffers in a specific order.
[0132] It should be noted that in the embodiment of the present disclosure, the various units of the data transmission device correspond to the various steps of the aforementioned data transmission method. For the specific functions of the data transmission device, please refer to the relevant description of the data transmission method, which will not be repeated here. Figure 5 The data transmission device 500 and Figure 6BThe components and structures of the data transmission device shown are merely exemplary and non-limiting. The data transmission device may further include other components and structures as needed.
[0133] Figure 7 A schematic block diagram of an electronic device 700 provided by at least one embodiment of the present disclosure is shown.
[0134] For example, Figure 7 As shown, the electronic device 700 includes a data transmission device 710 , a first memory 720 and a second memory 730 .
[0135] The data transmission device 710 is, for example, a data transmission device provided by any embodiment of the present disclosure. For example, the data transmission device 710 may be Figure 6A or Figure 6B The first memory 720 is coupled to the data transmission device 710 , and the data transmission device 710 is coupled to the second memory 730 .
[0136] The first memory 720 is, for example, Figure 1B The local data memory shown, the second memory 730 is for example Figure 1B Vector general register array.
[0137] The data transmission device 710 is used to transmit data from a first memory to a second memory, where the first memory includes a memory body with a depth of N, and the width of the first storage unit at each depth of the memory body is K bits. The second memory includes multiple consecutively arranged second storage units, and the width of the second storage unit is K bits. The method includes: reading the data stored in the first storage unit at each depth of N depths in sequence, and storing the data of N depths in a buffer unit in sequence, where the data is m bits, and each first storage unit is divided into K / m sub-data units from low to high bits according to m bits; and writing the data in the memory body from the buffer unit to the second memory in a specified order, and the specified order includes: K / m data at the same position in adjacent K / m first storage units in the memory body are stored in the same second storage unit of the second memory.
[0138] This electronic device can simultaneously rearrange data during the data reading process, eliminating the need for extra time to rearrange data, thereby improving data reading efficiency. Furthermore, the matrix rearrangement hardware structure of the present invention is applicable to local data memories with a configurable number of memory banks, meeting the needs of local data memories with different bit widths (bandwidths). Furthermore, the hardware structure of the disclosed embodiments is applicable to matrix operations on a variety of data formats, including but not limited to 16-bit, 8-bit, and 4-bit formats.
[0139] For example, in addition to being implemented in hardware, in other embodiments of the present disclosure, the data transmission device 710 may be implemented in hardware, software, firmware, or any feasible combination thereof. For example, the data transmission device 710 may be a dedicated or general-purpose circuit, chip, or device. The embodiments of the present disclosure do not limit the specific implementation of each of the above-mentioned units.
[0140] There are a few points to note:
[0141] (1) The drawings of the embodiments of the present disclosure only relate to the structures involved in the embodiments of the present disclosure. Other structures may refer to conventional designs.
[0142] (2) In the absence of conflict, the embodiments of the present disclosure and the features therein may be combined with each other to form new embodiments.
[0143] The above description is only a specific embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. The protection scope of the present disclosure shall be based on the protection scope of the claims.
Claims
1. A data transmission method for transmitting data from a first memory to a second memory, wherein the first memory includes a memory bank having a depth of N, wherein a first storage unit at each depth of the memory bank has a width of K bits, and the second memory includes a plurality of consecutively arranged second storage units, wherein the width of the second storage units is K bits. The method comprises: Sequentially read the data stored in the first storage unit at each depth of N, and Sequentially storing N depths of data into the buffer unit, wherein the data is m bits, and each first storage unit is divided into K / m sub-data units according to m bits from low to high, wherein N, K, and m are all positive integers; and writing the data in the memory bank from the buffer unit to the second memory in a specified order, The specified order includes: K / m pieces of data at the same position in adjacent K / m first storage units in the memory bank are stored in the same second storage unit of the second memory, Wherein, the buffer unit includes (K / m) 2 consecutively arranged buffers, each buffer being used to store m bits of data, Writing the data in the memory bank from the buffer unit to the second memory in a specified order includes: After sequentially storing the data in the first storage units of K / m depth into the buffer unit, reading in parallel the data in the K / m sub-data units at the same position in the adjacent K / m first storage units in the memory bank; and The data in the K / m sub-data units at the same position in the adjacent K / m first storage units are written into the same second storage unit in the second memory.
2. The method according to claim 1, wherein Data stored in a first storage unit with a lower depth among the adjacent K / m first storage units in the memory bank is located at a lower bit in the second storage unit.
3. The method according to claim 1 or 2, wherein: Sequentially reading data stored in a first storage unit at each of the N depths, including: The data stored in the first storage unit at each of the N depths are read sequentially in depth order, and the data in the K / m sub-data units stored in the same first storage unit are read in parallel.
4. The method according to claim 1, wherein Continuously index and number the multiple sub-data units in the storage body in the order of depth from small to large and position from small to large, After sequentially storing data in first storage units of K / m depths into a buffer unit, reading data in K / m sub-data units at the same position in adjacent K / m first storage units in the memory bank in parallel, comprising: From the first cycle to the K / mth cycle, in each cycle, data in the sub-data unit with index numbers (i-1)×K / m, ...K / m×i-1 is read from the memory bank and stored in the buffer unit, where i represents a cycle count value; and Starting from the K / m+1th cycle, for each cycle, the index number (i-1) is read out. ×K / m, ...K / m×i-1 sub-data units, and store them in the buffer unit, while reading K / m data at the same position in the adjacent K / m first storage units in the storage body from the buffer unit in parallel.
5. A data transmission device for transmitting data from a first memory to a second memory, wherein the first memory includes a memory bank having a depth of N, wherein a first storage unit at each depth of the memory bank has a width of K bits, and the second memory includes a plurality of consecutively arranged second storage units, wherein the width of the second storage units is K bits, the device comprising: Buffer unit; a reading unit configured to sequentially read data stored in a first storage unit at each of the N depths, and sequentially store the data at the N depths into the buffer unit, wherein the data is m bits, and each first storage unit is divided into K / m sub-data units according to m bits from low to high, wherein N, K, and m are all positive integers; and a writing unit configured to write the data in the storage body from the buffer unit to the second memory in a specified order, The specified order includes: K / m pieces of data at the same position in adjacent K / m first storage units in the memory bank are stored in the same second storage unit of the second memory, Wherein, the buffer unit includes (K / m) 2 registers are arranged in series, each register is configured to store the m bits of data read from the first storage unit, the reading unit includes a plurality of first multiplexers, the writing unit includes a plurality of second multiplexers, and the writing of the data in the storage body from the buffer unit to the second memory in a specified order includes: After sequentially storing the data in the first storage unit at each of the K / m depths into the K / m registers through the plurality of first multiplexers, reading in parallel from the registers the data in the K / m sub-data units at the same position in the adjacent K / m first storage units in the memory bank through the plurality of second multiplexers; and The data in the K / m sub-data units at the same position in the adjacent K / m first storage units are written into the same second storage unit in the second memory.
6. The device according to claim 5, wherein The first memory includes P storage banks, the number of the buffer units is P, and the P storage banks and the P buffer units correspond one to one, wherein P is a positive integer.
7. An electronic device comprising: The data transmission device according to claim 5 or 6; the first memory; as well as the second memory, The first memory is coupled to the data transmission device, and the data transmission device is coupled to the second memory.
Citation Information
Patent Citations
Matrix transposition method
CN117056266A
Cited By
Data transmission method, data transmission apparatus and electronic device
EP4718268A1
Data transmission method, data transmission apparatus and electronic device
WO2025123611A1