RAM read / write control method, device, electronic device, and storage medium
By detecting the number of consecutive repetitions of RAM input data to generate index data, the RAM write and read operations are controlled, which solves the problem of excessive read and write times in the prior art and reduces power consumption.
Patent Information
- Application Number
- CN202411210090.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2044-08-30
AI Technical Summary
The RAM reading and writing methods in the prior art fail to effectively consider data characteristics, resulting in excessive number of read and write operations and wasted power consumption.
By detecting the number of consecutive repetitions of data in the input data, index data is generated, and control is performed according to the write enable signal and the read enable signal to reduce the RAM address operations of writing and reading.
The generation of RAM write addresses and read addresses is effectively reduced, thereby lowering power consumption.
Smart Images

Figure CN119292445B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data reading and writing, and in particular to a RAM reading and writing control method, device, electronic device and storage medium. Background Art
[0002] Random Access Memory (RAM) is internal memory that exchanges data directly with the CPU. It can be read and written at any time, and with high speed, and is typically used as temporary data storage for operating systems or other running programs. RAM can write and read data from any specified address at any time. It is used in computers and digital systems to temporarily store programs, data, and intermediate results; therefore, it is widely used in various data cache interaction fields.
[0003] Figure 1 A schematic diagram of the read and write state of a RAM read and write method of the prior art is shown, wherein Figure 1 As shown, the input data example includes eight sets of data. When the RAM stores the data, eight write addresses are generated, and eight write operations are performed on the RAM. When the RAM reads the data, eight read addresses are generated, and eight read operations are performed on the RAM. However, the existing RAM reading and writing methods do not consider the characteristics of the data, and thus generate a large number of RAM write addresses and read addresses. Correspondingly, a large number of RAM read and write operations are performed, resulting in wasted power when reading and writing the RAM. Summary of the Invention
[0004] In view of the above problems, the purpose of the present invention is to provide a RAM read and write control method, device, electronic device and storage medium, which can effectively reduce the generation of RAM write addresses and read addresses, reduce the number of read and write address operations on RAM, and reduce power consumption.
[0005] The present invention provides a read-write control method for a RAM, comprising: sending input data to be written into the RAM; detecting the input data, obtaining the number of consecutive repetitions of data in multiple groups of data, and generating index data; writing the index data and a group of data corresponding to the index data into a RAM address according to a write enable signal; reading the index data and a group of data corresponding to the index data from the RAM address according to a read enable signal; and generating output data according to the index data and the group of data corresponding to the index data.
[0006] Optionally, obtaining the number of consecutive repetitions of data in multiple groups of data includes: performing data comparison to obtain the first group of data and the last group of data in which data appear consecutively; and obtaining the number of consecutive repetitions of data in multiple groups of data based on the sorting positions of the first group of data and the last group of data in which data appear consecutively.
[0007] Optionally, performing data comparison to obtain the first and last sets of data that appear continuously and repeatedly includes: sequentially comparing two adjacent sets of data from the plurality of sets of data, and obtaining the first and last sets of data that appear continuously and repeatedly according to the comparison result.
[0008] Optionally, performing data comparison to obtain the first set of data and the last set of data that appear repeatedly includes: performing data comparison to obtain the first set of data; comparing the first set of data with subsequent data in sequence until the two sets of data are different, and determining the last set of data.
[0009] Optionally, the data comparison includes: when comparing two sets of data, comparing whether the numbers corresponding to the same digits are the same, and repeating until the numbers corresponding to each digit are compared.
[0010] Optionally, when comparing two sets of data, comparing whether the numbers corresponding to the same digits are the same, and repeating until the numbers corresponding to each digit are compared, includes: setting the digit length of one of the two sets of data as the count number; comparing whether the numbers corresponding to the same digits are the same, and repeating until the numbers corresponding to each digit are compared, and reducing the count number by one each time a comparison operation corresponding to a digit is performed, until the comparison operation is stopped when the count number is zero.
[0011] Optionally, writing the index data and a group of data corresponding to the index data together to the RAM address according to the write enable signal includes: setting the group of data corresponding to the index data as the first group of data or the last group of data that appears continuously and repeatedly; writing the index data and a group of data corresponding to the index data together to the RAM address according to the write enable signal.
[0012] The present invention also provides a read-write control device for RAM, comprising an input module, a detection module, a write module, a readout module and an output module; the input module is used to send input data written to RAM; the detection module is used to detect the input data, obtain the number of consecutive repetitions of data in multiple groups of data, and generate index data; the write module is used to write the index data and a group of data corresponding to the index data into a RAM address according to a write enable signal; the readout module is used to read the index data and a group of data corresponding to the index data in the RAM address according to a read enable signal; the output module is used to generate output data based on the index data and a group of data corresponding to the index data.
[0013] The present invention also provides an electronic device, comprising a memory and a processor, wherein the memory stores executable code, and the processor implements the steps of the above-mentioned RAM read and write control method when executing the executable code.
[0014] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above-mentioned RAM read and write control method when executed by a processor.
[0015] The RAM read and write control method, device, electronic device and storage medium provided by the present invention can obtain the number of consecutive repetitions of data in multiple groups of data according to the characteristics of the data stored in the RAM, generate index data, and write the index data and a group of data corresponding to the index data together into the RAM address according to a write enable signal; read out the index data and a group of data corresponding to the index data in the RAM address according to a read enable signal; and generate output data according to the index data and the group of data corresponding to the index data, which can effectively reduce the generation of RAM write addresses and read addresses, reduce the number of operations of the read and write addresses on the RAM, and reduce power consumption. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.
[0017] Figure 1 A schematic diagram of the read and write states of a RAM read and write method of the prior art is shown;
[0018] Figure 2 A flowchart illustrating a RAM reading and writing method according to an embodiment of the present invention is shown;
[0019] Figure 3 A schematic diagram showing the read and write states of a RAM read and write method according to an embodiment of the present invention is shown;
[0020] Figure 4 A schematic structural diagram of a RAM reading and writing device according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0021] The aforementioned and other technical contents, features, and effects of the present invention will be clearly presented in the following detailed description of the preferred embodiments with reference to the drawings. Through the description of the specific embodiments, a deeper and more specific understanding of the technical means and effects adopted by the present invention to achieve the intended purpose can be obtained. However, the accompanying drawings are only for reference and illustration purposes and are not intended to limit the present invention. Some well-known parts may not be shown. In the various drawings, the same elements are represented by similar reference numerals. For the sake of clarity, the various parts in the drawings are not necessarily drawn strictly according to the actual scale.
[0022] It should be understood that the terms "first," "second," "third," "fourth," etc., are intended solely to distinguish between components or circuits having similar properties, and do not indicate or imply relative importance or a particular order. The terms "comprise," "comprising," or any other variations thereof are intended to encompass a non-exclusive inclusion, meaning that in addition to the listed elements, other elements not explicitly listed may also be included.
[0023] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0024] Please also refer to Figure 2 and Figure 3 , Figure 2 A flowchart illustrating a RAM reading and writing method according to an embodiment of the present invention is shown; Figure 3 A schematic diagram of the read and write states of a RAM read and write method according to an embodiment of the present invention is shown.
[0025] like Figure 2 As shown, this embodiment provides a RAM reading and writing method, which includes:
[0026] S110, sending input data to be written into RAM.
[0027] For example, in Figure 3 In the embodiment, the input data sent to be written into the RAM may include eight groups of data from data0 to data7, but the present invention is not limited thereto and may also include multiple groups of data of other numbers.
[0028] S120 , detecting the input data, obtaining the number of consecutive repetitions of data in multiple groups of data, and generating index data.
[0029] For example, in Figure 3 In the example, for the eight data sets from data0 to data8 in the input data, the data characteristics stored in the RAM are as follows: data0 and data1 are the same data, data3, data4 and data5 are the same data, data6 and data7 are the same data, data2 and the adjacent data1 or data3 are different data, and data6 and the adjacent data5 are different data. This is only used to illustrate the embodiment and is not a specific limitation on the data characteristics stored in the RAM. Thus, Figure 3 The number of consecutive repetitions of data in the example data sets is 2, 1, 3 and 2, respectively, resulting in Figure 3 The index data shown.
[0030] S130 , writing the index data and a group of data corresponding to the index data into the RAM address according to the write enable signal.
[0031] For example, in Figure 3 In the example, the index data is 2, 1, 3 and 2. The first 2 in the index data can correspond to data0 and data1, so a write address can be generated. According to the write enable signal, the first 2 in the index data and a group of data data0 or data1 corresponding to the 2 are written to RAM address 0. Similarly, the 1 in the index data and a group of data data2 corresponding to the 1 are written to RAM address 1. The 3 in the index data and a group of data data3, data4 or data5 corresponding to the 3 are written to RAM address 2. The second 2 in the index data and a group of data data6 or data7 corresponding to the 2 are written to RAM address 3. Figure 3 and Figure 1 By comparison, it can be seen that the prior art generates eight write addresses when storing data in RAM and performs eight RAM write operations, while the present embodiment generates four write addresses when storing data in RAM and performs four RAM write operations. Thus, the generation of RAM write addresses can be effectively reduced, the number of write address operations on RAM can be reduced, and power consumption can be reduced.
[0032] S140 , reading out the index data in the RAM address and a group of data corresponding to the index data according to the read enable signal.
[0033] For example, in Figure 3In the data stored in RAM, according to the read enable signal, the data can be read out. That is, according to the read enable signal, the first 2 in the index data in RAM address 0 and a group of data data0 or data1 corresponding to the 2 can be read out, the 1 in the index data in RAM address 1 and a group of data data2 corresponding to the 1 can be read out, the 3 in the index data in RAM address 2 and a group of data data3, data4 or data5 corresponding to the 3 can be read out, and the second 2 in the index data in RAM address 3 and a group of data data6 or data7 corresponding to the 2 can be read out. Figure 3 and Figure 1 By comparison, it can be seen that the prior art generates eight read addresses when reading data from the RAM and performs eight RAM read operations, while the present embodiment generates four read addresses when reading data from the RAM and performs four RAM read operations. Thus, the generation of RAM read addresses can be effectively reduced, the number of read address operations on the RAM can be reduced, and power consumption can be reduced.
[0034] S150: Generate output data according to the index data and a group of data corresponding to the index data.
[0035] For example, in Figure 3 In the example, according to the first 2 in the index data read from RAM address 0 and the corresponding data set data0 or data1, the data set can be repeatedly output twice to obtain data0 and data1 in the output data; according to the 1 in the index data read from RAM address 1 and the corresponding data set data2, the data set can be output only once to obtain data2 in the output data; according to the 3 in the index data read from RAM address 2 and the corresponding data set data3, data4, or data5, the data set can be repeatedly output three times to obtain data3, data4, and data5 in the output data; according to the second 2 in the index data read from RAM address 3 and the corresponding data set data6 or data7, the data set can be repeatedly output twice to obtain data6 and data7 in the output data. Thus, the final output data is data0, data1, data2, data3, data4, data5, data6, and data7, which are the same as the input data data0 to data7.
[0036] Therefore, the RAM read and write control method provided in this embodiment can obtain the number of consecutive repetitions of data in multiple groups of data according to the characteristics of the data stored in the RAM, generate index data, and write the index data and a group of data corresponding to the index data into the RAM address together according to the write enable signal; read out the index data and a group of data corresponding to the index data in the RAM address according to the read enable signal; generate output data according to the index data and a group of data corresponding to the index data, which can effectively reduce the generation of RAM write addresses and read addresses, reduce the number of operations of the read and write addresses on the RAM, and reduce power consumption.
[0037] Optionally, obtaining the number of consecutive repetitions of data in multiple groups of data includes: performing data comparison to obtain the first group of data and the last group of data in which data appear consecutively; and obtaining the number of consecutive repetitions of data in multiple groups of data based on the sorting positions of the first group of data and the last group of data in which data appear consecutively.
[0038] For example, in Figure 3 , perform data comparison; the first group of data data0 and the last group of data data1 that appear continuously can be obtained. According to the sorting positions of data0 and data1, the number of data that appear continuously in multiple groups of data can be obtained as 2; the first group of data data2 and the last group of data data2 that appear continuously can be obtained. According to the sorting positions of data2 and data2, the number of data that appear continuously in multiple groups of data can be obtained as 1; the first group of data data3 and the last group of data data5 that appear continuously can be obtained. According to the sorting positions of data3 and data5, the number of data that appear continuously in multiple groups of data can be obtained as 3; the first group of data data6 and the last group of data data7 that appear continuously can be obtained. According to the sorting positions of data6 and data7, the number of data that appear continuously in multiple groups of data can be obtained as 2.
[0039] Optionally, performing data comparison to obtain the first and last sets of data that appear repeatedly includes: sequentially comparing two adjacent sets of data from the plurality of sets of data, and obtaining the first and last sets of data that appear repeatedly according to the comparison result.
[0040] For example, in Figure 3, two adjacent groups of data in the multiple groups of data are compared in sequence, and the comparison result is that data0 and data1 are the same data, data1 and data2 are different data, data2 and data3 are different data, data3 and data4 are the same data, data4 and data5 are the same data, data5 and data6 are different data, and data6 and data7 are the same data; thus, the first group of data data0 and the last group of data data1 that appear continuously can be obtained, the first group of data data2 and the last group of data data2 that appear continuously can be obtained, the first group of data data3 and the last group of data data5 that appear continuously can be obtained, and the first group of data data6 and the last group of data data7 that appear continuously can be obtained.
[0041] Optionally, performing data comparison to obtain the first set of data and the last set of data that appear repeatedly includes: performing data comparison to obtain the first set of data; comparing the first set of data with subsequent data in sequence until the two sets of data are different, and then determining the last set of data.
[0042] For example, in Figure 3 , data comparison is performed to obtain the first group of data data0, and data0 is compared with subsequent data in sequence until data0 and data2 are compared to obtain two groups of data that are different. It is determined that the last group of data when the first group of data data0 is data1, then the first group of data data0 and the last group of data data1 that appear continuously can be obtained; similarly, the first group of data data2 and the last group of data data2 that appear continuously can be obtained, the first group of data data3 and the last group of data data5 that appear continuously can be obtained, and the first group of data data6 and the last group of data data7 that appear continuously can be obtained.
[0043] Optionally, performing data comparison includes: when comparing two sets of data, comparing whether the numbers corresponding to the same digits are the same, and repeating until the numbers corresponding to each digit are compared. For example, when comparing data0 and data1, comparing whether the numbers corresponding to the same digits are the same, and repeating until the numbers corresponding to each digit are compared, it can be found that the numbers corresponding to all digits are the same, and data0 and data1 can be determined to be the same data; when comparing data1 and data2, comparing whether the numbers corresponding to the same digits are the same, and repeating until the numbers corresponding to each digit are compared, it can be found that the numbers corresponding to at least one digit are different, and data1 and data2 can be determined to be different data.
[0044] Optionally, when comparing two sets of data, the numbers corresponding to the same digits are compared to see if they are the same, and repeating until the numbers corresponding to each digit are compared, including: setting the digit length of one of the two sets of data to the count number; comparing the numbers corresponding to the same digits to see if they are the same, and repeating until the numbers corresponding to each digit are compared, and reducing the count number by one each time a comparison operation corresponding to a digit is performed, and stopping the comparison operation when the count number reaches zero. For example, when comparing data0 with data1, the digit length of data0 can be set to the count number; compare whether the numbers corresponding to the same digits are the same, and repeat until the numbers corresponding to each digit are compared, and the count number is reduced by one each time a comparison operation corresponding to a digit is performed, until the comparison operation is stopped when the count number reaches zero, it can be obtained that the numbers corresponding to all digits are the same, and it can be determined that data0 and data1 are the same data; when comparing data1 with data2, the digit length of data1 can be set to the count number; compare whether the numbers corresponding to the same digits are the same, and repeat until the numbers corresponding to each digit are compared, and the count number is reduced by one each time a comparison operation corresponding to a digit is performed, until the comparison operation is stopped when the count number reaches zero, it can be obtained that the numbers corresponding to at least one of the digits are different, and it can be determined that data1 and data2 are different data.
[0045] Optionally, according to a write enable signal, the index data and a group of data corresponding to the index data are written together to the RAM address, including: setting a group of data corresponding to the index data as the first group of data or the last group of data that appears continuously and repeatedly; according to a write enable signal, the index data and a group of data corresponding to the index data are written together to the RAM address.
[0046] For example, in Figure 3 In the example, the group of data corresponding to 3 in the index data can be set to the first group of data data3 or the last group of data data5 that appear continuously; according to the write enable signal, the 3 in the index data and the data3 or data5 corresponding to the 3 are written into the RAM address together.
[0047] Based on the same inventive concept, Figure 4As shown, an embodiment of the present invention further provides a read-write control device for a RAM, comprising an input module 100, a detection module 200, a write module 300, a read module 400, and an output module 500; the input module 100 is used to send input data to be written into the RAM; the detection module 200 is used to detect the input data, obtain the number of consecutive repetitions of data in multiple groups of data, and generate index data; the write module 300 is used to write the index data and a group of data corresponding to the index data into a RAM address according to a write enable signal; the read module 400 is used to read the index data and a group of data corresponding to the index data in the RAM address according to a read enable signal; the output module 500 is used to generate output data according to the index data and a group of data corresponding to the index data. The implementation of the read-write control device for the RAM can refer to the embodiment of the read-write control method for the RAM described above, and the repeated parts will not be repeated here.
[0048] Based on the same inventive concept, an embodiment of the present invention further provides an electronic device comprising a memory and a processor. The memory stores executable code, and when the processor executes the executable code, it implements the steps of the RAM read / write control method of the aforementioned embodiment. The implementation of this electronic device can refer to the embodiment of the RAM read / write control method described above, and any repetitions are not repeated here.
[0049] Based on the same inventive concept, embodiments of the present invention further provide a computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program implements the steps of the RAM read / write control method described above. The implementation of this computer-readable storage medium can be found in the embodiments of the RAM read / write control method described above, and any repetitions are omitted.
[0050] The RAM read and write control method, device, electronic device and storage medium provided by the embodiments of the present invention can obtain the number of consecutive repetitions of data in multiple groups of data according to the characteristics of the data stored in the RAM, generate index data, and write the index data and a group of data corresponding to the index data together to the RAM address according to the write enable signal; read out the index data and a group of data corresponding to the index data in the RAM address according to the read enable signal; generate output data according to the index data and the group of data corresponding to the index data, which can effectively reduce the generation of RAM write addresses and read addresses, reduce the number of operations of the read and write addresses on the RAM, and reduce power consumption.
[0051] The above description is merely a preferred embodiment of the present application and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of the invention herein is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also encompasses other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the inventive concept. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features having similar functions disclosed in this application.
Claims
1. A RAM read and write control method, characterized in that: include: Send input data written to RAM; Detecting the input data, obtaining the number of consecutive repetitions of data in multiple groups of data, and generating index data; When obtaining the number of consecutive repetitions of data in multiple sets of data, performing data comparison, obtaining a first set of data, and sequentially comparing the first set of data with subsequent data until the two sets of data are different, determining the last set of data, wherein when comparing the two sets of data, comparing whether the numbers corresponding to the same digits are the same, and repeating until the numbers corresponding to each digit are compared; According to a write enable signal, the index data and a group of data corresponding to the index data are written into a RAM address; Reading the index data and a group of data corresponding to the index data in the RAM address according to a read enable signal; Output data is generated according to the index data and a group of data corresponding to the index data.
2. The RAM read and write control method according to claim 1, wherein: The obtaining of the number of consecutive repetitions of data in the multiple sets of data includes: Compare the data and obtain the first and last set of data that appear repeatedly. Get the number of consecutive repetitions of data in multiple groups of data based on the sorting positions of the first and last groups of data that appear consecutively.
3. The RAM read and write control method according to claim 2, wherein: The data comparison is performed to obtain the first set of data and the last set of data that are repeated continuously, including: Two adjacent sets of data in the plurality of sets of data are compared in sequence, and the first set of data and the last set of data that appear repeatedly are obtained according to the comparison result.
4. The RAM read and write control method according to claim 1, wherein: When comparing two sets of data, comparing the numbers corresponding to the same digits to see if they are the same, and repeating until the numbers corresponding to each digit are compared, includes: The digit length of one of the two sets of data is set to the count number; Compare whether the numbers corresponding to the same digits are the same, and repeat until the numbers corresponding to each digit are compared, and reduce the count by one each time a comparison operation corresponding to a digit is performed, and stop performing the comparison operation when the count reaches zero.
5. The RAM read and write control method according to claim 1, wherein: Writing the index data and a group of data corresponding to the index data into a RAM address according to a write enable signal includes: Set the group of data corresponding to the index data as the first group of data or the last group of data that appears repeatedly; According to a write enable signal, the index data and a group of data corresponding to the index data are written into a RAM address together.
6. A RAM read / write control device, characterized in that: include: Input module, used to send input data written into RAM; A detection module is used to detect the input data, obtain the number of consecutive repetitions of data in multiple groups of data, and generate index data; When obtaining the number of consecutive repetitions of data in multiple sets of data, performing data comparison, obtaining a first set of data, and sequentially comparing the first set of data with subsequent data until the two sets of data are different, determining the last set of data, wherein when comparing the two sets of data, comparing whether the numbers corresponding to the same digits are the same, and repeating until the numbers corresponding to each digit are compared; A writing module, configured to write the index data and a group of data corresponding to the index data into a RAM address according to a write enable signal; a readout module, configured to read out the index data and a set of data corresponding to the index data in the RAM address according to a read enable signal; An output module is used to generate output data based on the index data and a group of data corresponding to the index data.
7. An electronic device comprising a memory and a processor, wherein the memory stores executable code, wherein: When the processor executes the executable code, the steps of the RAM read and write control method according to any one of claims 1 to 5 are implemented.
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 steps of the RAM read and write control method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
System and method for peripheral data transfer
CA2111264A1
RAM read-write control method
CN114265796A