CN115050405A - Read-write control circuit, control method, chip and electronic equipment - Google Patents
Read-write control circuit, control method, chip and electronic equipment Download PDFInfo
- Publication number
- CN115050405A CN115050405A CN202210789662.6A CN202210789662A CN115050405A CN 115050405 A CN115050405 A CN 115050405A CN 202210789662 A CN202210789662 A CN 202210789662A CN 115050405 A CN115050405 A CN 115050405A
- Authority
- CN
- China
- Prior art keywords
- read
- write
- data
- cache unit
- control circuit
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 19
- 238000010586 diagram Methods 0.000 description 18
- 230000001960 triggered effect Effects 0.000 description 15
- 238000012986 modification Methods 0.000 description 4
- 230000004048 modification Effects 0.000 description 4
- 230000003068 static effect Effects 0.000 description 2
- 240000007594 Oryza sativa Species 0.000 description 1
- 235000007164 Oryza sativa Nutrition 0.000 description 1
- 241001417527 Pempheridae Species 0.000 description 1
- 210000000577 adipose tissue Anatomy 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000003111 delayed effect Effects 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000000977 initiatory effect Effects 0.000 description 1
- 238000003032 molecular docking Methods 0.000 description 1
- 230000035764 nutrition Effects 0.000 description 1
- 235000016709 nutrition Nutrition 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 235000009566 rice Nutrition 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G11—INFORMATION STORAGE
- G11C—STATIC STORES
- G11C11/00—Digital stores characterised by the use of particular electric or magnetic storage elements; Storage elements therefor
- G11C11/21—Digital stores characterised by the use of particular electric or magnetic storage elements; Storage elements therefor using electric elements
- G11C11/34—Digital stores characterised by the use of particular electric or magnetic storage elements; Storage elements therefor using electric elements using semiconductor devices
- G11C11/40—Digital stores characterised by the use of particular electric or magnetic storage elements; Storage elements therefor using electric elements using semiconductor devices using transistors
- G11C11/41—Digital stores characterised by the use of particular electric or magnetic storage elements; Storage elements therefor using electric elements using semiconductor devices using transistors forming static cells with positive feedback, i.e. cells not needing refreshing or charge regeneration, e.g. bistable multivibrator or Schmitt trigger
- G11C11/413—Auxiliary circuits, e.g. for addressing, decoding, driving, writing, sensing, timing or power reduction
Landscapes
- Engineering & Computer Science (AREA)
- Microelectronics & Electronic Packaging (AREA)
- Computer Hardware Design (AREA)
- Memory System Of A Hierarchy Structure (AREA)
Abstract
Description
技术领域technical field
本申请涉及电子技术领域,尤其涉及一种读写控制电路、控制方法、芯片及电子设备。The present application relates to the field of electronic technology, and in particular, to a read-write control circuit, a control method, a chip and an electronic device.
背景技术Background technique
AHB(Advanced High performance Bus,高级高性能总线)可以通过发起读操作或写操作,触发对SRAM(Static Random-Access Memory,静态随机存取存储器)的访问。AHB (Advanced High Performance Bus, Advanced High Performance Bus) can trigger access to SRAM (Static Random-Access Memory, Static Random Access Memory) by initiating a read operation or a write operation.
在AHB总线访问SRAM时,如果写操作后,紧接着读操作,由于SRAM写入需要时间,会导致读操作发生等待,系统访问效率受到影响。When the AHB bus accesses the SRAM, if the write operation is followed by the read operation, the read operation will wait due to the time required for the SRAM write operation, and the system access efficiency will be affected.
发明内容SUMMARY OF THE INVENTION
为了解决现有技术的问题,本申请实施例提供了一种读写控制电路、控制方法、芯片及电子设备,可以提高系统访问效率。技术方案如下:In order to solve the problems in the prior art, the embodiments of the present application provide a read-write control circuit, a control method, a chip and an electronic device, which can improve system access efficiency. The technical solution is as follows:
根据本申请的一方面,提供了一种读写控制电路,所述读写控制电路包括缓存模块;According to an aspect of the present application, a read-write control circuit is provided, and the read-write control circuit includes a cache module;
所述读写控制电路被配置为:The read-write control circuit is configured to:
当存在连续的读写操作时,执行读操作,并将写操作对应的数据存储在所述缓存模块中;When there are continuous read and write operations, the read operation is performed, and the data corresponding to the write operation is stored in the cache module;
从所述缓存模块中将写操作对应的数据写入存储器。Data corresponding to the write operation is written into the memory from the cache module.
可选的,所述缓存模块包括第一级写缓存单元和第二级写缓存单元;Optionally, the cache module includes a first-level write cache unit and a second-level write cache unit;
所述读写控制电路被配置为:The read-write control circuit is configured to:
当存在写操作时,将写操作对应的数据存储在所述第一级写缓存单元中;When there is a write operation, the data corresponding to the write operation is stored in the first-level write cache unit;
若当前不存在待执行的读操作,则执行将所述第一级写缓存单元当前存储的数据写入所述第二级写缓存单元的操作。If there is no read operation to be performed currently, the operation of writing the data currently stored in the first-level write cache unit into the second-level write cache unit is performed.
可选的,所述读写控制电路被配置为:Optionally, the read-write control circuit is configured as:
接收第一操作指令,并确定所述第一操作指令为写操作,则执行所述第一操作指令并将所述第一操作指令对应的数据存储在所述第一级写缓存单元中;Receive a first operation instruction, and determine that the first operation instruction is a write operation, execute the first operation instruction and store the data corresponding to the first operation instruction in the first-level write cache unit;
接收第二操作指令,并确定所述第二操作指令为读操作,若所述第一操作指令处于执行状态,则将所述第一操作指令挂起,执行所述第二操作指令以获取所述第二操作指令所需的数据并写回;Receive a second operation instruction, and determine that the second operation instruction is a read operation, if the first operation instruction is in the execution state, suspend the first operation instruction, and execute the second operation instruction to obtain the Describe the data required by the second operation instruction and write it back;
所述第二操作指令执行完毕后,若当前不存在待执行的读操作,则将挂起的所述第一操作指令执行,并执行将所述第一级写缓存单元当前存储的数据写入所述第二级写缓存单元的操作。After the execution of the second operation instruction is completed, if there is currently no read operation to be executed, the pending first operation instruction is executed, and the data currently stored in the first-level write cache unit is written. the operation of the second level write cache unit.
可选的,所述读写控制电路被配置为:Optionally, the read-write control circuit is configured as:
接收第三操作指令,并确定所述第三操作指令为读操作,则执行所述第三操作指令以获取所述第三操作指令所需的数据并写回;Receive a third operation instruction, and determine that the third operation instruction is a read operation, execute the third operation instruction to obtain the data required by the third operation instruction and write it back;
接收第四操作指令,并确定所述第四操作指令为写操作,则在所述第三操作指令执行完毕后,执行所述第四操作指令并将所述第四操作指令对应的数据存储在所述第一级写缓存单元中;After receiving the fourth operation instruction, and determining that the fourth operation instruction is a write operation, after the execution of the third operation instruction is completed, the fourth operation instruction is executed and the data corresponding to the fourth operation instruction is stored in the in the first-level write cache unit;
若当前不存在待执行的读操作,则执行将所述第一级写缓存单元当前存储的数据写入所述第二级写缓存单元的操作。If there is no read operation to be performed currently, the operation of writing the data currently stored in the first-level write cache unit into the second-level write cache unit is performed.
可选的,所述读写控制电路还被配置为:Optionally, the read-write control circuit is further configured as:
接收第五操作指令,并确定所述第五操作指令为写操作,则执行所述第五操作指令并将所述第五操作指令对应的数据存储在所述第一级写缓存单元中;Receive a fifth operation instruction, and determine that the fifth operation instruction is a write operation, execute the fifth operation instruction and store the data corresponding to the fifth operation instruction in the first-level write cache unit;
若当前不存在待执行的读操作,则执行将所述第一级写缓存单元当前存储的数据写入所述第二级写缓存单元的操作。If there is no read operation to be performed currently, the operation of writing the data currently stored in the first-level write cache unit into the second-level write cache unit is performed.
可选的,所述读写控制电路还被配置为:Optionally, the read-write control circuit is further configured as:
在执行将所述第一级写缓存单元当前存储的数据写入所述第二级写缓存单元的操作时,将所述第一级写缓存单元当前存储的数据作为第一数据,如果所述第二级写缓存单元当前存储有第二数据,则判断所述第一数据对应的写地址与所述第二数据对应的写地址是否满足相邻条件,所述相邻条件是指在所述存储器中的存储位置相邻;When performing the operation of writing the data currently stored in the first-level write-cache unit into the second-level write-cache unit, the data currently stored in the first-level write-cache unit is taken as the first data, if the The second-level write cache unit currently stores the second data, then it is determined whether the write address corresponding to the first data and the write address corresponding to the second data satisfy an adjacent condition, and the adjacent condition refers to the Storage locations in memory are adjacent;
若满足所述相邻条件,则将所述第一数据和所述第二数据写入所述存储器;If the adjacent condition is satisfied, writing the first data and the second data into the memory;
若不满足所述相邻条件,则将所述第二数据写入所述存储器,将所述第一数据写入所述第二级写缓存单元。If the adjacent condition is not satisfied, the second data is written into the memory, and the first data is written into the second-level write cache unit.
可选的,所述读写控制电路还被配置为:Optionally, the read-write control circuit is further configured as:
在总线空闲时,将所述缓存模块中当前存储的数据写入所述存储器。When the bus is idle, the data currently stored in the cache module is written into the memory.
可选的,所述读写控制电路被配置为:Optionally, the read-write control circuit is configured as:
当所述缓存模块中存在读操作所需的数据时,从所述缓存模块中获取所述所需的数据;When the data required for the read operation exists in the cache module, obtain the required data from the cache module;
当所述缓存模块中不存在读操作所需的数据时,从所述存储器中读取所述所需的数据。When the data required for the read operation does not exist in the cache module, the required data is read from the memory.
可选的,所述缓存模块包括第一级写缓存单元和第二级写缓存单元;Optionally, the cache module includes a first-level write cache unit and a second-level write cache unit;
所述读写控制电路被配置为:The read-write control circuit is configured to:
对于所述第一级写缓存单元:判断当前读操作对应的读地址与所述第一级写缓存单元的数据对应的写地址是否相同,如果相同,则从所述第一级写缓存单元中获取当前读操作的数据;如果不相同,则进入如下对于所述第二级写缓存单元的判断;For the first-level write cache unit: determine whether the read address corresponding to the current read operation is the same as the write address corresponding to the data of the first-level write-cache unit; Obtain the data of the current read operation; if it is not the same, enter the judgment on the second-level write cache unit as follows;
对于所述第二级写缓存单元:判断当前读操作对应的读地址与所述第二级写缓存单元的数据对应的写地址是否相同,如果相同,则从所述第二级写缓存单元中获取当前读操作的数据。For the second level write cache unit: determine whether the read address corresponding to the current read operation is the same as the write address corresponding to the data of the second level write cache unit, if they are the same, then from the second level write cache unit Get the data of the current read operation.
可选的,所述缓存模块还包括读缓存单元;Optionally, the cache module further includes a read cache unit;
所述读写控制电路还被配置为:The read-write control circuit is also configured to:
在所述判断当前读操作对应的读地址与所述第二级写缓存单元的数据对应的地址是否相同之后,如果不相同,则进入如下对于所述读缓存单元的判断;After judging whether the read address corresponding to the current read operation is the same as the address corresponding to the data of the second-level write cache unit, if they are not the same, enter the following judgment on the read cache unit;
对于所述读缓存单元:判断当前读操作对应的读地址与所述读缓存单元的数据对应的地址是否相同,如果相同,则从所述读缓存单元中获取当前读操作的数据;如果不相同,则从所述存储器中读取所述所需的数据。For the read cache unit: determine whether the read address corresponding to the current read operation is the same as the address corresponding to the data of the read cache unit, if they are the same, then obtain the data of the current read operation from the read cache unit; if not the same , the required data is read from the memory.
可选的,所述缓存模块还包括读缓存单元;Optionally, the cache module further includes a read cache unit;
所述读写控制电路还被配置为:The read-write control circuit is also configured to:
基于当前读操作对应的读地址,从所述存储器中读取所述读地址及其相邻存储位置的数据;Based on the read address corresponding to the current read operation, read the data of the read address and its adjacent storage locations from the memory;
将所述读地址的数据作为当前读操作所需的数据写回,并将所述相邻存储位置的数据写入所述读缓存单元。The data of the read address is written back as the data required for the current read operation, and the data of the adjacent storage location is written into the read cache unit.
可选的,所述缓存模块包括第一级写缓存单元、第二级写缓存单元和读缓存单元,所述读写控制电路还包括第一数据选择器、第二数据选择器、第三数据选择器、第四数据选择器和写数据选择控制电路;Optionally, the cache module includes a first-level write cache unit, a second-level write cache unit, and a read cache unit, and the read-write control circuit further includes a first data selector, a second data selector, and a third data selector. a selector, a fourth data selector and a write data selection control circuit;
所述第一级写缓存单元的输入端与总线连接,输出端分别连接所述第一数据选择器的输入端和所述第二数据选择器的输入端;The input end of the first-level write buffer unit is connected to the bus, and the output end is respectively connected to the input end of the first data selector and the input end of the second data selector;
所述第二级写缓存单元的输入端与所述第一数据选择器的输出端连接,输出端分别连接所述写数据选择控制电路的输入端和所述第三数据选择器的输入端;The input end of the second-level write buffer unit is connected to the output end of the first data selector, and the output end is respectively connected to the input end of the write data selection control circuit and the input end of the third data selector;
所述读缓存单元的输入端与所述存储器连接,输出端与所述第四数据选择器的输入端连接;The input end of the read buffer unit is connected to the memory, and the output end is connected to the input end of the fourth data selector;
所述第一数据选择器的输入端还与总线连接,输出端还与所述写数据选择控制电路连接;The input end of the first data selector is also connected to the bus, and the output end is also connected to the write data selection control circuit;
所述第二数据选择器的输入端还与所述第三数据选择器的输出端连接,输出端与总线连接;The input end of the second data selector is also connected to the output end of the third data selector, and the output end is connected to the bus;
所述第三数据选择器的输入端还与所述第四数据选择器的输出端连接;The input end of the third data selector is also connected with the output end of the fourth data selector;
所述第四数据选择器的输入端还与所述存储器连接;The input end of the fourth data selector is also connected with the memory;
所述写数据选择控制电路的输出端还与所述存储器连接。The output end of the write data selection control circuit is also connected to the memory.
根据本申请的另一方面,提供了一种读写控制电路的控制方法,所述读写控制电路包括缓存模块;According to another aspect of the present application, a control method for a read-write control circuit is provided, the read-write control circuit includes a cache module;
所述方法包括:The method includes:
当存在连续的读写操作时,执行读操作,并将写操作对应的数据存储在所述缓存模块中;When there are continuous read and write operations, the read operation is performed, and the data corresponding to the write operation is stored in the cache module;
从所述缓存模块中将写操作对应的数据写入存储器。Data corresponding to the write operation is written into the memory from the cache module.
根据本申请的另一方面,提供了一种芯片,包括上述读写控制电路。According to another aspect of the present application, a chip is provided, including the above-mentioned read-write control circuit.
根据本申请的另一方面,提供了一种电子设备,包括上述读写控制电路。According to another aspect of the present application, an electronic device is provided, including the above-mentioned read-write control circuit.
本申请中,当存在连续的读写操作时,写操作的数据可以缓存在缓存模块中,优先读取读操作的数据,此后才将写操作的数据写入存储器,消除了写操作在前时读操作的等待时间,提升了系统访问效率。In this application, when there are continuous read and write operations, the data of the write operation can be cached in the cache module, and the data of the read operation is read preferentially, and then the data of the write operation is written into the memory, eliminating the need for the write operation to occur in the first place. The waiting time of the read operation improves the system access efficiency.
附图说明Description of drawings
在下面结合附图对于示例性实施例的描述中,本申请的更多细节、特征和优点被公开,在附图中:Further details, features and advantages of the present application are disclosed in the following description of exemplary embodiments in conjunction with the accompanying drawings, in which:
图1示出了根据本申请示例性实施例提供的读写控制电路示意图;1 shows a schematic diagram of a read-write control circuit provided according to an exemplary embodiment of the present application;
图2示出了根据本申请示例性实施例提供的缓存模块示意图;FIG. 2 shows a schematic diagram of a cache module provided according to an exemplary embodiment of the present application;
图3示出了根据本申请示例性实施例提供的缓存模块示意图;FIG. 3 shows a schematic diagram of a cache module provided according to an exemplary embodiment of the present application;
图4示出了根据本申请示例性实施例提供的缓存模块示意图;FIG. 4 shows a schematic diagram of a cache module provided according to an exemplary embodiment of the present application;
图5示出了根据本申请示例性实施例提供的读写控制电路示意图;FIG. 5 shows a schematic diagram of a read-write control circuit provided according to an exemplary embodiment of the present application;
图6示出了未采用本申请提供的读写控制电路时的系统时序图;Fig. 6 shows the system sequence diagram when the read-write control circuit provided by the present application is not used;
图7示出了采用本申请提供的读写控制电路后的系统时序图;Fig. 7 shows the system sequence diagram after adopting the read-write control circuit provided by the present application;
图8示出了未采用本申请提供的读写控制电路时的系统时序图;Fig. 8 shows the system sequence diagram when the read-write control circuit provided by the present application is not used;
图9示出了采用本申请提供的读写控制电路后的系统时序图;Fig. 9 shows the system sequence diagram after adopting the read-write control circuit provided by the present application;
图10示出了根据本申请示例性实施例提供的读写控制电路的控制方法流程图。FIG. 10 shows a flowchart of a control method of a read-write control circuit provided according to an exemplary embodiment of the present application.
具体实施方式Detailed ways
下面将参照附图更详细地描述本申请的实施例。虽然附图中显示了本申请的某些实施例,然而应当理解的是,本申请可以通过各种形式来实现,而且不应该被解释为限于这里阐述的实施例,相反提供这些实施例是为了更加透彻和完整地理解本申请。应当理解的是,本申请的附图及实施例仅用于示例性作用,并非用于限制本申请的保护范围。Embodiments of the present application will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present application are shown in the drawings, it is to be understood that the present application may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for the purpose of A more thorough and complete understanding of this application. It should be understood that the drawings and embodiments of the present application are only used for exemplary purposes, and are not used to limit the protection scope of the present application.
本文使用的术语“包括”及其变形是开放性包括,即“包括但不限于”。术语“基于”是“至少部分地基于”。术语“一个实施例”表示“至少一个实施例”;术语“另一实施例”表示“至少一个另外的实施例”;术语“一些实施例”表示“至少一些实施例”。其他术语的相关定义将在下文描述中给出。需要注意,本申请中提及的“第一”、“第二”等概念仅用于对不同的装置、模块或单元进行区分,并非用于限定这些装置、模块或单元所执行的功能的顺序或者相互依存关系。As used herein, the term "including" and variations thereof are open-ended inclusions, ie, "including but not limited to". The term "based on" is "based at least in part on." The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions of other terms will be given in the description below. It should be noted that concepts such as "first" and "second" mentioned in this application are only used to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or interdependence.
需要注意,本申请中提及的“一个”、“多个”的修饰是示意性而非限制性的,本领域技术人员应当理解,除非在上下文另有明确指出,否则应该理解为“一个或多个”。It should be noted that the modifications of "a" and "a plurality" mentioned in this application are illustrative rather than restrictive, and those skilled in the art should understand that unless the context clearly indicates otherwise, they should be understood as "one or a plurality of". multiple".
本申请实施方式中的多个装置之间所交互的消息或者信息的名称仅用于说明性的目的,而并不是用于对这些消息或信息的范围进行限制。The names of messages or information exchanged between multiple devices in the embodiments of the present application are only used for illustrative purposes, and are not used to limit the scope of these messages or information.
本申请实施例提供了一种读写控制电路,该读写控制电路可以集成在芯片中,或者设置在电子设备中。The embodiments of the present application provide a read-write control circuit, and the read-write control circuit may be integrated in a chip or provided in an electronic device.
参照图1所示的读写控制电路示意图,该读写控制电路可以包括缓存模块。Referring to the schematic diagram of the read-write control circuit shown in FIG. 1 , the read-write control circuit may include a cache module.
读写控制电路可以被配置为:The read-write control circuit can be configured as:
当存在连续的读写操作时,执行读操作,并将写操作对应的数据存储在缓存模块中;When there are continuous read and write operations, the read operation is performed, and the data corresponding to the write operation is stored in the cache module;
从缓存模块中将写操作对应的数据写入存储器。Write the data corresponding to the write operation into the memory from the cache module.
在一种可能的实施方式中,读写控制电路可以设置在总线和存储器之间,在两者之间传输数据。具体的,上述总线可以是指AHB总线,存储器可以是指SRAM。作为一种示例,读写控制电路可以应用于32位MCU(Microcontroller Unit,微控制单元)设计中,SRAM每个地址存储数据为64bit。In a possible implementation, a read-write control circuit may be provided between the bus and the memory, and data is transferred between the two. Specifically, the above-mentioned bus may refer to the AHB bus, and the memory may refer to the SRAM. As an example, the read-write control circuit can be applied to the design of a 32-bit MCU (Microcontroller Unit, micro-control unit), and each address of the SRAM stores 64 bits of data.
当总线发出连续的读写操作时,通过配置,使得读写控制电路可以先执行读操作,读出读操作所需的数据,而后执行写操作,将写操作对应的数据存储在缓存模块中,并将写操作的数据写入存储器。When the bus sends out continuous read and write operations, through configuration, the read-write control circuit can first perform the read operation, read the data required for the read operation, and then perform the write operation, and store the data corresponding to the write operation in the cache module. And write the data of the write operation to the memory.
当存在连续的读写操作,特别是连续的写+读操作时,消除了写操作在前时读操作的等待时间,提升了系统访问效率。When there are continuous read and write operations, especially continuous write + read operations, the waiting time of the read operation when the write operation is preceded is eliminated, and the system access efficiency is improved.
下面将对读写控制电路的写操作相关配置进行介绍。The configuration related to the write operation of the read/write control circuit will be introduced below.
参照图2所示的缓存模块示意图,缓存模块可以包括第一级写缓存单元和第二级写缓存单元。作为一种示例,第一级写缓存单元和第二级写缓存单元存储的数据可以为32bit。Referring to the schematic diagram of the cache module shown in FIG. 2 , the cache module may include a first-level write cache unit and a second-level write cache unit. As an example, the data stored in the first-level write cache unit and the second-level write cache unit may be 32 bits.
在此基础上,读写控制电路可以被配置为:On this basis, the read-write control circuit can be configured as:
当存在写操作时,将写操作对应的数据存储在第一级写缓存单元中;When there is a write operation, the data corresponding to the write operation is stored in the first-level write cache unit;
若当前不存在待执行的读操作,则执行将第一级写缓存单元当前存储的数据写入第二级写缓存单元的操作。If there is currently no read operation to be performed, the operation of writing the data currently stored in the first-level write cache unit into the second-level write cache unit is performed.
在一种可能的实施方式中,每当总线发出写操作时,首先将写操作对应的数据存入第一级写缓存单元,在总线下一次非读地址相位(也即是不存在待执行的读操作)时,将第一级写缓存单元的数据写入第二级写缓存单元。也即是说,如果总线中写地址相位的下一个时钟周期为读地址相位(即触发读操作),则将写操作暂时挂起,优先读SRAM,等待总线没有读地址相位时,再将挂起的写操作执行,即写入第二级写缓存单元。作为一种示例,参照图6,HWRITE为高电平且HADDR存在地址相位时表示AHB总线发出写操作,此时的地址相位为写地址相位;HWRITE为低电平且HADDR存在地址相位时表示AHB总线发出读操作,此时的地址相位为读地址相位。In a possible implementation, whenever a write operation is issued by the bus, the data corresponding to the write operation is first stored in the first-level write buffer unit, and the next non-read address phase of the bus (that is, there is no pending execution) read operation), write the data of the first-level write cache unit into the second-level write cache unit. That is to say, if the next clock cycle of the write address phase in the bus is the read address phase (that is, the read operation is triggered), the write operation is temporarily suspended, the SRAM is read first, and when there is no read address phase on the bus, the write operation is suspended. The write operation from the beginning of the write operation is executed, that is, the second-level write cache unit is written. As an example, referring to FIG. 6 , when HWRITE is high and HADDR has an address phase, it means that the AHB bus issues a write operation, and the address phase at this time is the write address phase; when HWRITE is low and HADDR has an address phase, it means AHB The bus issues a read operation, and the address phase at this time is the read address phase.
可选的,在将第一级写缓存单元的数据写入第二级写缓存单元之后,可以将第一级写缓存单元清空。Optionally, after the data of the first-level write cache unit is written into the second-level write cache unit, the first-level write cache unit may be cleared.
下面将分别对触发操作的各个情况进行介绍。Each situation of the trigger operation will be introduced separately below.
情况一:触发连续的写+读操作,即写操作在前,读操作在后。Case 1: Trigger continuous write + read operations, that is, the write operation comes first, and the read operation comes after.
此种情况下,读写控制电路可以被配置为:In this case, the read-write control circuit can be configured as:
接收第一操作指令,并确定第一操作指令为写操作,则执行第一操作指令并将第一操作指令对应的数据存储在第一级写缓存单元中;Receive the first operation instruction, and determine that the first operation instruction is a write operation, then execute the first operation instruction and store the data corresponding to the first operation instruction in the first-level write cache unit;
接收第二操作指令,并确定第二操作指令为读操作,若第一操作指令处于执行状态,则将第一操作指令挂起,执行第二操作指令以获取第二操作指令所需的数据并写回;Receive the second operation instruction, and determine that the second operation instruction is a read operation. If the first operation instruction is in the execution state, the first operation instruction is suspended, and the second operation instruction is executed to obtain the data required by the second operation instruction and write back;
第二操作指令执行完毕后,若当前不存在待执行的读操作,则将挂起的第一操作指令执行,并执行将第一级写缓存单元当前存储的数据写入第二级写缓存单元的操作。After the second operation instruction is executed, if there is currently no read operation to be executed, the pending first operation instruction is executed, and the data currently stored in the first-level write cache unit is written into the second-level write cache unit. operation.
在一种可能的实施方式中,在第一个时钟周期,总线中触发写操作对应的第一操作指令,则可以接收到该第一操作指令并确定指令类型为写操作,进而读写控制电路可以执行该写操作,将写操作对应的数据存入第一级写缓存单元。接下来的第二个时钟周期,总线中触发读操作对应的第二操作指令,则可以接收到该第二操作指令并确定指令类型为写操作,进而读写控制电路可以将上述写操作挂起,执行该读操作,获取该读操作所需的数据并作为第二操作指令的结果写回。接下来的第三个时钟周期,若总线中触发另一写操作或者不触发任何操作,此时总线中没有读地址相位,则读写控制电路可以将挂起的写操作执行,也即是执行将第一级写缓存单元当前存储的数据写入第二级写缓存单元的操作。In a possible implementation, in the first clock cycle, the first operation instruction corresponding to the write operation is triggered in the bus, the first operation instruction can be received and the type of the instruction can be determined as a write operation, and then the read and write control circuit The write operation may be performed to store the data corresponding to the write operation into the first-level write cache unit. In the next second clock cycle, the second operation instruction corresponding to the read operation is triggered in the bus, the second operation instruction can be received and the instruction type can be determined as a write operation, and then the read-write control circuit can suspend the above write operation. , perform the read operation, obtain the data required by the read operation, and write it back as the result of the second operation instruction. In the next third clock cycle, if another write operation is triggered on the bus or no operation is triggered, and there is no read address phase in the bus at this time, the read-write control circuit can execute the pending write operation, that is, execute The operation of writing the data currently stored in the first-level write-cache unit into the second-level write-cache unit.
此外,在上述第三个时钟周期中,若总线中触发另一读操作,该读操作与挂起的写操作仍然存在访问存储器的冲突(即写操作在前时读操作存在等待时间),仍然符合上述情况一。此时,可以继续保持写操作挂起,直至总线中不存在待执行的读操作,则执行将第一级写缓存单元当前存储的数据写入第二级写缓存单元的操作。In addition, in the above third clock cycle, if another read operation is triggered in the bus, the read operation and the pending write operation still have a conflict of accessing the memory (that is, there is a waiting time for the read operation when the write operation is ahead), and the read operation still has a conflict with the pending write operation. Consistent with the above situation. At this time, the write operation may continue to be suspended until there is no read operation to be performed on the bus, and then the operation of writing the data currently stored in the first-level write cache unit into the second-level write cache unit is performed.
情况二:触发连续的读+写操作,即读操作在前,写操作在后。Case 2: Trigger continuous read + write operations, that is, read operations come first and write operations follow.
此种情况下,读写控制电路可以被配置为:In this case, the read-write control circuit can be configured as:
接收第三操作指令,并确定第三操作指令为读操作,则执行第三操作指令以获取第三操作指令所需的数据并写回;Receive the third operation instruction, and determine that the third operation instruction is a read operation, execute the third operation instruction to obtain the data required by the third operation instruction and write it back;
接收第四操作指令,并确定第四操作指令为写操作,则在第三操作指令执行完毕后,执行第四操作指令并将第四操作指令对应的数据存储在第一级写缓存单元中;Receive the fourth operation instruction, and determine that the fourth operation instruction is a write operation, then after the execution of the third operation instruction is completed, execute the fourth operation instruction and store the data corresponding to the fourth operation instruction in the first-level write cache unit;
若当前不存在待执行的读操作,则执行将第一级写缓存单元当前存储的数据写入第二级写缓存单元的操作。If there is currently no read operation to be performed, the operation of writing the data currently stored in the first-level write cache unit into the second-level write cache unit is performed.
在一种可能的实施方式中,在第一个时钟周期,总线中触发读操作对应的第三操作指令,则可以接收到该第三操作指令并确定指令类型为读操作,进而读写控制电路可以执行该读操作,获取该读操作所需的数据并作为第三操作指令的结果写回。接下来的第二个时钟周期,总线中触发写操作对应的第四操作指令,则可以接收到该第四操作指令并确定指令类型为写操作,并确定上述读操作是否执行完毕。在上述读操作执行完毕后,读写控制电路可以执行第四操作指令对应的写操作,将该写操作对应的数据存入第一级写缓存单元。接下来的第三个时钟周期,若总线中触发另一写操作或者不触发任何操作,此时总线中没有读地址相位,则读写控制电路可以执行将第一级写缓存单元当前存储的数据写入第二级写缓存单元的操作。In a possible implementation, in the first clock cycle, the third operation instruction corresponding to the read operation is triggered in the bus, the third operation instruction can be received and the instruction type can be determined as a read operation, and then the read and write control circuit can be read and written. The read operation can be performed, and the data required for the read operation is obtained and written back as a result of the third operation instruction. In the next second clock cycle, the fourth operation instruction corresponding to the write operation is triggered in the bus, the fourth operation instruction can be received, the instruction type can be determined as a write operation, and it is determined whether the above-mentioned read operation is completed. After the above-mentioned read operation is completed, the read-write control circuit may execute the write operation corresponding to the fourth operation instruction, and store the data corresponding to the write operation into the first-level write cache unit. In the next third clock cycle, if another write operation is triggered in the bus or no operation is triggered, and there is no read address phase in the bus at this time, the read-write control circuit can execute the data currently stored in the first-level write cache unit. An operation that writes to a second-level write cache unit.
同样,在上述第三个时钟周期中,若总线中触发另一读操作,该读操作与第四操作指令对应的写操作存在访问存储器的冲突(即写操作在前时读操作存在等待时间),符合上述情况一。此时,可以将该写操作挂起,直至总线中不存在待执行的读操作,则执行将第一级写缓存单元当前存储的数据写入第二级写缓存单元的操作。Similarly, in the above third clock cycle, if another read operation is triggered in the bus, the read operation and the write operation corresponding to the fourth operation instruction have a conflict of accessing the memory (that is, there is a waiting time for the read operation when the write operation is preceding) , which is consistent with the above situation. At this time, the write operation can be suspended until there is no read operation to be performed on the bus, and then the operation of writing the data currently stored in the first-level write cache unit into the second-level write cache unit is performed.
情况三:触发连续的写+写操作或单独的写操作。Case 3: Trigger continuous write + write operation or separate write operation.
此种情况下,读写控制电路可以被配置为:In this case, the read-write control circuit can be configured as:
接收第五操作指令,并确定第五操作指令为写操作,则执行第五操作指令并将第五操作指令对应的数据存储在第一级写缓存单元中;Receive the fifth operation instruction, and determine that the fifth operation instruction is a write operation, then execute the fifth operation instruction and store the data corresponding to the fifth operation instruction in the first-level write cache unit;
若当前不存在待执行的读操作,则执行将第一级写缓存单元当前存储的数据写入第二级写缓存单元的操作。If there is currently no read operation to be performed, the operation of writing the data currently stored in the first-level write cache unit into the second-level write cache unit is performed.
在一种可能的实施方式中,在第一个时钟周期,总线中触发写操作对应的第五操作指令,则可以接收到该第五操作指令并确定指令类型为写操作,进而读写控制电路可以执行该写操作,将该写操作对应的数据存入第一级写缓存单元。接下来的第二个时钟周期,总线中触发另一写操作对应的第六操作指令或不触发任何操作(即不存在待执行的读操作),则读写控制电路可以执行将第一级写缓存单元当前存储的数据写入第二级写缓存单元的操作。此后,对应于接收到第六操作指令的情况,读写控制电路还可以清空第一级写缓存单元,将第六操作指令的写操作对应的数据存入第一级写缓存单元。In a possible implementation, in the first clock cycle, the fifth operation instruction corresponding to the write operation is triggered in the bus, the fifth operation instruction can be received and the instruction type can be determined as a write operation, and then the read and write control circuit The write operation may be performed, and the data corresponding to the write operation is stored in the first-level write cache unit. In the next second clock cycle, the sixth operation instruction corresponding to another write operation is triggered in the bus or no operation is triggered (that is, there is no read operation to be performed), then the read-write control circuit can execute the first-level write operation. The operation of writing the data currently stored in the cache unit to the second-level write cache unit. Thereafter, in response to receiving the sixth operation instruction, the read-write control circuit may also clear the first-level write cache unit, and store the data corresponding to the write operation of the sixth operation instruction into the first-level write cache unit.
可选的,上述执行将第一级写缓存单元当前存储的数据写入第二级写缓存单元的操作的具体处理可以如下:Optionally, the specific processing of the above-mentioned operation of writing the data currently stored in the first-level write cache unit into the second-level write cache unit may be as follows:
将第一级写缓存单元当前存储的数据作为第一数据,判断第二级写缓存单元是否存储有第二数据;Using the data currently stored in the first-level write cache unit as the first data, determine whether the second-level write cache unit stores the second data;
如果第二级写缓存单元当前存储有第二数据,则判断第一数据对应的写地址与第二数据对应的写地址是否满足相邻条件,相邻条件是指在存储器中的存储位置相邻;若满足相邻条件,则将第一数据和第二数据写入存储器;若不满足相邻条件,则将第二数据写入存储器,将第一数据写入第二级写缓存单元;If the second-level write cache unit currently stores the second data, it is determined whether the write address corresponding to the first data and the write address corresponding to the second data satisfy the adjacent condition. The adjacent condition means that the storage locations in the memory are adjacent to each other. ; If the adjacent conditions are met, the first data and the second data are written into the memory; if the adjacent conditions are not met, the second data is written into the memory, and the first data is written into the second-level write cache unit;
如果第二级写缓存单元当前未存储第二数据,则将第一级写缓存单元当前存储的数据写入第二级写缓存单元。此时,第二级写缓存单元存储的该数据,可以作为下一次执行将第一级写缓存单元当前存储的数据写入第二级写缓存单元的操作时的第二数据。If the second level write cache unit does not currently store the second data, the data currently stored in the first level write cache unit is written into the second level write cache unit. At this time, the data stored in the second-level write cache unit can be used as the second data when the operation of writing the data currently stored in the first-level write cache unit into the second-level write cache unit is performed next time.
作为一种示例,AHB总线发起的读写操作的地址可以如0xXXXX_XXX0、0xXXXX_XXX4、0xXXXX_XXX8和0xXXXX_XXXC,每个地址对应32bit的数据,其中,0xXXXX_XXX0和0xXXXX_XXX4相邻,0xXXXX_XXX8和0xXXXX_XXXC相邻。相邻的两个地址可以在SRAM(位宽为64bit)中寻址到同一物理地址,相邻的两个地址对应的共64bit的数据存储在寻址到的同一物理地址中,也即是满足相邻条件。As an example, the addresses of the read and write operations initiated by the AHB bus may be such as 0xXXXX_XXX0, 0xXXXX_XXX4, 0xXXXX_XXX8 and 0xXXXX_XXXC, and each address corresponds to 32 bits of data, where 0xXXXX_XXX0 and 0xXXXX_XXX4 are adjacent, and 0xXXXX_XXX8 and 0xXXXX_XXXC are adjacent. Two adjacent addresses can be addressed to the same physical address in the SRAM (bit width is 64 bits), and the data of a total of 64 bits corresponding to the two adjacent addresses is stored in the same physical address addressed, that is, it satisfies Adjacent conditions.
每当需要将数据写入第二级写缓存单元时,可以依靠缓存的空满标志判断第二级写缓存单元是否缓存满。如果缓存满,则不可写入,此时可以判断当前待写入数据(即上述第一数据)的地址是否和已缓存于第二级写缓存单元的数据(即上述第二数据)的地址满足上述相邻条件。Whenever data needs to be written into the second-level write cache unit, it can be judged whether the second-level write cache unit is full by relying on the full flag of the cache. If the cache is full, it cannot be written. At this time, it can be judged whether the address of the current data to be written (ie the first data) and the address of the data already cached in the second-level write cache unit (ie the second data) satisfy the aforementioned adjacent conditions.
如果满足,表明在SRAM中寻址一次即可访问到相应位置,并将64bit的数据写入SRAM。If it is satisfied, it means that the corresponding position can be accessed by addressing once in the SRAM, and 64bit data is written into the SRAM.
如果不满足,则将已缓存于第二级写缓存单元的32bit的数据写入SRAM,将当前待写入的32bit的数据写入第二级写缓存单元,等待与其相邻的另一32bit的数据一齐写入SRAM。If it is not satisfied, write the 32-bit data that has been cached in the second-level write cache unit into the SRAM, write the 32-bit data currently to be written into the second-level write cache unit, and wait for another 32-bit data adjacent to it. Data is written to SRAM all at once.
通过上述配置,第二级写缓存单元可以用于缓存等待相邻地址的数据,当连续两次写入的是相邻的两个地址的数据时,可以一齐将两个地址的数据写入存储器,减少了访问存储器的次数,从而降低系统功耗。Through the above configuration, the second-level write cache unit can be used to cache the data waiting for adjacent addresses. When the data of two adjacent addresses are written twice in a row, the data of the two addresses can be written into the memory at the same time. , reducing the number of memory accesses, thereby reducing system power consumption.
此后,可以在总线空闲时将数据写入存储器,在此基础上,读写控制电路还可以被配置为:在总线空闲时,将缓存模块中当前存储的数据写入存储器。可选的,将数据写入存储器后,可以将缓存模块中的相应数据删除,即清空缓存模块。After that, the data can be written into the memory when the bus is idle, and on this basis, the read-write control circuit can also be configured to write the data currently stored in the cache module into the memory when the bus is idle. Optionally, after the data is written into the memory, the corresponding data in the cache module may be deleted, that is, the cache module may be cleared.
通过上述配置,当存在连续的读写操作时,写操作的数据可以缓存在缓存模块中,优先读取读操作的数据,此后才将写操作的数据写入存储器,消除了写操作在前时读操作的等待时间,提升了系统访问效率。Through the above configuration, when there are continuous read and write operations, the data of the write operation can be cached in the cache module, and the data of the read operation is read first, and then the data of the write operation is written into the memory, eliminating the need for the write operation to be in the first place. The waiting time of the read operation improves the system access efficiency.
下面将对读写控制电路的读操作相关配置进行介绍。The configuration related to the read operation of the read/write control circuit will be introduced below.
对于读操作,读写控制电路可以被配置为:For read operations, the read/write control circuit can be configured as:
当缓存模块中存在读操作所需的数据时,从缓存模块中获取该所需的数据;When the data required for the read operation exists in the cache module, obtain the required data from the cache module;
当缓存模块中不存在读操作所需的数据时,从存储器中读取该所需的数据。When the data required for the read operation does not exist in the cache module, the required data is read from the memory.
在一种可能的实施方式中,可以基于读操作的地址和已缓存于缓存模块中的数据的地址判断是否为读操作所需的数据。如果缓存模块中存在与读操作相同地址的数据,表明该数据为读操作所需的数据,则可以从缓存模块中获取该数据作为读操作的结果并写回。如果不存在,则可以访问存储器,读取读操作所需的数据并写回。In a possible implementation manner, whether the data is required for the read operation may be determined based on the address of the read operation and the address of the data already cached in the cache module. If the data at the same address as the read operation exists in the cache module, indicating that the data is required for the read operation, the data can be obtained from the cache module as the result of the read operation and written back. If not present, the memory can be accessed, the data needed for the read operation is read and written back.
通过上述配置,也可以减少访问存储器的次数,降低系统功耗。Through the above configuration, the number of times of accessing the memory can also be reduced, and the power consumption of the system can be reduced.
可选的,当缓存模块包括第一级写缓存单元和第二级写缓存单元时,读写控制电路可以被配置为:Optionally, when the cache module includes a first-level write cache unit and a second-level write cache unit, the read-write control circuit may be configured as:
对于第一级写缓存单元:判断当前读操作对应的读地址与第一级写缓存单元的数据对应的写地址是否相同,如果相同,则从第一级写缓存单元中获取当前读操作的数据;如果不相同,则进入如下对于第二级写缓存单元的判断;For the first-level write cache unit: determine whether the read address corresponding to the current read operation is the same as the write address corresponding to the data of the first-level write-cache unit, if they are the same, obtain the data of the current read operation from the first-level write-cache unit ; If they are not the same, enter the following judgment for the second-level write cache unit;
对于第二级写缓存单元:判断当前读操作对应的读地址与第二级写缓存单元的数据对应的写地址是否相同,如果相同,则从第二级写缓存单元中获取当前读操作的数据。For the second-level write cache unit: determine whether the read address corresponding to the current read operation is the same as the write address corresponding to the data of the second-level write cache unit, if they are the same, obtain the data of the current read operation from the second-level write cache unit .
也即是说,可以依次判断第一级写缓存单元和第二级写缓存单元是否存储读操作所需的数据,如果是,则读操作的数据来源于相应的写缓存单元。That is to say, whether the first-level write cache unit and the second-level write cache unit store data required for the read operation can be sequentially determined, and if so, the read operation data comes from the corresponding write cache unit.
如果第二级写缓存单元中仍然未查找到所需数据,则可以从存储器中读取所需的数据,或者,采用下文提供的技术方案继续查找。If the required data is still not found in the second-level write cache unit, the required data can be read from the memory, or the technical solution provided below is used to continue the search.
为了进一步降低系统功耗,与上文中一齐写入相邻的两个地址的数据的技术方案相类似的,还可以通过缓存模块一齐将相邻的两个地址的数据读出,将读操作所需的数据取走后,将相邻存储位置的数据写入缓存模块。在判断缓存模块中是否存在读操作所需的数据时,还可以通过判断前一次读操作是否将当前读操作所需的数据一齐读出,从而判断是否为所需数据。In order to further reduce the power consumption of the system, similar to the technical solution of writing the data of two adjacent addresses at the same time, the data of the two adjacent addresses can be read out through the cache module at the same time, and the data of the two adjacent addresses can be read out by the cache module. After the required data is taken away, the data in the adjacent storage location is written into the cache module. When judging whether the data required for the read operation exists in the cache module, it can also be judged whether the data required for the current read operation is read out by judging whether the data required for the current read operation is read out in the previous read operation.
在此基础上,作为一种可选方案,参照图3所示的缓存模块示意图,缓存模块还可以包括读缓存单元,读缓存单元可以用于存储上述相邻存储位置的数据。作为一种示例,读缓存单元存储的数据可以为32bit。On this basis, as an optional solution, referring to the schematic diagram of the cache module shown in FIG. 3 , the cache module may further include a read cache unit, and the read cache unit may be used to store the data of the above-mentioned adjacent storage locations. As an example, the data stored in the read cache unit may be 32 bits.
当读缓存单元与上述第一级写缓存单元、第二级写缓存单元相结合时,如图4所示。在此基础上,读写控制电路还可以被配置为:When the read cache unit is combined with the first level write cache unit and the second level write cache unit, as shown in FIG. 4 . On this basis, the read-write control circuit can also be configured as:
在判断当前读操作对应的读地址与第二级写缓存单元的数据对应的地址是否相同之后,如果不相同,则进入如下对于读缓存单元的判断;After judging whether the read address corresponding to the current read operation and the address corresponding to the data of the second-level write cache unit are the same, if they are not the same, enter the following judgment on the read cache unit;
对于读缓存单元:判断当前读操作对应的读地址与读缓存单元的数据对应的地址是否相同,如果相同,则从读缓存单元中获取当前读操作的数据;如果不相同,则从存储器中读取所需的数据。For the read cache unit: determine whether the read address corresponding to the current read operation is the same as the address corresponding to the data of the read cache unit. If they are the same, obtain the data of the current read operation from the read cache unit; if they are not the same, read from the memory. Fetch the required data.
也即是说,可以依次判断第一级写缓存单元、第二级写缓存单元和读缓存单元是否存储读操作所需的数据,如果是,则读操作的数据来源于相应的缓存单元。That is to say, whether the first-level write cache unit, the second-level write cache unit and the read cache unit store the data required for the read operation can be judged in turn, and if so, the data of the read operation comes from the corresponding cache unit.
其中,判断当前读操作对应的读地址与读缓存单元的数据对应的地址是否相同的处理,也可以是通过判断当前读操作对应的读地址与前一次读操作对应的读地址是否满足上述相邻条件实现,如果满足,则表明当前读操作对应的读地址与读缓存单元的数据对应的地址相同。Among them, the process of judging whether the read address corresponding to the current read operation and the address corresponding to the data of the read cache unit are the same, or whether the read address corresponding to the current read operation and the read address corresponding to the previous read operation satisfy the above-mentioned adjacent If the condition is fulfilled, it indicates that the read address corresponding to the current read operation is the same as the address corresponding to the data of the read cache unit.
此后,如果仍然未查找到所需数据,则可以从存储器中读取所需的数据。After that, if the desired data is still not found, the desired data can be read from the memory.
当需要从存储器读取数据时,读写控制电路可以被配置为:When data needs to be read from memory, the read-write control circuit can be configured as:
基于当前读操作对应的读地址,从存储器中读取读地址及其相邻存储位置的数据;Based on the read address corresponding to the current read operation, read the data of the read address and its adjacent storage locations from the memory;
将读地址的数据作为当前读操作所需的数据写回后,将相邻存储位置的数据写入读缓存单元。After the data of the read address is written back as the data required by the current read operation, the data of the adjacent storage location is written into the read cache unit.
作为一种具体的示例,参照图5示出的读写控制电路示意图,该读写控制电路具体可以由第一级写缓存单元、第二级写缓存单元、读缓存单元、第一数据选择器、第二数据选择器、第三数据选择器、第四数据选择器和写数据选择控制电路构成,其中,第一级写缓存单元、第二级写缓存单元和读缓存单元可以对应于上述缓存模块,可以通过第一数据选择器、第二数据选择器、第三数据选择器、第四数据选择器和写数据选择控制电路实现上述读写控制电路的配置。As a specific example, referring to the schematic diagram of the read-write control circuit shown in FIG. 5 , the read-write control circuit may specifically consist of a first-level write cache unit, a second-level write cache unit, a read cache unit, and a first data selector. , a second data selector, a third data selector, a fourth data selector and a write data selection control circuit, wherein the first level write cache unit, the second level write cache unit and the read cache unit may correspond to the above cache Module, the configuration of the read-write control circuit can be realized through the first data selector, the second data selector, the third data selector, the fourth data selector and the write data selection control circuit.
第一级写缓存单元的输入端可以与AHB总线连接,输出端分别与第一数据选择器和第二数据选择器连接。The input end of the first-level write buffer unit can be connected to the AHB bus, and the output end is respectively connected to the first data selector and the second data selector.
第二级写缓存单元的输入端可以与第一数据选择器连接,输出端分别与写数据选择控制电路、第三数据选择器连接。The input end of the second-level write buffer unit can be connected to the first data selector, and the output end is respectively connected to the write data selection control circuit and the third data selector.
读缓存单元的输入端可以与SRAM连接,输出端与第四数据选择器连接。The input end of the read buffer unit can be connected to the SRAM, and the output end is connected to the fourth data selector.
第一数据选择器的输入端可以分别与AHB总线、第一级写缓存单元连接,输出端分别与第二级写缓存单元、写数据选择控制电路连接。The input end of the first data selector can be connected to the AHB bus and the first-level write buffer unit respectively, and the output end is respectively connected to the second-level write buffer unit and the write data selection control circuit.
第二数据选择器的输入端可以分别与第一级写缓存单元、第三数据选择器连接,输出端与AHB总线连接。The input end of the second data selector can be connected to the first-level write buffer unit and the third data selector respectively, and the output end is connected to the AHB bus.
第三数据选择器的输入端可以分别与第二级写缓存单元、第四数据选择器连接,输出端与第二数据选择器连接。The input end of the third data selector can be connected to the second-level write buffer unit and the fourth data selector respectively, and the output end is connected to the second data selector.
第四数据选择器的输入端可以分别与SRAM、读缓存单元连接,输出端与第三数据选择器连接。The input end of the fourth data selector can be connected to the SRAM and the read buffer unit respectively, and the output end is connected to the third data selector.
写数据选择控制电路的输入端可以分别与第一数据选择器、第二级写缓存单元连接,输出端与SRAM连接。The input end of the write data selection control circuit can be respectively connected to the first data selector and the second level write buffer unit, and the output end is connected to the SRAM.
本申请实施例可以取得如下有益效果:The embodiments of the present application can achieve the following beneficial effects:
(1)当存在连续的读写操作时,写操作的数据可以缓存在缓存模块中,优先读取读操作的数据,此后才将写操作的数据写入存储器,消除了写操作在前时读操作的等待时间,提升了系统访问效率。(1) When there are continuous read and write operations, the data of the write operation can be cached in the cache module, and the data of the read operation is read first, and then the data of the write operation is written into the memory, eliminating the need for the read operation when the write operation is preceded. The waiting time of the operation improves the system access efficiency.
图6示出了未采用本申请提供的读写控制电路时的系统时序图,其中,HWRITE为高电平且HADDR存在地址相位时表示AHB总线发出写操作,HWRITE为低电平且HADDR存在地址相位时表示AHB总线发出读操作,图6中写操作和读操作连续、且写操作在前。通过时序图可以看到,SRAM首先触发写操作WR,而后触发读操作RD,但是,由于SRAM写入需要时间,触发读操作RD时HREADYOUT为低电平,表明未准备好读取数据(HRDATA中的阴影部分示意),读操作延迟一拍后读出数据(HRDATA中的RDATA示意,未在RD的下一拍读出RDATA)。Figure 6 shows the system timing diagram when the read-write control circuit provided by the present application is not used, wherein, when HWRITE is high and HADDR has an address phase, it means that the AHB bus issues a write operation, HWRITE is low and HADDR has an address When in phase, it means that the AHB bus sends out a read operation. In Figure 6, the write operation and the read operation are continuous, and the write operation comes first. It can be seen from the timing diagram that SRAM first triggers the write operation WR, and then triggers the read operation RD. However, because SRAM requires time to write, HREADYOUT is low when the read operation RD is triggered, indicating that the data is not ready to be read (in HRDATA The shaded part of ) indicates that the read operation is delayed by one beat and then reads out data (RDATA in HRDATA indicates that RDATA is not read out in the next beat of RD).
图7示出了采用本申请提供的读写控制电路后的系统时序图,其中,SRAM首先触发读操作RD,而后触发写操作WR,RDATA可以在RD的下一拍读出,消除了等待写操作WR写入的时间。Figure 7 shows the system timing diagram after using the read-write control circuit provided by the present application, wherein, SRAM first triggers the read operation RD, and then triggers the write operation WR, and RDATA can be read out in the next shot of RD, eliminating the need for waiting for writing Time to operate WR write.
(2)当连续两次写入的是相邻的两个地址的数据时,可以一齐将两个地址的数据写入存储器,和/或,可以一齐将相邻的两个地址的数据读出,当连续两次读取的是相邻的两个地址的数据时,可以从缓存模块获取数据,减少了访问存储器的次数,从而降低系统功耗。(2) When the data of two adjacent addresses are written twice in a row, the data of the two addresses can be written into the memory at the same time, and/or the data of the two adjacent addresses can be read out at the same time , when the data of two adjacent addresses are read for two consecutive times, the data can be obtained from the cache module, which reduces the number of times of accessing the memory, thereby reducing the power consumption of the system.
图8示出了未采用本申请提供的读写控制电路时的系统时序图,其中,addr0和addr1为相邻的两个写地址,addr2和addr3为相邻的两个读地址,可以看到每次AHB总线读写都会触发SRAM读写(每个WR对应一个写地址,每个RD对应一个读地址),系统功耗较高。Figure 8 shows a system timing diagram when the read-write control circuit provided by the present application is not used, wherein addr0 and addr1 are two adjacent write addresses, and addr2 and addr3 are two adjacent read addresses. It can be seen that Every AHB bus read and write will trigger SRAM read and write (each WR corresponds to a write address, each RD corresponds to a read address), and the system power consumption is high.
图9示出了采用本申请提供的读写控制电路后的系统时序图,其中,可以看到AHB总线的2次读操作/写操作仅触发了SRAM的1次读操作/写操作(addr0和addr1触发一个WR,addr2和addr3触发一个RD),降低了系统功耗。Fig. 9 shows the system timing diagram after using the read-write control circuit provided by the present application, in which it can be seen that the two read/write operations of the AHB bus only trigger one read/write operation of the SRAM (addr0 and addr1 triggers a WR, addr2 and addr3 trigger a RD), which reduces system power consumption.
本申请实施例还提供了一种读写控制电路的控制方法,可以用于控制上述读写控制电路,该读写控制电路包括缓存模块。参照图10所示的读写控制电路的控制方法流程图,该方法可以包括如下步骤1001-1002:The embodiment of the present application also provides a control method for a read-write control circuit, which can be used to control the above-mentioned read-write control circuit, and the read-write control circuit includes a cache module. Referring to the flow chart of the control method of the read-write control circuit shown in FIG. 10, the method may include the following steps 1001-1002:
步骤1001,当存在连续的读写操作时,执行读操作,并将写操作对应的数据存储在所述缓存模块中;Step 1001, when there are continuous read and write operations, perform a read operation, and store the data corresponding to the write operation in the cache module;
步骤1002,从所述缓存模块中将写操作对应的数据写入存储器。Step 1002: Write the data corresponding to the write operation into the memory from the cache module.
可选的,所述缓存模块包括第一级写缓存单元和第二级写缓存单元;Optionally, the cache module includes a first-level write cache unit and a second-level write cache unit;
所述将写操作对应的数据存储在所述缓存模块中,包括:The storing of the data corresponding to the write operation in the cache module includes:
当存在写操作时,将写操作对应的数据存储在所述第一级写缓存单元中;When there is a write operation, the data corresponding to the write operation is stored in the first-level write cache unit;
若当前不存在待执行的读操作,则执行将所述第一级写缓存单元当前存储的数据写入所述第二级写缓存单元的操作。If there is no read operation to be performed currently, the operation of writing the data currently stored in the first-level write cache unit into the second-level write cache unit is performed.
可选的,所述当存在连续的读写操作时,执行读操作,并将写操作对应的数据存储在所述缓存模块中,包括:Optionally, when there are continuous read and write operations, the read operation is performed, and the data corresponding to the write operation is stored in the cache module, including:
接收第一操作指令,并确定所述第一操作指令为写操作,则执行所述第一操作指令并将所述第一操作指令对应的数据存储在所述第一级写缓存单元中;Receive a first operation instruction, and determine that the first operation instruction is a write operation, execute the first operation instruction and store the data corresponding to the first operation instruction in the first-level write cache unit;
接收第二操作指令,并确定所述第二操作指令为读操作,若所述第一操作指令处于执行状态,则将所述第一操作指令挂起,执行所述第二操作指令以获取所述第二操作指令所需的数据并写回;Receive a second operation instruction, and determine that the second operation instruction is a read operation, if the first operation instruction is in the execution state, suspend the first operation instruction, and execute the second operation instruction to obtain the Describe the data required by the second operation instruction and write it back;
所述第二操作指令执行完毕后,若当前不存在待执行的读操作,则将挂起的所述第一操作指令执行,并执行将所述第一级写缓存单元当前存储的数据写入所述第二级写缓存单元的操作。After the execution of the second operation instruction is completed, if there is currently no read operation to be executed, the pending first operation instruction is executed, and the data currently stored in the first-level write cache unit is written. the operation of the second level write cache unit.
可选的,所述当存在连续的读写操作时,执行读操作,并将写操作对应的数据存储在所述缓存模块中,包括:Optionally, when there are continuous read and write operations, the read operation is performed, and the data corresponding to the write operation is stored in the cache module, including:
接收第三操作指令,并确定所述第三操作指令为读操作,则执行所述第三操作指令以获取所述第三操作指令所需的数据并写回;Receive a third operation instruction, and determine that the third operation instruction is a read operation, execute the third operation instruction to obtain the data required by the third operation instruction and write it back;
接收第四操作指令,并确定所述第四操作指令为写操作,则在所述第三操作指令执行完毕后,执行所述第四操作指令并将所述第四操作指令对应的数据存储在所述第一级写缓存单元中;After receiving the fourth operation instruction, and determining that the fourth operation instruction is a write operation, after the execution of the third operation instruction is completed, the fourth operation instruction is executed and the data corresponding to the fourth operation instruction is stored in the in the first-level write cache unit;
若当前不存在待执行的读操作,则执行将所述第一级写缓存单元当前存储的数据写入所述第二级写缓存单元的操作。If there is no read operation to be performed currently, the operation of writing the data currently stored in the first-level write cache unit into the second-level write cache unit is performed.
可选的,所述方法还包括:Optionally, the method further includes:
接收第五操作指令,并确定所述第五操作指令为写操作,则执行所述第五操作指令并将所述第五操作指令对应的数据存储在所述第一级写缓存单元中;Receive a fifth operation instruction, and determine that the fifth operation instruction is a write operation, execute the fifth operation instruction and store the data corresponding to the fifth operation instruction in the first-level write cache unit;
若当前不存在待执行的读操作,则执行将所述第一级写缓存单元当前存储的数据写入所述第二级写缓存单元的操作。If there is no read operation to be performed currently, the operation of writing the data currently stored in the first-level write cache unit into the second-level write cache unit is performed.
可选的,所述执行将所述第一级写缓存单元当前存储的数据写入所述第二级写缓存单元的操作,包括:Optionally, the performing the operation of writing data currently stored in the first-level write-cache unit into the second-level write-cache unit includes:
将所述第一级写缓存单元当前存储的数据作为第一数据,如果所述第二级写缓存单元当前存储有第二数据,则判断所述第一数据对应的写地址与所述第二数据对应的写地址是否满足相邻条件,所述相邻条件是指在所述存储器中的存储位置相邻;The data currently stored in the first-level write cache unit is used as the first data, and if the second-level write cache unit currently stores the second data, it is determined that the write address corresponding to the first data is the same as the second data. Whether the write address corresponding to the data satisfies the adjacent condition, the adjacent condition means that the storage locations in the memory are adjacent;
若满足所述相邻条件,则将所述第一数据和所述第二数据写入所述存储器;If the adjacent condition is satisfied, writing the first data and the second data into the memory;
若不满足所述相邻条件,则将所述第二数据写入所述存储器,将所述第一数据写入所述第二级写缓存单元。If the adjacent condition is not satisfied, the second data is written into the memory, and the first data is written into the second-level write cache unit.
可选的,所述方法还包括:Optionally, the method further includes:
在总线空闲时,将所述缓存模块中当前存储的数据写入所述存储器。When the bus is idle, the data currently stored in the cache module is written into the memory.
可选的,所述执行读操作,包括:Optionally, the performing a read operation includes:
当所述缓存模块中存在读操作所需的数据时,从所述缓存模块中获取所述所需的数据;When the data required for the read operation exists in the cache module, obtain the required data from the cache module;
当所述缓存模块中不存在读操作所需的数据时,从所述存储器中读取所述所需的数据。When the data required for the read operation does not exist in the cache module, the required data is read from the memory.
可选的,所述缓存模块包括第一级写缓存单元和第二级写缓存单元;Optionally, the cache module includes a first-level write cache unit and a second-level write cache unit;
所述当所述缓存模块中存在所述读操作所需的数据时,从所述缓存模块中获取所述所需的数据,包括:When the data required for the read operation exists in the cache module, acquiring the required data from the cache module includes:
对于所述第一级写缓存单元:判断当前读操作对应的读地址与所述第一级写缓存单元的数据对应的写地址是否相同,如果相同,则从所述第一级写缓存单元中获取当前读操作的数据;如果不相同,则进入如下对于所述第二级写缓存单元的判断;For the first-level write cache unit: determine whether the read address corresponding to the current read operation is the same as the write address corresponding to the data of the first-level write-cache unit; Obtain the data of the current read operation; if it is not the same, enter the judgment on the second-level write cache unit as follows;
对于所述第二级写缓存单元:判断当前读操作对应的读地址与所述第二级写缓存单元的数据对应的写地址是否相同,如果相同,则从所述第二级写缓存单元中获取当前读操作的数据。For the second level write cache unit: determine whether the read address corresponding to the current read operation is the same as the write address corresponding to the data of the second level write cache unit, if they are the same, then from the second level write cache unit Get the data of the current read operation.
可选的,所述缓存模块还包括读缓存单元;Optionally, the cache module further includes a read cache unit;
所述方法还包括:The method also includes:
在所述判断当前读操作对应的读地址与所述第二级写缓存单元的数据对应的地址是否相同之后,如果不相同,则进入如下对于所述读缓存单元的判断;After judging whether the read address corresponding to the current read operation is the same as the address corresponding to the data of the second-level write cache unit, if they are not the same, enter the following judgment on the read cache unit;
对于所述读缓存单元:判断当前读操作对应的读地址与所述读缓存单元的数据对应的地址是否相同,如果相同,则从所述读缓存单元中获取当前读操作的数据;如果不相同,则从所述存储器中读取所述所需的数据。For the read cache unit: determine whether the read address corresponding to the current read operation is the same as the address corresponding to the data of the read cache unit, if they are the same, then obtain the data of the current read operation from the read cache unit; if not the same , the required data is read from the memory.
可选的,所述方法还包括:Optionally, the method further includes:
基于当前读操作对应的读地址,从所述存储器中读取所述读地址及其相邻存储位置的数据;Based on the read address corresponding to the current read operation, read the data of the read address and its adjacent storage locations from the memory;
将所述读地址的数据作为当前读操作所需的数据写回,并将所述相邻存储位置的数据写入所述读缓存单元。The data of the read address is written back as the data required for the current read operation, and the data of the adjacent storage location is written into the read cache unit.
本申请实施例中,当存在连续的读写操作时,写操作的数据可以缓存在缓存模块中,优先读取读操作的数据,此后才将写操作的数据写入存储器,消除了写操作在前时读操作的等待时间,提升了系统访问效率。In the embodiment of the present application, when there are continuous read and write operations, the data of the write operation can be cached in the cache module, and the data of the read operation is read first, and then the data of the write operation is written into the memory, which eliminates the need for the write operation in the memory. The waiting time of the previous read operation improves the system access efficiency.
本申请实施例还提供一种芯片,包括本申请实施例提供的读写控制电路。该芯片可以是但不限于是SOC(System on Chip,芯片级系统)芯片、SIP(system in package,系统级封装)芯片。该芯片通过配置上述读写控制电路,使得系统访问效率提高。The embodiments of the present application further provide a chip, including the read-write control circuit provided by the embodiments of the present application. The chip may be, but is not limited to, a SOC (System on Chip, system-on-chip) chip, or a SIP (system in package, system-in-package) chip. By configuring the above-mentioned read-write control circuit, the chip improves the system access efficiency.
本申请实施例还提供一种电子设备,该电子设备包括设备主体以及设于设备主题内的如上述的芯片。电子设备可以是但不限于体重秤、体脂秤、营养秤、红外电子体温计、脉搏血氧仪、人体成分分析仪、移动电源、无线充电器、快充充电器、车载充电器、适配器、显示器、USB(Universal Serial Bus,通用串行总线)扩展坞、触控笔、真无线耳机、汽车中控屏、汽车、智能穿戴设备、移动终端、智能家居设备。智能穿戴设备包括但不限于智能手表、智能手环、颈椎按摩仪。移动终端包括但不限于智能手机、笔记本电脑、平板电脑、POS(point ofsales terminal,销售点终端)机。智能家居设备包括但不限于智能插座、智能电饭煲、智能扫地机、智能灯。该电子设备通过配置上述读写控制电路,使得电子设备系统访问效率提高。An embodiment of the present application further provides an electronic device, the electronic device includes a device body and the above-mentioned chip provided in the device subject. Electronic devices can be but are not limited to weight scales, body fat scales, nutrition scales, infrared electronic thermometers, pulse oximeters, body composition analyzers, power banks, wireless chargers, fast chargers, car chargers, adapters, monitors , USB (Universal Serial Bus, Universal Serial Bus) docking station, stylus, true wireless headset, car central control screen, automobile, smart wearable device, mobile terminal, smart home equipment. Smart wearable devices include but are not limited to smart watches, smart bracelets, and cervical spine massagers. Mobile terminals include, but are not limited to, smart phones, notebook computers, tablet computers, and POS (point of sales terminal, point of sale terminal) machines. Smart home devices include but are not limited to smart sockets, smart rice cookers, smart sweepers, and smart lights. By configuring the above-mentioned read-write control circuit in the electronic device, the access efficiency of the electronic device system is improved.
以上,仅是本申请的较佳实施例而已,并非对本申请作任何形式上的限制,虽然本申请已以较佳实施例揭示如上,然而并非用以限定本申请,任何本领域技术人员,在不脱离本申请技术方案范围内,当可利用上述揭示的技术内容做出些许更动或修饰为等同变化的等效实施例,但凡是未脱离本申请技术方案内容,依据本申请的技术实质对以上实施例所作的任何简介修改、等同变化与修饰,均仍属于本申请技术方案的范围内。The above are only preferred embodiments of the present application, and are not intended to limit the present application in any form. Although the present application has been disclosed above with preferred embodiments, it is not intended to limit the present application. Without departing from the scope of the technical solution of the present application, when the technical content disclosed above can be used to make some changes or modifications to equivalent examples of equivalent changes, provided that it does not depart from the content of the technical solution of the present application, according to the technical essence of the present application. Any brief modifications, equivalent changes and modifications made in the above embodiments still fall within the scope of the technical solutions of the present application.
Claims (15)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210789662.6A CN115050405A (en) | 2022-07-06 | 2022-07-06 | Read-write control circuit, control method, chip and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210789662.6A CN115050405A (en) | 2022-07-06 | 2022-07-06 | Read-write control circuit, control method, chip and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115050405A true CN115050405A (en) | 2022-09-13 |
Family
ID=83165605
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210789662.6A Pending CN115050405A (en) | 2022-07-06 | 2022-07-06 | Read-write control circuit, control method, chip and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115050405A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117149671A (en) * | 2023-08-30 | 2023-12-01 | 上海合芯数字科技有限公司 | Cache realization method, system, medium and electronic equipment |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20010007538A1 (en) * | 1998-10-01 | 2001-07-12 | Wingyu Leung | Single-Port multi-bank memory system having read and write buffers and method of operating same |
CN107506139A (en) * | 2017-08-14 | 2017-12-22 | 上海交通大学 | A kind of write request towards phase transition storage optimizes device |
US20190042458A1 (en) * | 2018-06-25 | 2019-02-07 | Intel Corporation | Dynamic cache partitioning in a persistent memory module |
CN109800193A (en) * | 2019-01-14 | 2019-05-24 | 浙江大学 | A kind of bridge-set of ahb bus access on piece SRAM |
CN112100097A (en) * | 2020-11-17 | 2020-12-18 | 杭州长川科技股份有限公司 | Multi-test channel priority adaptive arbitration method and memory access controller |
-
2022
- 2022-07-06 CN CN202210789662.6A patent/CN115050405A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20010007538A1 (en) * | 1998-10-01 | 2001-07-12 | Wingyu Leung | Single-Port multi-bank memory system having read and write buffers and method of operating same |
CN107506139A (en) * | 2017-08-14 | 2017-12-22 | 上海交通大学 | A kind of write request towards phase transition storage optimizes device |
US20190042458A1 (en) * | 2018-06-25 | 2019-02-07 | Intel Corporation | Dynamic cache partitioning in a persistent memory module |
CN109800193A (en) * | 2019-01-14 | 2019-05-24 | 浙江大学 | A kind of bridge-set of ahb bus access on piece SRAM |
CN112100097A (en) * | 2020-11-17 | 2020-12-18 | 杭州长川科技股份有限公司 | Multi-test channel priority adaptive arbitration method and memory access controller |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117149671A (en) * | 2023-08-30 | 2023-12-01 | 上海合芯数字科技有限公司 | Cache realization method, system, medium and electronic equipment |
CN117149671B (en) * | 2023-08-30 | 2024-05-24 | 上海合芯数字科技有限公司 | Cache realization method, system, medium and electronic equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US6279063B1 (en) | Microcomputer system with at least first and second microcomputers each operable in master and slave modes with configurable bus access control terminals and bus use priority controller | |
CN109154918B (en) | Self-refresh state machine MOP array | |
CN102640226B (en) | There is the storer of internal processor and the method for control store access | |
US5289584A (en) | Memory system with FIFO data input | |
TWI454909B (en) | Memory device, method and system to reduce the power consumption of a memory device | |
JP7508470B2 (en) | Extended data clock operation in memory - Patents.com | |
CN105095254B (en) | A method and device for realizing data consistency | |
CN107391400A (en) | A kind of memory expanding method and system for supporting complicated access instruction | |
CN114902198A (en) | Signaling for heterogeneous memory systems | |
WO2020106482A1 (en) | Programming and controlling compute units in an integrated circuit | |
TW201303870A (en) | Effective utilization of flash interface | |
CN109426623A (en) | A kind of method and device reading data | |
US8015329B2 (en) | Data transfer coherency device and methods thereof | |
CN115050405A (en) | Read-write control circuit, control method, chip and electronic equipment | |
US6754779B1 (en) | SDRAM read prefetch from multiple master devices | |
CN104064213A (en) | Memory access method, memory access control method and memory controller | |
US6735683B2 (en) | Single-chip microcomputer with hierarchical internal bus structure having data and address signal lines coupling CPU with other processing elements | |
CN117312210B (en) | Method for expanding performance of RISC-V processor | |
CN111158753A (en) | Flash controller structure with data prefetching function and implementation method thereof | |
CN101425044A (en) | Write-through cache oriented SDRAM read-write method | |
CN111381881A (en) | AHB (advanced high-performance bus) interface-based low-power-consumption instruction caching method and device | |
CN107807888B (en) | Data prefetching system and method for SOC architecture | |
JP2007087416A (en) | Single-chip data processor | |
CN109558076A (en) | A kind of configurable virtual SPI-FLASH | |
JP2002366509A (en) | Direct memory access controller and its access control method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |