This application claims priority to Taiwanese Application Serial Number 108141833, filed Nov. 18, 2019, which is herein incorporated by reference.
The present disclosure relates to a cache technology. More particularly, the present disclosure relates to a data write system and a data write method suitable for a cache memory.
In memory technology, the cache memory can work in coordination with a main memory. Compared to the main memory, the operation speed of the cache memory is faster. Accordingly, with the cache memory, the operation efficiency of the overall system is increased, in which the cache hit rate and the cache miss penalty are key factors to the operation efficiency of the overall system.
One embodiment of the present disclosure is related to a data write system. The data write system includes a main memory, a cache memory, and a core processing circuit. The main memory includes a restricted region and a non-restricted region. The cache memory is coupled to the main memory.
The cache memory includes multiple ways. The core processing circuit is coupled to the cache memory and includes a logic circuit. The logic circuit is configured to select one of the ways as a selected way according to an access address of the main memory, the restricted region, and mode setting information, to write data corresponding to the access address into the selected way.
One embodiment of the present disclosure is related to a data write method. The data write method includes the following steps: reading base address information and top address information by a logic circuit of a core processing circuit, to determine a restricted region and a non-restricted region of a main memory; and selecting one of multiple ways of a cache memory as a selected way according to an access address of the main memory, the restricted region, and mode setting information by the logic circuit, to write data corresponding to the access address into the selected way.
As shown in the above embodiments, the data write system and the data write method of the present disclosure can prevent data in the restricted region and data in the non-restricted region from interfering each other.
It is to be understood that both the foregoing general description and the following detailed description are by examples, and are intended to provide further explanation of the disclosure as claimed.
The disclosure can be more fully understood by reading the following detailed description of the embodiment, with reference made to the accompanying drawings as follows:
Reference is now made in detail to the present embodiments of the disclosure, examples of which are illustrated in the accompanying drawings. Wherever possible, the same reference numbers are used in the drawings and the description to refer to the same or like parts. The embodiments below are described in detail with the accompanying drawings, but the examples provided are not intended to limit the scope of the disclosure covered by the description. The structure and operation are not intended to limit the execution order. Any structure regrouped by elements, which has an equal effect, is covered by the scope of the present disclosure.
In the present disclosure, “connected” or “coupled” may be referred to “electrically connected” or “electrically coupled.” “Connected” or “coupled” may also be referred to operations or actions between two or more elements.
Reference is made to
The registers R1-R3 are coupled to the core processing circuit 120. The core processing circuit 120 is coupled to the cache memory 140 and the main memory 160. The cache memory 140 is coupled to the main memory 160. In some embodiments, the core processing circuit 120 includes a logic circuit (for example, a logic circuit 121 in
In some embodiments, for increasing the operation efficiency, data commonly used is stored in the cache memory 140, such that the core processing circuit 120 can reads the data from the cache memory 140 directly.
References are made to
As illustrated in
When the core processing circuit 120 receives a reading command to read data in an access address AA1, the core processing circuit 120 can read the cache memory 140 according to the access address AM .
As illustrated in
For example, if the index field INDEX indicates the third row, a comparator circuit 141 compares the tag information TAG2 in the third row with the tag field TAG1. If the tag information TAG2 in the way W2 and the tag field TAG1 are matched, it is referred as “cache hit.” In other words, data to be read exists in the cache memory 140. Accordingly, a selector circuit 142 outputs a corresponding bit of data DATA in the way W2 according to the offset field OFFSET to an output circuit 143. Then, the output circuit 143 outputs the corresponding bit of the data DATA in the way W2. In some embodiments, the comparator circuit 141 is implemented by a comparator, but the present disclosure is not limited thereto. In some embodiments, the selector circuit 142 is implemented by a multiplexer, but the present disclosure is not limited thereto.
If the tag information TAG2 in the third row and the tag field TAG1 are not matched, it is referred as “cache miss.” In other words, data to be read does not exist in the cache memory 140.
Selection information LL is configured to indicate a mechanism of how to choose a written address. In some embodiments, the mechanism is the Least Recently Used (LRU) algorithm, but the present disclosure is not limited thereto. In other words, in these embodiments, if “cache miss” occurs, the LRU algorithm is used to load the data to be read from the main memory 160 into the cache memory 140 by using the LRU algorithm. In addition, valid information VALID is configured to indicate whether the corresponding data is valid.
The register R1 is configured to store base address information BA. The register R2 is configured to store top address information TA. A restricted region of the main memory 160 is defined by the base address information BA and the top address information TA. Other portions of the main memory 160 are non-restricted regions. The register R3 is configured to store mode setting information MODE. The mode setting information MODE records whether each of the ways W0-W3 is a restricted way or a non-restricted way.
Reference is made to
Reference is made to
Reference is made to
References are made to
In operation S502, it is determined whether “cache hit” occurs. If yes, the operation method 500 goes to operation S528. If “cache hit” occurs, it indicates that the data to be read exists in the cache memory 140, so the data is read from the cache memory 140 directly. If “cache hit” does not occur, it indicates “cache miss” occurs. In other words, the data to be read does not exist in the cache memory 140. Then, the operation method 500 goes to operation S504.
In operation S504, the logic circuit 121 determines whether the access address AA2 belongs to the restricted region RR (defined by the base address information BA and the top address information TA) of the main memory 160. As illustrated in the step ST1 in
In operation S518, the logic circuit 121 determines whether at least one way is reserved for the restricted region RR. For example, if the mode setting information MODE records that the ways W0-W3 are restricted ways and the ways W4-W5 are non-restricted ways, it indicates that there is at least one way (restricted way) is reserved for the restricted region RR. Then, the operation method 500 goes to operation S520. If there is no way reserved for the restricted region RR (for example, the ways W0-W5 are the non-restricted ways), the operation method 500 goes to operation S526.
In operation S526, the core processing circuit 120 performs a reading process to the main memory 160. In other words, the core processing circuit 120 reads “the data to be read” from the main memory 160.
In operation S520, the logic circuit 121 determines whether there is valid data in each of the ways W0-W5. As illustrated in step ST1 in
In operation S524, the logic circuit 121 selects the restricted way W0 as the selected way. Then, the operation method 500 goes to operation S514, to write the data to be read from the main memory 160 into the selected way. In other words, the data corresponding to the access address AA2 (0x2000) is written into the way W0 of the cache memory 140, as illustrated in step ST2 in
Then, the operation method 500 goes to operation S516, to update the selection information LL in
There are similar operations in steps ST2-ST4, so they are not described herein again. In some embodiments, as illustrated in steps ST5-ST6 in
Back to operation S504. As illustrated in step ST6 in
In operation S506, the logic circuit 121 determines whether at least one way is reserved for the non-restricted region NRR. For example, if the mode setting information MODE records that the ways W0-W3 are the restricted ways, and that the ways W4-W5 are the non-restricted ways, it indicates that there is at least one way (non-restricted way) reserved for the non-restricted region NRR. Then, the operation method 500 goes to operation S508. If there is no way reserved for the non-restricted region NRR (for example, the ways W0-W5 are restricted ways), the operation method 500 goes to operation S526.
In operation S526, the core processing circuit 120 performs a reading process from the main memory 160. In other words, the core processing circuit 120 reads “the data to be read” from the main memory 160.
In operation S508, the logic circuit 121 determines whether there is valid data in each of the ways W0-W5. As illustrated in step ST6 in
In operation S524, the logic circuit 121 selects the non-restricted way W5 as the selected way. Then, the operation method 500 goes to operation S514, to write the data to be read from the main memory 160 into the selected way. In other words, the data corresponding to the access address AA2 (0x8000) is written into the non-restricted way W5 of the cache memory 140, as illustrated in step ST7 in
In some embodiments, if the access address AA2 belongs to the non-restricted region NRR of the main memory 160, and if there is no valid data in at least one of the ways W0-W3 (that is, the determination of operation S508 is “no”), the at least one way is selected as the selected way (operation S524). Even if the selected way is the restricted way, the data corresponding to the access address AA2 is still written into the restricted way (operation S514).
Then, the operation method 500 goes to operation S516 to update the selection information LL in the
Back to operation S508, if the logic circuit 121 determines that there is valid data in each of the ways W0-W5, the operation method 500 goes to operation S510. In operation S510, the logic circuit 121 selects one of the non-restricted ways W4-W5 as the selected way according to the selection information LL. As illustrated in step ST7 in
Then, the operation method 500 goes to operation S512. If the data has been modified, the modified data is required to be stored back to the main memory 160. Then, the operation method 500 goes to operation S514 to write data to be read from the main memory 160 into the selected way of the cache memory 140. In other words, the data corresponding to the access address AA2 (0x9000) is written into the non-restricted way W4 of the cache memory 140, as illustrated in step ST8 in
Then, the operation method 500 goes to operation S516 to update the selection information LL in the
Back to operation S520, if the logic circuit 121 determines that there is valid data in each of the ways W0-W5, the operation method 500 goes to operation S522. In operation S522, the logic circuit 121 selects one of the restricted ways W0-W3 as the selected way according to the selection information LL. As illustrated in step ST10 in
Then, the operation method 500 goes to operation S512. If the data has been modified, the modified data is required to be stored back to the main memory 160. Then, the operation method 500 goes to operation S514 to write the data to be read in the main memory 160 into the selected way. In other words, the data corresponding to the access address AA2 (0x7000) is written into the restricted way W0 of the cache memory 140, as illustrated in step ST11 in
Then, the operation method 500 goes to operation S516 to update the selection information LL in the
Based on the descriptions above, by setting the restricted ways and the non-restricted ways and with a specific written method, the data in the restricted region RR and the data in the non-restricted region NRR do not interfere to each other. For example, if a system is running a program A in the restricted region RR, it does not affect a program B in the non-restricted region NRR. Accordingly, the cache hit rate of the restricted region RR and the cache hit rate of the non-restricted region NRR can be maintained respectively.
In addition, by the operations above, the present disclosure does not lock data and does not perform an initialization process. Thus, the cache memory 140 is utilized more effectively. In addition, by utilizing the base address information BA and the top address information TA to define the restricted region RR, in some embodiments, the restricted region RR of the present disclosure is larger than the non-restricted region NRR.
Reference is made to
In operation S702, the logic circuit 121 of the core processing circuit 120 reads the base address information BA and the top address information TA, to determine the restricted region RR and the non- restricted region NRR of the main memory 160. The base address information BA is stored in the register R1. The top address information TA stored in the register R2. In some embodiments, the main memory 160 has multiple restricted regions RR.
In operation S704, the logic circuit 121 selects one of the ways W0-W5 in
As shown in the above embodiments, the data write system and the data write method of the present disclosure can prevent data in the restricted region and data in the non-restricted region from interfering each other.
Various functional components or blocks have been described herein. As will be appreciated by persons skilled in the art, in some embodiments, the functional blocks will preferably be implemented through circuits (either dedicated circuits, or general purpose circuits, which operate under the control of one or more processors and coded instructions), which will typically comprise transistors or other circuit elements that are configured in such a way as to control the operation of the circuity in accordance with the functions and operations described herein. As will be further appreciated, the specific structure or interconnections of the circuit elements will typically be determined by a compiler, such as a register transfer language (RTL) compiler. RTL compilers operate upon scripts that closely resemble assembly language code, to compile the script into a form that is used for the layout or fabrication of the ultimate circuitry. Indeed, RTL is well known for its role and use in the facilitation of the design process of electronic and digital systems.
Although the present disclosure has been described in considerable detail with reference to certain embodiments thereof, other embodiments are possible. Therefore, the spirit and scope of the appended claims should not be limited to the description of the embodiments contained herein.
It will be apparent to those skilled in the art that various modifications and variations can be made to the structure of the present disclosure without departing from the scope or spirit of the disclosure. In view of the foregoing, it is intended that the present disclosure cover modifications and variations of this disclosure provided they fall within the scope of the following claims.
Number | Date | Country | Kind |
---|---|---|---|
108141833 | Nov 2019 | TW | national |