Summary of the invention
The purpose of the embodiment of the invention is to provide a kind of access control method of external memory storage, is intended to solve prior art low problem of access efficiency when the processor access external memory storage.
The embodiment of the invention is achieved in that a kind of access control method of external memory storage, and described method comprises the steps:
From the data that read in advance, read all data in the data line corresponding with the described first director data reference address;
The described first director data reference address is added that default step value is as the second director data reference address;
From external memory storage, read all data in the data line that also buffer memory is corresponding with the described second director data reference address.
Further, when receiving the director data request of access, read from the data that read in advance before the step of all data in the corresponding data line of the first director data reference address that carries with described director data request of access, described method also comprises the steps:
Receive data access request, and judge whether described data access request is the director data request of access, when described data access request is not the instruction data access request, according to described data access request, directly to the external memory storage operation that conducts interviews.
Further, the described first director data reference address is being added that default step value is as the second director data reference address, read from external memory storage after the step of all data in the data line that also buffer memory is corresponding with the described second director data reference address, described method also comprises the steps:
Judge whether to receive non-director data request of access, whether the director data reference address that the director data request of access that perhaps receives is carried is the continuation address behind the described first director data reference address, whether the data that perhaps read have in advance reached default quantity, if finish to read;
If do not receive non-director data request of access, the director data reference address that the director data request of access that receives is carried is the continuation address behind the described first director data reference address, and the data that read in advance do not reach default quantity, then the described second director data reference address is added that default step value is as the 3rd director data reference address, all data in the data line corresponding with described the 3rd director data reference address are read in continuation from external memory storage, circulation is carried out, until receiving non-director data request of access, the director data reference address that the director data request of access that perhaps receives is carried is not the continuation address behind the described first director data reference address, and the data that perhaps read in advance reach default quantity.
Another purpose of the embodiment of the invention is to provide a kind of access control apparatus of external memory storage, and described access control apparatus comprises:
Bus interface is with condition handler, the prefetch data buffer memory that described bus interface is connected respectively, the external memory interface that is connected with described condition handler, prefetch data buffer memory, and the prefetch address buffer memory that is connected with described condition handler respectively;
The data access request that described condition handler receives according to described bus interface is controlled described external memory interface and is fetched data to described prefetch data buffer memory from external read.
Further, described access control apparatus also comprises:
Read buffer memory and write buffer memory with described bus interface is connected with external memory interface respectively; At this moment,
Described condition handler is controlled described external memory interface reading of data from external memory storage and perhaps the described data of writing in the buffer memory is write external memory storage to the described buffer memory of reading according to the data access request that described bus interface receives.
Further, described condition handler comprises:
The instruction judging unit is used to judge whether the data access request that described bus interface receives is the director data request of access;
The matching addresses unit is used in the result of described instruction judging unit when being, mate the address that prestores in first director data reference address that described director data request of access is carried and the described prefetch address buffer memory;
Access control unit, be used for according to described instruction judging unit, perhaps the judged result of matching addresses unit control described external memory interface from external memory storage reading of data to the described buffer memory of reading, perhaps from external memory storage in advance reading of data perhaps the described data of writing in the buffer memory are write external memory storage to described prefetch data buffer memory.
In embodiments of the present invention, by the access control apparatus of an external memory storage is set, director data is read buffer memory in advance, thereby when the cache-miss of processor, can from the access control apparatus of external memory storage, read in advance and read the corresponding instruction data in the buffer memory, thereby improve the work efficiency of processor.
Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer,, the present invention is further elaborated below in conjunction with drawings and Examples.Should be appreciated that specific embodiment described herein only in order to explanation the present invention, and be not used in qualification the present invention.
In embodiments of the present invention, when receiving the director data request of access, from the data that read in advance, read all data in the corresponding data line of the director data reference address that carries with this director data request of access, simultaneously this director data reference address is added that default step value is as the director data reference address, from external memory storage, read all data of the data line that also buffer memory is corresponding with this director data reference address in advance, thereby before processor uses director data, reading command data have in advance improved the work efficiency of processor.
Fig. 1 shows the realization flow of the external memory access control method that the embodiment of the invention provides, and details are as follows:
In step S101, receive and carry the data access request of data access address, and judge whether this data access request is the director data request of access, if, execution in step S102, otherwise, execution in step S106.
Because the required data of processor generally can be divided into two kinds, a kind of is the instruction data, and another kind is an operational data.Wherein director data is the instruction code of processor, and its correlativity generally is fixing continuity.Operational data is the operand of processor, and its correlativity is relevant with concrete computing application, and more complicated.Therefore, data access request can be instruction data access request or operational data request of access.Because the correlativity of operational data is relevant with concrete computing application, therefore, need read mechanism according to the data in advance of concrete computing Application Design correspondence, is difficult to design a kind of general data in advance and reads mechanism and read operational data in advance.And the correlativity of director data is fixing continuity, and therefore, the embodiment of the invention is primarily aimed at the mechanism that reads in advance that director data designs a kind of director data.So, when receiving data access request, need to judge whether this data access request is the director data request of access.
In embodiments of the present invention, can be by in data access request, adding marking signal, identifying this data access request by this marking signal still is the operational data request of access for the director data request of access.After receiving the data access request of carrying data access address, judge according to the marking signal in this data access request whether this data access request is the director data request of access.If this data access request is the director data request of access, then the data access address that carries of this data access request is the first director data reference address A, if this data access request is the operational data request of access, then the data access address that carries of this data access request is operational data reference address B.
In step S102, first director data reference address A that this director data request of access is carried and the address line that reads in advance mate item by item, if coupling is unsuccessful, and execution in step S103, if the match is successful, while execution in step S104 and step S105.
In step S103, from external memory storage, read all data in the data line corresponding with this first director data reference address A, and with the data transmission that reads to the high speed buffer memory, execution in step S105 again.
In step S104, from the data that read in advance, read with this pairing data line in first director data reference address A address that the match is successful in all data and transfer to high-speed cache, return step S101 again, continue to wait for the request of access that receives bus interface.
For guarantee from the data that read in advance, to read with this pairing data line in first director data reference address A address that the match is successful in all data be valid data, in another embodiment of the present invention, read with this pairing data line in first director data reference address A address that the match is successful in all data before, this method also comprises the steps:
Whether the significance bit of the data in judgement and this pairing data line in first director data reference address A address that the match is successful is effective, if, then read these data and with this data transmission to the high speed buffer memory, if not, then wait for read these data again after significance bit until these data is changed to effectively and with this data transmission to the high speed buffer memory, circulation is carried out, until with this pairing data line in first director data reference address A address that the match is successful in all data all read and finish.
In step S105, this first director data reference address A is added that default step value S is as the second director data reference address C, from external memory storage, read all data in the data line corresponding with this second director data reference address C, and buffer memory second director data reference address C and the data that read.Its detailed process is as described below:
A, this first director data reference address A is added default step value S as the second director data reference address C, and this second director data reference address of buffer memory C.Wherein the length of Yu She step value S is the size of the data line of the high-speed cache that uses of processor, and promptly the data volume that at every turn reads in advance is the data volume of the delegation of the high-speed cache that uses of processor.
B, from external memory storage, read all data and buffer memory in the data line corresponding with this second director data reference address C.
Because when reading the data line corresponding with the second director data reference address C, word for word read, therefore, when whenever reading data in the data line corresponding with the second director data reference address C, the active position that is about to this data correspondence is effective, in order to later on when reading these data, guarantee the validity of these data.
In another embodiment of the present invention, after all data in the data line that has read the second director data reference address C correspondence, if receive the non-director data request of access of bus interface transmission, perhaps receive the director data request of access, but the director data reference address that this director data request of access is carried is not the continuation address of the first director data reference address A back, perhaps the data that read from external memory storage of buffer memory have reached predetermined number, then stop to continue reading of data from external memory storage.If do not receive non-director data request of access, the director data reference address that the director data request of access that receives is carried is the continuation address behind the described first director data reference address A, and the data that read in advance do not reach default quantity, the second director data reference address C is added that default step value S is as the 3rd director data reference address D, all data in the data line corresponding with the 3rd director data reference address D are read in continuation from external memory storage, circulation is carried out, until receiving non-director data request of access, the director data reference address that the director data request of access that perhaps receives is carried is not the continuation address behind the first director data reference address A, the data that perhaps read have in advance reached default quantity, promptly stop reading of data in advance.
In step S106, the data access address that carries according to the data access request that receives to the external memory storage operation that conducts interviews, returns step S101 after one time data access operation is finished, and continues to wait for the request of access of reception bus interface.
In embodiments of the present invention, when the data access request that receives is the write data request of access, this write data request of access is carried the data and the data that need write in the external memory storage and is write the address, at this moment, the needs that this write data request of access the is carried data of carrying with this write data request of access that write that data in the external memory storage write to external memory storage write in the corresponding address of address.When the data access request from the data bus transmission is the read data request of access, this read data request of access is carried data read address, at this moment, from external memory storage, read the corresponding data of data read address of carrying, and transfer to bus interface with this read data request of access.
Fig. 2 shows the structure of the access control apparatus of the external memory storage that the embodiment of the invention provides, and for convenience of explanation, only shows the part relevant with the embodiment of the invention.
Bus interface 1 is connected with high-speed cache (scheming not shown), the condition handler 2 of processor respectively, the data access request of the high-speed cache of processor is transferred to condition handler 2, simultaneously this bus interface 1 respectively with prefetch data buffer memory 3, read buffer memory 5 and write buffer memory 6 to be connected, with the data in the prefetch data buffer memory 3 or read data transmission in the buffer memory 5 to the high-speed cache of processor, perhaps the data with the cache transfers of processor write in the buffer memory 6.
Condition handler 2 is connected with prefetch address buffer memory 4 and external memory interface 7 respectively.This condition handler 2 is according to data access request control external memory interface 7 access external memory of bus interface 1 transmission.Wherein data access request control external memory interface 7 access external memory according to bus interface 1 transmission specifically comprise: the data that condition handler 2 will be write in the buffer memory 6 according to the data access request control external memory interface 7 of bus interface 1 transmission write external memory storage, perhaps control external memory interface 7 from external memory storage reading of data to reading in the buffer memory 5, perhaps control external memory interface 7 from external memory storage in advance reading of data to prefetch data buffer memory 3.
Wherein prefetch data buffer memory 3 is kept in the director datas that read in advance from external memory storage.This prefetch data buffer memory 3 can have at least one data line, the data line of the high-speed cache that the size of data line and processor use big or small consistent.Each data in the data line are provided with a significance bit simultaneously, and whether data corresponding in this this data line of significance bit sign are effective.
The high address that prefetch address buffer memory 4 is stored corresponding to the director data in the prefetch data buffer memory 3, i.e. an address line in the corresponding prefetch address buffer memory 4 of each data line.
External memory interface 7 under the control of condition handler from external memory storage in advance reading of data to prefetch data buffer memory 3 or reading of data to reading in the buffer memory 5, perhaps the data with cache transfers write external memory storage.
Wherein condition handler 2 comprises instruction judging unit 21, matching addresses unit 22, access control unit 23.This instruction judging unit 21 judges whether this data access request is the director data request of access when receiving the data access request of bus interface 1 transmission.In embodiments of the present invention, can be by adding marking signal in the director data request of access, identifying this data access request by this marking signal still is the operational data request of access for the director data request of access.Instruction judging unit 21 can judge according to the marking signal in the data access request whether this data access request is the director data request of access.
If instruction judging unit 21 judges that the data access request of bus interface 1 transmission is the director data request of access, then this director data request of access is carried the first director data reference address A.When this data access request was the director data request of access, mated the address that prestores in first director data reference address A that matching addresses unit 22 carries this director data request of access and the prefetch address buffer memory 4.
Wherein access control unit 23 comprises the access control module 231 of looking ahead, directly reads control module 232 and direct access control module 233.
Wherein look ahead access control module 231 when instruction judging unit 21 judges that the data access request of bus interface 1 transmission is the director data request of access, from prefetch data buffer memory 3, read data in the corresponding data line in address in the prefetch address buffer memory 4 with first director data reference address A coupling to bus interface 1, the first director data reference address A that simultaneously this director data request of access is carried adds that default step value S is as the second director data reference address C, and with this second director data reference address C buffer memory to prefetch address buffer memory 4, control external memory interface 7 simultaneously and read data the data line corresponding in advance to prefetch data buffer memory 3 with this second director data reference address C from external memory storage.
In another embodiment of the present invention, the access control module 231 control external memory interfaces 7 of looking ahead read all data in the data line corresponding with this second director data reference address C in advance from external memory storage after, if receive non-director data request of access from bus interface 1, the director data reference address that the director data request of access that perhaps receives is carried is not the continuation address of the first director data reference address A back, perhaps the data line in the prefetch data buffer memory 3 is full, the access control module 231 control external memory interfaces 7 of then looking ahead stop reading of data in advance, otherwise, the access control module 231 of looking ahead adds default step value S as the 3rd director data reference address D with the second director data reference address C, and continuation control external memory interface 7 reads all data in the data line corresponding with the 3rd director data reference address D in advance and keeps in to prefetch data buffer memory 3 from external memory storage.
Directly read matching addresses that control module 232 prestores in the first director data reference address A and prefetch address buffer memory 4 in matching addresses unit 22 when unsuccessful, control external memory interface 7 directly reads the data in the data line corresponding with the first director data reference address A from external memory storage, and the data that read are temporary to reading in the buffer memory 5, will read data transmission in the buffer memory 5 to the high-speed cache of processor by data-interface 21.
Directly access control module 233 is when instruction judging unit 21 judges that the data access request of bus interface 1 transmission is not the instruction data access request, the data that control external memory interface 7 will be write in the buffer memory 6 according to data access request write external memory storage, perhaps reading of data will be read data transmission in the buffer memory 5 to the high-speed cache of processor by bus data interface 21 again to reading buffer memory 5 from external memory storage.
In embodiments of the present invention, the access control apparatus of external memory storage is when receiving the director data request of access, from the data that prestore, search earlier, the director data reference address that carries according to this director data request of access simultaneously adds default step-length, reading of data in advance from external memory storage, thereby increased the hit rate of high-speed cache, improved the work efficiency of processor.Simultaneously the embodiment of the invention externally is provided with in the access control apparatus of storer and reads buffer memory (comprising prefetch address buffer memory and prefetch data buffer memory) in advance, does not need to revise the high-speed cache of processor, and versatility is better.The embodiment of the invention is by being provided with significance bit for data, thereby do not read fully when finishing at a data line, significance bit that can first reading of data is an active data, do not redo after finishing thereby do not need processor to wait for that the full line data all read, improved the work efficiency of processor.The embodiment of the invention is after the read request of delegation's director data of finishing processor simultaneously, if do not receive other non-director data request of access, and prediction is correct, and the prefetch data buffer memory less than the time, continue to read the next line director data, thereby increased the amount of reading of the valid data of each access external memory, improved the access efficiency of external memory storage.
The above only is preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of being done within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.