Cache processing request for data stored in stack area by using useless information, operating method of cache, and electronic device comprising cache
A cache includes a data memory, a tag memory, and a cache controller. The data memory includes a stack area storing, in a stack structure, data used by an external processor in a plurality of cache lines. The tag memory stores a tag entry including useless information indicating whether data stored in a corresponding cache line has been popped. The cache controller is configured to, when a pop request for data stored in the stack area is received, change the useless information of a cache line storing the data subject to the pop request, to a useless state.
1 . A cache comprising:
a data memory including a stack area storing, in a stack structure, data used by an external processor in a plurality of cache lines;
a tag memory for storing a tag entry including useless information indicating whether data stored in a corresponding cache line has been popped; and
a cache controller configured to, when a pop request for data stored in the stack area is received, change the useless information of a cache line storing the data subject to the pop request, to a useless state,
wherein the cache controller is further configured to, when a push request for the cache line in which the useless information is in the useless state is received, change the useless information of the cache line to store the data subject to the push request, to a useful state.
2 . The cache of claim 1 , wherein the cache controller is further configured to, when a read request for the data stored in the stack area is received, set read data based on the useless information of the cache line storing the data subject to the read request.
3 . The cache of claim 2 , wherein the cache controller is further configured to:
when the useless information of the cache line storing the data subject to the read request is in the useless state, set the read data to dummy data different from the data subject to the read request; and
when the useless information of the cache line storing the data subject to the read request is in a useful state, set the read data to data stored in the cache line.
4 . The cache of claim 1 , wherein the tag entry further comprises:
valid information indicating whether the data stored in the corresponding cache line is valid; and
dirty information indicating whether the data stored in the corresponding cache line is different from data stored in an external main memory.
5 . The cache of claim 4 , wherein the cache controller is further configured to, when an evict operation or a flush operation is performed on the cache line in which the dirty information is in a dirty state and the useless information of the cache line subject to the evict operation or the flush operation is in the useless state, change the valid information of the cache line subject to the evict operation or the flush operation to an invalid state.
6 . The cache of claim 4 , wherein the cache controller is further configured to, when an evict operation or a flush operation is performed on the cache line in which the dirty information is in a dirty state and the useless state of the cache line subject to the evict operation or the flush operation is in a useful state, store, in the external main memory, data stored in the cache line subject to the evict operation or the flush operation and change the valid information to an invalid state.
7 . The cache of claim 4 , wherein the cache controller is further configured to, when a push request for the stack area is received, change the valid information of a cache line to store data subject to the push request, to a valid state, and change the dirty information of the cache line to store the data subject to the push request, to a dirty state.
8 . An operating method of a cache comprising a data memory including a stack area storing data in a stack structure, a tag memory, and a cache controller, the operating method comprising:
receiving, by the cache controller, a pop request from a processor;
changing, by the cache controller, useless information in the tag memory for a cache line of the stack area storing data subject to the pop request, to a useless state;
receiving, by the cache controller, a read request for the data stored in the stack area; and
setting, by the cache controller, read data based on useless information of a cache line storing the data subject to the read request,
wherein the useless information indicates whether data stored in a corresponding cache line has been popped.
9 . The operating method of claim 8 , further comprising:
receiving, by the cache controller, a push request for the cache line in which the useless information is in the useless state; and
changing, by the cache controller, the useless information of a cache line to store data subject to the push request, to a useful state.
10 . The operating method of claim 8 , wherein the setting of the read data comprises:
when the useless information of the cache line storing the data subject to the read request is in a useless state, setting, by the cache controller, the read data to dummy data different from the data subject to the read request; and
when the useless information of the cache line storing the data subject to the read request is in a useful state, setting, by the cache controller, the read data to data stored in the cache line.
11 . The operating method of claim 8 , wherein a tag entry of the tag memory comprises:
valid information indicating whether data stored in a cache line corresponding to a tag address is valid; and
dirty information indicating whether the data stored in the cache line corresponding to the tag address is different from data stored in a main memory.
12 . An electronic device comprising:
a main memory;
a cache; and
a processor,
wherein the cache includes:
a data memory including a stack area storing, in a stack structure, data used by the processor in a plurality of cache lines;
a tag memory for storing a tag entry including information about the data stored in the stack area; and
a cache controller configured to process a request for the data stored in the stack area based on the tag entry,
the tag entry includes useless information indicating whether data stored in a corresponding cache line has been popped,
the cache controller is further configured to, when a pop request for the data stored in the stack area is received, change the useless information of a cache line storing the data subject to the pop request, to a useless state,
wherein the tag entry further comprises:
valid information indicating whether the data stored in the corresponding cache line is valid; and
dirty information indicating whether the data stored in the corresponding cache line is different from data stored in the main memory, and
wherein the cache controller is further configured to, when an evict operation or a flush operation is performed on a cache line in which the dirty information is in a dirty state and the useless information of the cache line subject to the evict operation or the flush operation is in the useless state, change the valid information of the cache line subject to the evict operation or the flush operation, to an invalid state.
13 . The electronic device of claim 12 , wherein the cache controller is further configured to, when a push request for the cache line in which the useless information is in the useless state is received, change the useless information of the cache line to store data subject to the push request, to a useful state.
14 . The electronic device of claim 12 , wherein the cache controller is further configured to, when a read request for the data stored in the stack area is received, set read data based on the useless information of a cache line storing the data subject to the read request.
15 . The electronic device of claim 14 , wherein the cache controller is further configured to:
when the useless information of the cache line storing the data subject to the read request is in a useless state, set the read data to dummy data different from the data subject to the read request; and
when the useless information of the cache line storing the data subject to the read request is in a useful state, set the read data to data stored in the cache line.
16 . The electronic device of claim 12 , wherein the cache controller is further configured to, when an evict operation or a flush operation is performed on a cache line in which the dirty information is in a dirty state and the useless information of the cache line subject to the evict operation or the flush operation is in a useful state, store, in the main memory, data stored in the cache line subject to the evict operation or the flush operation, and change the valid information to an invalid state.