Data bit width conversion method, device, electronic device and storage medium
By calculating the bit width conversion ratio and determining the bit width of each cache unit, ensuring that each data port occupies the same resource space in the cache unit, solving the problem of resource waste in the existing technology and achieving efficient data bit width conversion sex.
Patent Information
- Application Number
- CN202311617764.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-29
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2043-11-29
AI Technical Summary
In the prior art, when converting data bit width, each interface needs to set up an independent cache unit, resulting in waste of resources.
By calculating the bit width conversion ratio, multiple cache units are determined, and the bit width of each cache unit is the same as the small bit width port, ensuring that each data port occupies the same resource space in each cache unit, thereby realizing the sharing of cache units , avoid wasting resources.
It effectively avoids the problem of idle cache units when there is no data on one or more ports, improves resource utilization and reduces resource waste.
Smart Images

Figure CN117743234B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a data bit width conversion method, device, electronic device and storage medium. Background Art
[0002] The communication system includes various communication devices, which often involve various modules. When modules or components with different functions are connected, the bit widths are unequal. Therefore, when transmitting data, the data bit widths between input and output interfaces need to be converted.
[0003] In the prior art, when performing data bit width conversion, each interface needs to be provided with an independent cache unit for bit width conversion, resulting in a waste of resources. Summary of the invention
[0004] In order to avoid wasting resources, the present application provides a data bit width conversion method, device, electronic device and storage medium.
[0005] In a first aspect, the present application provides a data bit width conversion method, comprising:
[0006] Acquire a first bit width of a first port and a second bit width of a second port, and calculate a bit width conversion ratio according to the first bit width and the second bit width, wherein the first bit width is smaller than the second bit width;
[0007] Determining a plurality of cache units according to the bit width conversion ratio, wherein the bit width of each cache unit in the plurality of cache units is equal to the first bit width;
[0008] If data is transmitted from the first port to the second port, determine the resource space occupied by the data of each first port respectively, and write the data of each first port into the multiple cache units according to the resource space occupied by the data of each first port respectively; wherein the resource space occupied by the data of each first port in each cache unit of the multiple cache units is the same;
[0009] The data stored in the plurality of cache units are read from the plurality of cache units.
[0010] As an optional implementation of the embodiment of the present application, writing the data of each first port into the multiple cache units according to the resource space respectively occupied by the data of each first port includes:
[0011] For each first port, determine the resource space occupied by the data of the first port in each cache unit according to the resource space occupied by the data of the first port and the number of the cache units;
[0012] The data of the first ports are sequentially written into the plurality of cache units according to the data writing timing information of the first ports and the resource space respectively occupied by the data of the first ports in each cache unit.
[0013] As an optional implementation of the embodiment of the present application, the method further includes:
[0014] If data is transmitted from the second port to the first port, determine the resource space occupied by the data flowing to each first port, and write the data into the multiple cache units according to the resource space occupied by the data flowing to each first port; wherein, for each first port, the resource space occupied by the data flowing to the first port in each cache unit is the same.
[0015] As an optional implementation of the embodiment of the present application, writing data into the multiple cache units according to the resource space respectively occupied by the data flowing to each first port includes:
[0016] For each first port, determine the resource space occupied by the data flowing to the first port in each cache unit according to the resource space occupied by the data flowing to the first port and the number of the cache units;
[0017] The data is written into the plurality of cache units according to the resource space respectively occupied by the data flowing to the first port in each cache unit.
[0018] As an optional implementation of the embodiment of the present application, the reading of data stored in the multiple cache units from the multiple cache units includes:
[0019] Obtaining data read timing information of each first port;
[0020] According to the data reading timing information, the data in the plurality of cache units are read sequentially from the plurality of cache units through the first ports.
[0021] As an optional implementation of the embodiment of the present application, the calculating the bit width conversion ratio according to the first bit width and the second bit width includes:
[0022] The ratio of the second bit width to the first bit width is obtained to obtain the bit width conversion ratio.
[0023] As an optional implementation of the embodiment of the present application, the determining of a plurality of cache units according to the bit width conversion ratio and the number of the first ports includes:
[0024] The number of cache units is determined according to the value of the bit width conversion ratio, and a plurality of cache units are set according to the number of cache units.
[0025] In a second aspect, the present application provides a data bit width conversion device, comprising:
[0026] An address management module, configured to obtain a first bit width of a first port and a second bit width of a second port, and calculate a bit width conversion ratio according to the first bit width and the second bit width, wherein the first bit width is smaller than the second bit width;
[0027] The address management module is further used to determine a plurality of cache units according to the bit width conversion ratio, wherein the bit width of each cache unit in the plurality of cache units is equal to the first bit width; and if data is transmitted from the first port to the second port, to determine the resource space occupied by the data of each first port respectively;
[0028] A control module, configured to write the data of each first port into the plurality of cache units according to the resource spaces respectively occupied by the data of each first port; wherein the resource spaces occupied by the data of each first port in each cache unit of the plurality of cache units are the same;
[0029] The control module is further used to read the data stored in the multiple cache units from the multiple cache units.
[0030] As an optional implementation of the embodiment of the present application, the control module includes: a data control module;
[0031] The address management module is specifically used for the timing control module to determine, for each first port, the resource space occupied by the data of the first port in each cache unit according to the resource space occupied by the data of the first port and the number of the cache units;
[0032] The data control module is used to write the data of the first ports into the multiple cache units in sequence according to the data writing timing information of each first port and the resource space occupied by the data of the first port in each cache unit.
[0033] As an optional implementation of the embodiment of the present application, if data is transmitted from the second port to the first port, the address management module is further used to determine the resource space occupied by the data flowing to each first port;
[0034] The data control module is further used to write data into the multiple cache units according to the resource space occupied by the data flowing to each first port; wherein, for each first port, the resource space occupied by the data flowing to the first port in each cache unit is the same.
[0035] As an optional implementation of the embodiment of the present application, the address management module is specifically used to determine, for each first port, the resource space occupied by the data flowing to the first port in each cache unit according to the resource space occupied by the data flowing to the first port and the number of the cache units;
[0036] The data control module is specifically configured to write data into the plurality of cache units according to the resource space respectively occupied by the data flowing to the first port in each cache unit.
[0037] As an optional implementation of the embodiment of the present application, the control module includes: a timing control module;
[0038] The timing control module is used to obtain data reading timing information of each first port;
[0039] The data control module is specifically configured to read the data in the plurality of cache units in sequence from the plurality of cache units through the first ports according to the data reading timing information.
[0040] As an optional implementation of the embodiment of the present application, the address management module is specifically used to obtain the ratio of the second bit width to the first bit width to obtain the bit width conversion ratio.
[0041] As an optional implementation of the embodiment of the present application, the address management module is specifically used to determine the number of cache units according to the value of the bit width conversion ratio, and set a plurality of cache units according to the number of cache units.
[0042] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory and a processor, the memory being used to store a computer program, the processor being used to execute the data bit width conversion method described in the first aspect or any optional implementation of the first aspect when calling the computer program.
[0043] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the data bit width conversion method described in the first aspect or any optional implementation of the first aspect is implemented.
[0044] Compared with the prior art, the technical solution provided by the embodiments of the present application has the following advantages:
[0045] The data bit width conversion method provided in the embodiment of the present application includes:
[0046] Obtain the first bit width of the first port and the second bit width of the second port, calculate the bit width conversion ratio according to the first bit width and the second bit width, wherein the first bit width is smaller than the second bit width; determine multiple cache units according to the bit width conversion ratio, wherein the bit width of each cache unit in the multiple cache units is equal to the first bit width; if data is transmitted from the first port to the second port, determine the resource space occupied by the data of each first port respectively, and write the data of each first port into the multiple cache units according to the resource space occupied by the data of each first port respectively; wherein the resource space occupied by the data of each first port in each cache unit of the multiple cache units is the same; read the data stored in the multiple cache units from the multiple cache units. Since the data of each first port is written into each cache unit and the resource space occupied in each cache unit is the same, when one or more first ports have no data, the space occupied by the one or more ports in the cache unit can be vacated for the first port with data, thereby avoiding resource waste. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0048] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0049] Figure 1 A flowchart of a method for converting data bit width provided in one embodiment of the present application;
[0050] Figure 2 A schematic diagram of the output direction of a data bit width conversion device provided by another embodiment of the present application;
[0051] Figure 3 A timing diagram of the output direction of a data bit width conversion device provided by one embodiment of the present application;
[0052] Figure 4 A schematic diagram of the output direction of a data bit width conversion device provided by an embodiment of the present application;
[0053] Figure 5 A timing diagram of the output direction of a data bit width conversion device provided by one embodiment of the present application;
[0054] Figure 6A structural block diagram of a data bit width conversion device provided by another embodiment of the present application;
[0055] Figure 7 An internal structure diagram of an electronic device provided for one embodiment of the present application. DETAILED DESCRIPTION
[0056] In order to make the purpose, implementation mode and advantages of the present application clearer, the exemplary implementation mode of the present application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only part of the embodiments of the present application, rather than all the embodiments.
[0057] Based on the exemplary embodiments described in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the claims attached to this application. In addition, although the disclosure in this application is introduced according to one or several exemplary examples, it should be understood that each aspect of these disclosures can also constitute a complete implementation method separately. It should be noted that the brief description of the terms in this application is only for the convenience of understanding the implementation methods described below, and is not intended to limit the implementation methods of this application. Unless otherwise specified, these terms should be understood according to their common and usual meanings.
[0058] First, the application scenario of the embodiment of the present application is described exemplarily. When data is transmitted inside a communication device or between communication devices, if the bit widths of the output data port and the input data port are different, a bit width conversion is required. At present, when performing data bit width conversion, each port needs to set up an independent cache for bit width conversion. For example, if there are 4 small bit width ports and 1 large bit width port in the communication system, the small bit width port needs to transmit data to the large bit width port. When performing bit width conversion, 4 cache units need to be set up, each cache unit corresponds to a small bit width port, that is, the data of each small bit width port will be cached to the corresponding cache unit, and the large bit width port completes the data transmission by reading data in parallel in the 4 cache units. However, since the cache unit is the exclusive cache space of the corresponding small bit width port, when one or more small bit width ports have no data, the corresponding cache unit will be idle, resulting in a waste of resources.
[0059] Based on this, an embodiment of the present application provides a data bit width conversion method, which realizes the sharing of cache units by writing the data of each port into multiple cache units, thereby avoiding resource waste.
[0060] The data bit width conversion method provided by the present application will be described and elaborated below through specific exemplary embodiments. The data bit width conversion method provided by the present application can be executed by the electronic device provided by the embodiment of the present application, or the data bit width conversion device.
[0061] Figure 1 A flow chart of a data bit width conversion method provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the data bit width conversion method provided in this embodiment includes the following steps S11 to S13.
[0062] S11 . Obtain a first bit width of a first port and a second bit width of a second port, and calculate a bit width conversion ratio according to the first bit width and the second bit width.
[0063] The first bit width is smaller than the second bit width, that is, the first port is a small bit width port relative to the second port, and the bit width conversion ratio is the ratio between the data bit width of the large bit width port and the data bit width of the small bit width port.
[0064] Exemplarily, the bit width conversion ratio is obtained by obtaining a quotient of the second bit width and the first bit width. For example, if the first port is a 64-bit port and the second port is a 256-bit port, the bit width conversion ratio is 4.
[0065] S12: Determine a plurality of cache units according to the bit width conversion ratio and the bit width of the first port.
[0066] Exemplarily, the number of cache units is determined according to the value of the bit width conversion ratio, and a plurality of cache units are set according to the number of cache units.
[0067] The bit width of each cache unit in the plurality of cache units is equal to the first bit width.
[0068] Continuing with the above example, if the first port is a 64-bit port, the second port is a 256-bit port, and the bit width conversion ratio is 4, 4 cache units are required. The cache unit described in the embodiment of the present application can be a RAM (random-access memory) or other memory devices, which is not specifically limited in the embodiment of the present application.
[0069] If data is transmitted from the first port to the second port, that is, the small bit width port is the input data port and the large bit width port is the output data port, it is necessary to write the data of multiple first ports into multiple cache units, and output the data stored in the cache units from the cache units to the second port, and execute the following step S13; if data is transmitted from the second port to the first port, the large bit width port is the input data port and the small bit width port is the output data port, it is necessary to write the data of the second port into multiple cache units, and output the data stored in the cache units from the cache units to multiple first ports, and execute the following step S14.
[0070] S13: Determine the resource space respectively occupied by the data of each first port, and write the data of each first port into the multiple cache units according to the resource space respectively occupied by the data of each first port.
[0071] The data of each first port occupies the same resource space in each cache unit of the multiple cache units.
[0072] Exemplarily, for each first port, the resource space occupied by the data of the first port in each cache unit is determined according to the resource space occupied by the data of the first port and the number of the cache units; and the data of the first port is written into the multiple cache units in sequence according to the data write timing information of each first port and the resource space occupied by the data of the first port in each cache unit.
[0073] For example, when the first port includes 4 input data ports, for each first port, the required cache space is calculated according to the data length of the first port. If it is determined that the data of the input data port requires 8 spaces, and the number of cache units is 4, the data of the input data port requires 2 spaces in each cache unit. Then, the data of the input data port is written into the 4 cache units, occupying 2 spaces in each cache unit.
[0074] Combination Figure 2 As shown, Figure 2 A schematic diagram of the output direction of a data bit width conversion device provided for an embodiment of the present application, in this example, a first port includes four 64-bit input data ports (four first ports) and a second port includes one 256-bit output data port (one second port) as an example, each port corresponds to a data channel, that is, the first port corresponds to four data channels ch0, ch1, ch2, ch3, and the second port corresponds to one data channel ch_all, and the bit width conversion ratio determines that four cache units (RAM0, RAM1, RAM2, RAM3) are required, that is, the data bit width conversion system includes: a channel group consisting of five data channels (ch0, ch1, ch2, ch3, ch_all), a RAM group consisting of four RAMs, Figure 2 The A side shown in FIG. 1 is the first port side, and the B side is the second port side.
[0075] Exemplarily, four cache units with a bit width of 64 bits are generated according to the bit width conversion ratio, and each cache unit has the same bit width and the same depth, for example, the depth is 16. The resource space occupied by the four channels is calculated according to the data length of each data channel, such as: the data of channel 0 occupies 3 spaces, the data of channel 1 occupies 2 spaces, the data of channel 2 occupies 4 spaces, and the data of channel 3 occupies 1 space. That is, the data of channel 0 occupies 3 spaces in each cache unit, the data of channel 1 occupies 2 spaces in each cache unit, the data of channel 2 occupies 4 spaces in each cache unit, and the data of channel 3 occupies 1 space in each cache unit. That is, the four ports included in the first port side share four cache units, so when one or more ports have no data, the space occupied by the one or more ports in the cache unit can be vacated for use by ports with data, thereby avoiding waste of resources.
[0076] Specifically, the data write timing information includes multiple write start signals. When writing the data of each first port to multiple cache units, it is necessary to determine the write start signal corresponding to the first port. Exemplarily, for each first port, the data of the first port is written to each cache unit in turn according to the write start signal corresponding to the first port.
[0077] Following the above example, refer to Figure 3 As shown, Figure 3 The output direction timing diagram of the data bit width conversion device provided in one embodiment of the present application, each data channel corresponding to the first port starts to write data into the cache unit according to the corresponding write start signal, wherein the write start signal can be generated by the channel round-robin counter in the data bit width conversion device, and the channel round-robin counter is controlled by the timing control module. The write start signal is as follows: Figure 3 As shown in the ch_cnt, ch0_start, ch1_start, ch2_start, ch3_start signals in the A side (first port side), the data is sequentially written into the 4 RAMs according to the write start signals of the respective channels. Each time each channel writes 64 bits of data into the RAM, it switches to the next RAM, and so on, to achieve the synchronous write operation of the 4 channels. Exemplarily, after receiving the write start signal of channel 0, the data of channel 0 is started to be written, and after the data of channel 0 is written into ram0, the data of channel 0 is then written into ram1. While channel 0 is writing the data of ram1, channel 1 starts to write the data of ram0. While channel 0 is writing the data of ram2, channel 1 starts to write the data of ram1, and channel 2 starts to write the data of ram0... As shown in the figure Figure 3As shown in the ch0_data[63:0], ch1_data[63:0], ch2_data[63:0], ch3_data[63:0] signals in FIG. Since the data write operations of the four channels are performed synchronously and do not conflict with each other, the data transmission efficiency is improved.
[0078] S14: Determine the resource space respectively occupied by the data flowing to each first port, and write the data into the multiple cache units according to the resource space respectively occupied by the data flowing to each first port.
[0079] For each first port, the resource space occupied by the data flowing to the first port in each cache unit is the same.
[0080] Exemplarily, for each first port, the resource space occupied by the data flowing to the first port in each cache unit is determined based on the resource space occupied by the data flowing to the first port and the number of the cache units; and the data is written into the multiple cache units based on the resource space occupied by the data flowing to the first port in each cache unit.
[0081] For example, when the first port includes four data output ports, for each first port, the corresponding cache space is calculated according to the length of the data flowing to the first port. If it is determined that the data flowing to the first port requires eight spaces, and the number of cache units is four, the data flowing to the first port requires two spaces in each cache unit. Then, the data flowing to the first port is written into the four cache units, occupying two spaces in each cache unit.
[0082] Combination Figure 4 As shown, Figure 4 A schematic diagram of the output direction of a data bit width conversion device provided for an embodiment of the present application, in which the first port includes four 64-bit output data ports (four first ports) and the second port includes one 256-bit input data port (one second port) as an example, each port corresponds to a data channel, that is, the first port corresponds to four data channels ch0, ch1, ch2, ch3, and the second port corresponds to one data channel ch_all. It is determined by the bit width conversion ratio that four cache units (RAM0, RAM1, RAM2, RAM3) are required, that is, the data bit width conversion system includes: a channel group consisting of five data channels (ch0, ch1, ch2, ch3, ch_all), a RAM group consisting of four RAMs, Figure 4 The A side shown in FIG. 1 is the first port side, and the B side is the second port side.
[0083] Exemplarily, four cache units with a bit width of 64 bits are generated according to the bit width conversion ratio, and each cache unit has the same bit width and depth, for example, the depth is 16. The resource space occupied by the four channels is calculated according to the data length of each data channel, such as: the data of channel 0 occupies 3 spaces, the data of channel 1 occupies 2 spaces, the data of channel 2 occupies 4 spaces, and the data of channel 3 occupies 1 space. That is, the data of channel 0 occupies 3 spaces in each cache unit, the data of channel 1 occupies 2 spaces in each cache unit, the data of channel 2 occupies 4 spaces in each cache unit, and the data of channel 3 occupies 1 space in each cache unit. That is, the four cache units are shared cache units, and each data output port reads data from each cache unit, that is, as long as one data output port needs to read data, the four cache units are all in use, and the space corresponding to the port without data in the cache unit can be used by other ports, avoiding resource waste.
[0084] S15. Reading data stored in the multiple cache units from the multiple cache units.
[0085] When reading data, the data reading timing information of each first port is obtained; according to the data reading timing information, the data in the multiple cache units are read sequentially from the multiple cache units through the first ports. The data reading timing information may include a read start signal corresponding to each first port, and when a first port receives the read start signal, it starts to read data from the four cache units sequentially.
[0086] Following the above example, refer to Figure 5 As shown, Figure 5 The output direction timing diagram of the data width conversion device provided by an embodiment of the present application, each data channel corresponding to the first port starts to read data from the cache unit according to the corresponding read start signal, wherein the read start signal can be generated by the channel round robin counter in the data width conversion system, and the channel round robin counter is controlled by the timing control module. After the data on the B side is written, the timing control module generates a channel round robin counter for generating the read start signal of the four channels on the A side, such as Figure 5 As shown in the ch_cnt, ch0_start, ch1_start, ch2_start, ch3_start signals. Side A reads data from the four RAMs in turn according to the read start signals of each channel. Each time each channel reads 64 bits of data from the RAM, it switches to the next RAM, and so on, realizing the synchronous read operation of the four channels, as shown in the following figure. Figure 5As shown in the ch0_data[63:0], ch1_data[63:0], ch2_data[63:0], ch3_data[63:0] signals, the data read operations of the four channels are performed synchronously and do not conflict with each other, thereby improving the data transmission efficiency.
[0087] The embodiment of the present application provides a data bit width conversion method, which includes: obtaining a first bit width of a first port and a second bit width of a second port, calculating a bit width conversion ratio according to the first bit width and the second bit width, wherein the first bit width is smaller than the second bit width; determining multiple cache units according to the bit width conversion ratio, wherein the bit width of each cache unit in the multiple cache units is equal to the first bit width; if data is transmitted from the first port to the second port, determining the resource space occupied by the data of each first port respectively, and writing the data of each first port into the multiple cache units according to the resource space occupied by the data of each first port respectively; wherein the resource space occupied by the data of each first port in each cache unit of the multiple cache units is the same; reading the data stored in the multiple cache units from the multiple cache units. Since the data of each first port is written into each cache unit and the resource space occupied in each cache unit is the same, when one or more first ports have no data, the space occupied by the one or more ports in the cache unit can be vacated for the first port with data, thereby avoiding resource waste.
[0088] Based on the same inventive concept, as an implementation of the above method, an embodiment of the present application also provides a data bit width conversion device for executing the above embodiment, and the device embodiment corresponds to the above method embodiment.
[0089] Reference Figure 6 As shown, Figure 6 A structural block diagram of a data bit width conversion device provided for an embodiment of the present application, the data bit width conversion device includes: an address management module and a control module, the control module may include: a data control module and a timing control module, the data control module is used to control reading data or writing data, such as controlling the data of channels ch0, ch1, ch2, ch3, and ch_all to be written into cache units RAM0, RAM1, RAM2, RAM3, or controlling the data to be read from cache units RAM0, RAM1, RAM2, RAM3, the timing control module is used to generate data writing control logic or data reading control logic.
[0090] The present device embodiment will not repeat the details of the aforementioned method embodiment one by one, but it should be clear that the data bit width conversion device in the present embodiment can implement all the contents of the aforementioned method embodiment.
[0091] Exemplarily, an address management module is used to obtain a first bit width of a first port and a second bit width of a second port, and calculate a bit width conversion ratio according to the first bit width and the second bit width, wherein the first bit width is smaller than the second bit width;
[0092] The address management module is further used to determine a plurality of cache units according to the bit width conversion ratio, wherein the bit width of each cache unit in the plurality of cache units is equal to the first bit width; and if data is transmitted from the first port to the second port, to determine the resource space occupied by the data of each first port respectively;
[0093] A control module, configured to write the data of each first port into the plurality of cache units according to the resource spaces respectively occupied by the data of each first port; wherein the resource spaces occupied by the data of each first port in each cache unit of the plurality of cache units are the same;
[0094] The control module is further used to read the data stored in the multiple cache units from the multiple cache units.
[0095] As an optional implementation of the embodiment of the present application, the control module includes: a data control module;
[0096] The address management module is specifically used for the timing control module to determine, for each first port, the resource space occupied by the data of the first port in each cache unit according to the resource space occupied by the data of the first port and the number of the cache units;
[0097] The data control module is used to write the data of the first ports into the multiple cache units in sequence according to the data writing timing information of each first port and the resource space occupied by the data of the first port in each cache unit.
[0098] As an optional implementation of the embodiment of the present application, if data is transmitted from the second port to the first port, the address management module is further used to determine the resource space occupied by the data flowing to each first port;
[0099] The data control module is further used to write data into the multiple cache units according to the resource space occupied by the data flowing to each first port; wherein, for each first port, the resource space occupied by the data flowing to the first port in each cache unit is the same.
[0100] As an optional implementation of the embodiment of the present application, the address management module is specifically used to determine, for each first port, the resource space occupied by the data flowing to the first port in each cache unit according to the resource space occupied by the data flowing to the first port and the number of the cache units;
[0101] The data control module is specifically configured to write data into the plurality of cache units according to the resource space respectively occupied by the data flowing to the first port in each cache unit.
[0102] As an optional implementation of the embodiment of the present application, the control module includes: a timing control module;
[0103] The timing control module is used to obtain data reading timing information of each first port;
[0104] The data control module is specifically configured to read the data in the plurality of cache units in sequence from the plurality of cache units through the first ports according to the data reading timing information.
[0105] As an optional implementation of the embodiment of the present application, the address management module is specifically used to obtain the ratio of the second bit width to the first bit width to obtain the bit width conversion ratio.
[0106] As an optional implementation of the embodiment of the present application, the address management module is specifically used to determine the number of cache units according to the value of the bit width conversion ratio, and set a plurality of cache units according to the number of cache units.
[0107] The data width conversion device provided in this embodiment can execute the data width conversion method provided in the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here. Each module in the above data width conversion device can be implemented in whole or in part by software, hardware and a combination thereof. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0108] In one embodiment, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the data bit width conversion methods described in the above method embodiments when executing the computer program.
[0109] For example, Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 7As shown, the electronic device provided in this embodiment includes: a memory 71 and a processor 72, the memory 71 is used to store a computer program; the processor 72 is used to execute the steps of the data bit width conversion method provided in the above method embodiment when calling the computer program, and its implementation principle and technical effect are similar, which will not be repeated here. Those skilled in the art can understand that Figure 7 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0110] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the data bit width conversion methods described in the above method embodiments are implemented.
[0111] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in various forms, such as static random access memory (SRAM) and dynamic random access memory (DRAM).
[0112] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants 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 further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0113] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data bit width conversion method, characterized in that: include: Acquire a first bit width of a plurality of first ports and a second bit width of a second port, calculate a ratio of the second bit width to the first bit width, and obtain a bit width conversion ratio, wherein the first bit width is smaller than the second bit width; Determining the number of cache units according to the value of the bit width conversion ratio, and setting a plurality of cache units according to the number of cache units, wherein the bit width of each cache unit in the plurality of cache units is equal to the first bit width; If data is transmitted from the plurality of first ports to the second port, the resource space occupied by the data of each first port is determined, and the data of each first port is written into the plurality of cache units in parallel according to the resource space occupied by the data of each first port; wherein the resource space occupied by the data of each first port in each cache unit of the plurality of cache units is the same; The data stored in the multiple cache units are read from the multiple cache units in parallel.
2. The method according to claim 1, characterized in that The step of writing the data of each first port into the plurality of cache units in parallel according to the resource spaces respectively occupied by the data of each first port comprises: For each first port, determine the resource space occupied by the data of the first port in each cache unit according to the resource space occupied by the data of the first port and the number of the cache units; The data of the first ports are sequentially written into the plurality of cache units according to the data writing timing information of the first ports and the resource space respectively occupied by the data of the first ports in each cache unit.
3. The method according to claim 1, characterized in that The method further comprises: If data is transmitted from the second port to the first port, determine the resource space occupied by the data flowing to each first port, and write the data into the multiple cache units according to the resource space occupied by the data flowing to each first port; wherein, for each first port, the resource space occupied by the data flowing to the first port in each cache unit is the same.
4. The method according to claim 3, characterized in that The step of writing data into the plurality of cache units according to the resource spaces respectively occupied by the data flowing to each first port comprises: For each first port, determine the resource space occupied by the data flowing to the first port in each cache unit according to the resource space occupied by the data flowing to the first port and the number of the cache units; The data is written into the plurality of cache units according to the resource space respectively occupied by the data flowing to the first port in each cache unit.
5. The method according to claim 4, characterized in that The reading the data stored in the plurality of cache units in parallel from the plurality of cache units comprises: When data is transmitted from the second port to the first port, acquiring data reading timing information of each first port; According to the data reading timing information, the data in the plurality of cache units are read sequentially from the plurality of cache units through the first ports.
6. A data bit width conversion device, characterized in that: include: An address management module, configured to obtain a first bit width of a plurality of first ports and a second bit width of a second port, calculate a ratio of the second bit width to the first bit width, and obtain a bit width conversion ratio, wherein the first bit width is smaller than the second bit width; The address management module is further used to determine the number of cache units according to the value of the bit width conversion ratio, and set a plurality of cache units according to the number of cache units, wherein the bit width of each cache unit in the plurality of cache units is equal to the first bit width; a control module, if data is transmitted from the plurality of first ports to the second port, for determining the resource space respectively occupied by the data of each first port, and writing the data of each first port into the plurality of cache units in parallel according to the resource space respectively occupied by the data of each first port; wherein the resource space occupied by the data of each first port in each cache unit of the plurality of cache units is the same; The control module is further configured to read the data stored in the multiple cache units in parallel from the multiple cache units.
7. An electronic device comprising: A memory and a processor, wherein the memory stores a computer program, and wherein the processor implements the data bit width conversion method according to any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the data bit width conversion method according to any one of claims 1 to 5 is implemented.
