A method of using a cache device for data accesses, wherein the cache device electrically coupled to a primary memory through a bus includes a data memory, a tag memory and a prefetch queue comparing circuit which includes a cache hit/miss judging circuit, an address queue register and a prefetch condition judging circuit, comprising the following steps:
- (a) judging whether a currently-read address coming from the bus is of cache hit or cache miss by the cache hit/miss judging circuit, wherein the address consists of an index address and a tag address;
- (b) directly storing the index address of the currently-read address plus a corresponding first one-bit flag signal output from the cache hit/miss judging circuit in the address queue register if the cache hit/miss judging circuit judges that the currently-read address is of cache hit, wherein the address queue register always continuously outputs index addresses already stored therein in first in-first out order to the data memory for data accesses;
- (c) judging whether the index address of the currently-read address is the same as any index addresses already stored in the address queue register by the prefetch condition judging circuit if the cache hit/miss judging circuit judges that the currently-read address is of cache miss;
- (d) replacing an original tag address stored at the same index address in the tag memory with the tag address of the currently-read address when the index address is not the same as any index addresses still stored in the address queue register;
- (e) storing the index address plus a corresponding second one-bit flag signal output from the cache hit/miss judging circuit in the address queue register after step (d);
- (f) replacing original data stored at the same index address in the data memory with required data stored at the same currently-read address in the primary memory after step (e);
- and
- (g) changing the second one-bit flag signal into the first one-bit flag signal after step (f).