A kind of ping-pong buffers device
Technical field
The present invention relates to the metadata cache field, relate in particular to scattered, diversiform data reception, the metadata cache technology that classification quantitatively sends handled.
Background technology
Ping-pong buffer (PingPong Buffer) mechanism is a kind of relatively cache way of increase data bandwidth commonly used.Can be used in any one needs in the system that read operation and write operation carry out simultaneously, such as the data recombination buffer memory in switch and the route system, and the perhaps transmission of the batch data in the computer system.
Fig. 1 is the schematic diagram of common buffer memory.As shown in Figure 1, this is a common buffer memory (buffer), suppose its input (An) and export the processing (batch process) that (Dn) has data cell, in each data cell time (we are referred to as time slot), zero (An=0) or one (An=1) new data cell can be imported, and have zero (Dn=0) or (Dn=1) data cell output; This means that at each time slot two independently storage operation generations are arranged.If the employing dual-ported memory is that can to reach be two purposes that operation is carried out simultaneously; But dual-ported memory costs an arm and a leg, for consideration economically, generally all can adopt one-port memory, this bandwidth of memory (equal buffer memory input rate and output speed and) that just requires buffer memory must be the twice of linear speed (input or output) so.(OC (Optical Carrier, light carrier) is the transmission speed that defines in SONET (Synchronous Optical NETwork, the synchronous optical network) standard with OC-48.The transmission speed of OC definition light device, OC-48 linear speed 2.4Gbps) be example, the bandwidth of memory that it needs is 4.8Gbps, corresponds to 32 memory, the access time of memory is necessary for 6.4ns so, and this requirement to memory and system clock is very harsh.
Except adopting dual-ported memory, also have another mechanism to realize that read and write operates ping-pong buffer mechanism that Here it is simultaneously.Ping-pong buffer adopts two one-port memories, and at each time slot, every block storage only need be carried out a kind of operation (read or write).The general structure of ping-pong buffer as shown in Figure 2, the total capacity of supposing ping-pong buffer is M (unit is a memory cell), its input is handled and output is handled and represented with An and Dn respectively.Ping-pong buffer comprises two memory devices that physically separate, and the capacity of each is respectively M/2, and two memory interfaces are held together, and (from the angle of An and Dn) to buffer memory just from the outside, but operation capacity is M/2.
With respect to general one-port memory buffer memory, in ping-pong buffer, read operation and write operation can take place simultaneously, but alternating action is on different storage component parts respectively.Fig. 3 is the operation example figure of ping-pong buffer.As shown in Figure 3, when input (An) data cell arrived, if wherein a block cache (buffer1) is read, these data cells can be written on the other block cache (buffer2) so; Write completely when buffer memory 1, buffer memory 2 is read after the sky, and operation has just exchanged comes, and An writes in the buffer memory 2, and Dn is from buffer memory 1 total reading of data.From the angle of An or Dn, operation all hockets between two buffer memorys.Ping-pong buffer is a caching mechanism relatively more commonly used at present, and its basic principle is accepted extensively by industry.In the different system for reality, demand is diversified, and concrete control mode is Protean.
But traditional ping-pong buffer still exists some shortcomings in actual applications.For example: common ping-pong buffer can only one of them buffer memory (as buffer memory 1 or buffer memory 2) in ping-pong buffer be write full or is read and redirect just takes place in empty.When data in buffer is data of different types, the data type that system often requires to export also will be consistent respectively, if adopt traditional ping-pong buffer, just must be after distinguishing data type for the data of different types in the data flow, adopt many cover ping-pong buffers to come buffer memory data of different types respectively, this is relatively waste on resource, and can increase the scale and the complexity of whole system undoubtedly.
Summary of the invention
Purpose of the present invention proposes a kind of economic and reliable, is applicable to the ping-pong buffer device of buffer memory different types of data.
Core concept of the present invention is: according to dissimilar with the road data separation of input data, data of different types must make a distinction and leave in the inner different buffer memorys of ping-pong buffer (buffer memory 1 or buffer memory 2), if data type changes, even if buffer memory less than, redirect also will take place in ping-pong buffer, is the data of same type with what guarantee to deposit in each buffer memory (buffer memory 1 or buffer memory 2); For showing with road information is data of the same type, also can further classify to data according to the additional information of data, and different classes of data also leave in the inner different buffer entity of different ping-pong buffers.
Technical scheme of the present invention is:
A kind of ping-pong buffer device comprises:
Data additional information analysis module is used to analyze the data additional information of input, and analysis result is input to the additional information input selector, produces simultaneously to write completely normal redirect condition and the unusual redirect condition of additional information and output to and write redirect condition processing module;
The additional information input selector receives data additional information analysis module and the output result who writes the redirect processing module, selects the data additional information to enter the data additional information register of buffer memory 1 or the data additional information register of buffer memory 2;
The input data analysis module, be used to analyze the data of input and data with road information, the data of analyzing the back additivity are outputed to write the buffer memory selector, and produce the unusual redirect condition of data type and output to and write redirect condition processing module;
Write the buffer memory selector, receive the data of additivity of input data analysis module output and the output of writing the redirect processing module, select to put into data in the buffer memory 1 or in the buffer memory 2;
Write redirect condition processing module, be used to handle the various redirect conditions that receive, the selection result that produces is outputed to the additional information input selector and writes the buffer memory selector select;
The entity module of ping-pong buffer is used for buffer memory input data and input data additional information; Specifically comprise
A, buffer memory 1 and buffer memory 2, two buffer entities in the ping-pong buffer module are used for the data that buffer memory is write the output of buffer memory selector;
Data additional information register in data additional information register and the buffer memory 2 is used to deposit the data additional information that the additional information input selector is exported in B, the buffer memory 1;
The valid data of C, buffer memory 1 number register is gentle deposits a valid data number register of 2, is used to deposit the number of valid data in current cache 1 or the buffer memory 2;
The write pointer register of D, buffer memory 1 and the read pointer register of buffer memory 1 are used to deposit the write pointer and the read pointer of buffer memory 1;
The write pointer register of E, buffer memory 2 and the read pointer register of buffer memory 2 are used to deposit the write pointer and the read pointer of buffer memory 2;
The additional information outlet selector is used for selecting the data additional information of data additional information registers in output buffers 1 interior data additional information register or the buffer memory 2 according to reading the redirect condition;
Read the buffer memory selector, be used for selecting the data of output buffers 1 or buffer memory 2 according to reading the redirect condition.
Above-mentioned buffer memory 1 and buffer memory 2 are storage component parts of the symmetry of physically separating, can be made of single port RAM, also can be built by registers group.It is that the inner buffer degree of depth is a ping-pong buffer of 1 that buffer memory 1 interior data additional information register and buffer memory 2 interior data additional information registers group lump together.
Use the ping-pong buffer device of proposition of the present invention, only can realize can be to the buffer memory of classifying of different types of data in the data flow with a cover ping-pong buffer entity, the table tennis device that the present invention proposes, expanded the function of traditional ping-pong buffer, solved effectively and used traditional ping-pong buffer waste problem of resource, save circuit resource, improved the efficient of metadata cache in the system.
Description of drawings
Fig. 1 is the schematic diagram of common buffer memory;
Fig. 2 is the structural representation of traditional ping-pong buffer;
Fig. 3 is the operation example figure of ping-pong buffer;
Fig. 4 is the structural representation of the ping-pong buffer device that proposes of the present invention.
Embodiment
The present invention is described in further detail below in conjunction with drawings and Examples.
Fig. 1, Fig. 2 and Fig. 3 had carried out detailed description in background technology.
Fig. 4 is the structural representation of the ping-pong buffer device that proposes of the present invention.The main input of the ping-pong buffer device that the present invention relates to is: the additional information of input data and input data.As shown in Figure 4, the ping-pong buffer device of the present invention's proposition comprises:
Data additional information analysis module is used to analyze the data additional information of input, and analysis result is input to the additional information input selector, produces simultaneously to write completely normal redirect condition and the unusual redirect condition of additional information and output to and write redirect condition processing module.
The additional information input selector receives data additional information analysis module and the output result who writes the redirect processing module, selects the data additional information to enter the data additional information register of buffer memory 1 or the data additional information register of buffer memory 2.
The input data analysis module, be used to analyze the data of input and data with road information, the data of analyzing the back additivity are outputed to write the buffer memory selector, and produce the unusual redirect condition of data type and output to and write redirect condition processing module.This analysis module requires to contain data type information in the input data, if do not contain with road information in the input data, then device thinks that all data all are same types, and this has just guaranteed that ping-pong buffer device that the present invention proposes can be fully and traditional buffer unit function compatibility.
Write the buffer memory selector, receive the data of additivity of input data analysis module output and the output of writing the redirect processing module, select to put into data in the buffer memory 1 or in the buffer memory 2;
Write redirect condition processing module, be used to handle the various redirect conditions that receive, the selection result that produces is outputed to the additional information input selector and writes the buffer memory selector select;
The entity module of ping-pong buffer is used for buffer memory input data and input data additional information; Specifically comprise
A, buffer memory 1 and buffer memory 2, two buffer entities in the ping-pong buffer module are used for the data that buffer memory is write the output of buffer memory selector; A data cached high position has been added control informations in real time such as type.
Data additional information register in data additional information register and the buffer memory 2 is used to deposit the data additional information that the additional information input selector is exported in B, the buffer memory 1; Such as destination address etc.
The valid data of C, buffer memory 1 number register is gentle deposits a valid data number register of 2, is used to deposit the number of valid data in current cache 1 or the buffer memory 2;
The write pointer register of D, buffer memory 1 and the read pointer register of buffer memory 1 are used to deposit the write pointer and the read pointer of buffer memory 1;
The write pointer register of E, buffer memory 2 and the read pointer register of buffer memory 2 are used to deposit the write pointer and the read pointer of buffer memory 2;
The additional information outlet selector is used for selecting the data additional information of data additional information registers in output buffers 1 interior data additional information register or the buffer memory 2 according to reading the redirect condition;
Read the buffer memory selector, be used for selecting the data of output buffers 1 or buffer memory 2 according to reading the redirect condition.
Describe the operation principle of ping-pong buffer device proposed by the invention below in detail.At first explain " redirect ".So-called redirect is meant when ping-pong buffer operated (read or write) to jump to another one from a buffer memory that " normal redirect " takes place when referring to write full (for read operation) or reading sky (for read operation)." unusual redirect " just is meant the redirect of writing that triggers generation down in other condition (non-write full condition) so; Therefore: unusual redirect condition only can be created in the write port of ping-pong buffer, the redirect condition of the read port of ping-pong buffer is unique: certain buffer memory that is exactly ping-pong buffer " has been read sky ", and this had also comprised original not write full buffer memory and read sky because of unusual redirect certainly.
The additional information of input data is non-real-times, or by the control information that the final receiver of data is brought, can utilize these information that data are further classified.Data additional information analysis module is analyzed the additional information of data, also can produce unusual redirect condition, and the information after will analyzing exists in the additional information register of buffer memory correspondence at data place, reads use for follow-up processing unit.
It also is that the inner buffer degree of depth is a ping-pong buffer of 1 that buffer memory 1 interior data additional information register and buffer memory 2 interior data additional information registers group lump together.In buffer entity inside, buffer memory 1 and buffer memory 2 are the storage component parts that physically separate, and they are symmetrical, can be made of single port RAM, also can be built by registers group; Storage organization in the buffer memory is: the control of data+data and state information; Wherein control and state information are decided as required, can be need be delivered to the data of next stage processing unit with road information, and also can be the intermediate parameters that will use in this module.The degree of depth of buffer memory can be decided according to concrete needs, is generally 4,8 or 16; The width of buffer memory depends on the width of data width (generally being 32) and state of a control information.
At every turn to each buffer memory (buffer memory 1 or buffer memory 2) read or write operation all is that the original position of buffer memory begins, but because there is the situation of unusual redirect in ping-pong buffer, so might not write full by certain buffer memory, represent the write operation of current cache has been proceeded to which position (it is effective having represented to have in the current cache how many data) so need " write pointer register ", this register begins certain buffer memory is carried out resetting in the write operation at An, when carrying out write operation, bring in constant renewal in, in the time of write operation generation redirect, the value that the write pointer register keeps at that time is constant; When Dn carries out read operation to this buffer memory, can instruct read operation with reference to this write pointer register value, each buffer memory also has one " read pointer register " simultaneously, Dn whenever reads a number, just upgrade once " read pointer register ", update rule is consistent with renewal " write pointer register ", like this when the numerical value of " read pointer register " equals the numerical value of " write pointer register ", just expression is read empty, when reading sky, read pointer zero clearing, read operation jump on the another one buffer memory.