Background technology
Asynchronous first-in first-out, the data that refer to working storage write logic and read logic working at different clock zones with data.Read pointer points to the next address that is read, the address that the write pointers point next one is written into, and read pointer and write pointer constantly increase, and after pointer arrives address, working storage end, get back to start address again, recycle working storage.
In order to prevent reading of data from the working storage of sky, write pointer can be delivered to the clock zone of read pointer work, in the clock zone of read pointer work,, judged whether that data are readable according to residing position of current write pointer and the residing position of read pointer; In full working storage, write data in order to prevent equally, read pointer can be delivered to the clock zone of write pointer work, in the clock zone of write pointer work,, judge whether in working storage, to write data according to residing position of current read pointer and the residing position of write pointer.It is the clock zone that read pointer and write pointer are passed to the other side respectively, in each clock zone, determine the full state of sky of working storage according to the relation between read pointer and the write pointer, thus guarantee not can be from the working storage of sky reading of data, can in full working storage, not write data yet.
Referring to Fig. 1, Fig. 1 is the system construction drawing of asynchronous first-in first-out in the prior art.As shown in Figure 1, the read pointer of clock zone 2 (clock zone of read pointer work) is delivered in the clock zone 1 (clock zone of write pointer work), compare in the counting logic of clock zone 1 with the write pointer of clock zone 1, determine the current number that writes byte according to the relation of read pointer and write pointer; Equally, the write pointer of clock zone 1 also is delivered in the clock zone 2, compares in the counting logic of clock zone 2 with the read pointer of clock zone 2, determines the current number that can read byte according to the relation of read pointer and write pointer.
Wherein, in order to transmit read/write pointer accurately, the form that the scale-of-two read/write pointer can be converted to Gray code is transmitted, and after transmission, change back binary mode again, Gray code conversion module as shown in Figure 1 and Binary Conversion module are finished the function of Gray code conversion and Binary Conversion respectively.Because when adopting the Gray code transmission, pointer adds at 1 o'clock, Gray code has only a data bit to change, through after the data synchronization processing, the gray code pointer that obtains at the purpose clock zone only can be to add before one or add value after one, and no matter any result can not produce wrong read/write operation.But in the sort circuit, at every turn can only byte of read/write, because if each a plurality of bytes of read/write, be pointer add up greater than 1 several the time, then corresponding Gray code also has a plurality of data bit and changes, the Gray code that be transferred to the purpose territory this moment just might make a mistake, thereby may cause the read-write operation mistake.As: suppose that pointer becomes 1010 by 1000, then corresponding Gray code can become 1111 by 1100, there are two data bit that variation has taken place, when then Gray code transmits, because each data bit has situations such as delay and instability, the Gray code that is delivered to the purpose clock zone might be 1110,1101 and 1111, if transmission is 1101 and 1111, because 1101 and 1111 smaller or equal to 1111, therefore the read-write operation mistake can not take place; If what transmit is 1110, because 1110 greater than 1111, corresponding scale-of-two pointer is 1011, read pointer then may take place remove read data to 1011 places that write pointer does not write data, and perhaps write pointer goes write data to 1011 places that read pointer is not read away data.
In the practical application, in order to improve the speed of reading and writing data, the data of each byte of read/write are normally not enough.As for the data bus that in working storage, reads and writes data, because data-bus width of the prior art is generally the width greater than a byte, as be generally the width of 4 bytes, i.e. 32 bits, in fact then each bus operation can read and write the data of maximum 4 bytes, uses asynchronous fifo circuit of the prior art, can only read and write the data of a byte at every turn, thereby limited dirigibility and efficient that bus is used, reduced the speed of reading and writing data.
Summary of the invention
In view of this, one aspect of the present invention provides a kind of asynchronism first in first out method, and a kind of asynchronous first-in first-out system and dispensing device are provided on the other hand, can support that multibyte data reads while write, and improves the speed of reading and writing data.
Asynchronism first in first out method provided by the present invention comprises:
In the clock zone of source, according to the Gray code of scale-of-two read/write pointer conversion to be passed, determine to have only at most the Gray code current to be transmitted of a data bit generation conversion, determined current Gray code to be transmitted is delivered to the purpose clock zone;
In the purpose clock zone, be the scale-of-two read/write pointer with the Gray code conversion that is received, carry out write/read operation according to the scale-of-two read/write pointer of being changed.
Wherein, described Gray code according to conversion determines to have only the Gray code current to be transmitted of a data bit generation conversion to be at most:
The Gray code of conversion and the Gray code to be transmitted of last time are compared, have only a data bit not simultaneously, will wait that this different pieces of information position of transmitting Gray code carries out conversion last time, obtain Gray code current to be transmitted when the two;
And/or, when the two not only a data bit not simultaneously, one that will wait last time to transmit in the different pieces of information position of Gray code is carried out conversion, obtains Gray code current to be transmitted, wherein, the data bit of conversion can make current wait to transmit Gray code less than and the Gray code of approaching conversion;
And/or, when the two data bit is all identical, will wait to transmit Gray code last time as Gray code current to be transmitted.
Wherein, the Gray code of described scale-of-two read/write pointer conversion to be passed is: scale-of-two read/write pointer to be passed is directly carried out the Gray code that Gray code conversion obtains; Describedly for the scale-of-two read/write pointer be: the Gray code that is received is directly carried out Binary Conversion obtain the scale-of-two read/write pointer with the Gray code conversion that is received;
Perhaps, the Gray code of described scale-of-two read/write pointer conversion to be passed is: scale-of-two read/write pointer to be passed is divided into high-order and low level two parts, respectively high-order and low level are carried out Gray code conversion then, and the high position after will changing and low level are combined the Gray code that obtains; Describedly for the scale-of-two read/write pointer be: the Gray code that is received is divided into high-order and low level two parts with the Gray code conversion that is received, respectively high-order and low level are carried out Binary Conversion then, a high position and low level after the conversion are combined, obtained the scale-of-two read/write pointer.
Asynchronous first-in first-out provided by the present invention system comprises: source clock zone and purpose clock zone, wherein,
Described source clock zone is used for the Gray code according to scale-of-two read/write pointer conversion to be passed, determines to have only at most the Gray code current to be transmitted of a data bit generation conversion, and determined current Gray code to be transmitted is delivered to the purpose clock zone;
Described purpose clock zone is used to receive the Gray code from the source clock zone, and is the scale-of-two read/write pointer with the Gray code conversion that is received, and carries out write/read operation according to the scale-of-two read/write pointer of being changed.
Wherein, described source clock zone comprises: Gray code conversion module and Decision Control module, wherein,
The Gray code conversion module is used for scale-of-two read/write pointer to be passed is converted to Gray code, and the Gray code of being changed is exported to the Decision Control module;
The Decision Control module, be used to receive Gray code from the Gray code conversion module, according to the Gray code that is received, determine to have only at most the Gray code current to be transmitted of a data bit generation conversion, determined current Gray code to be transmitted is delivered to the purpose clock zone.
Wherein, described Decision Control module comprises: relatively controlling sub and Gray code send submodule, wherein,
Compare controlling sub, be used to receive Gray code from the Gray code conversion module, with the Gray code that received and exported to Gray code last time and transmit the Gray code to be transmitted that submodule transmits and compare, when the two has only a data bit not simultaneously, to wait that this different pieces of information position of transmitting Gray code carries out conversion last time, obtain Gray code current to be transmitted, transmit submodule output to Gray code; And/or, not only a data bit is not simultaneously when the two, one that then will wait last time to transmit in the Gray code different pieces of information position is carried out conversion, obtain Gray code current to be transmitted, and make that this data bit of conversion obtains current wait to transmit Gray code less than and the most approaching Gray code that receives, transmit submodule output to Gray code; And/or, when the two data bit is all identical, will wait to transmit Gray code last time as Gray code current to be transmitted, transmit submodule output to Gray code;
Gray code transmits submodule, is used to receive the Gray code current to be transmitted from comparing controlling sub, and the Gray code current to be transmitted that is received is delivered to the purpose clock zone.
Wherein, described Gray code conversion module is further used for: scale-of-two read/write pointer to be passed is divided into high-order and low level two parts, respectively high-order and low level are carried out the operation of conversion Gray code then, and after the high-order Gray code after will changing and low level Gray code make up, carry out described operation of exporting to the Decision Control module;
Described purpose clock zone is further used for: the Gray code that is received is divided into high-order and low level two parts, respectively high-order and low level are carried out the operation of described Binary Conversion then, and the high position after will changing and low level make up, and obtains described scale-of-two read/write pointer.
Asynchronous first-in first-out dispensing device provided by the present invention comprises: Gray code conversion module and Decision Control module, wherein,
The Gray code conversion module is used for scale-of-two read/write pointer to be passed is converted to Gray code, and the Gray code of being changed is exported to the Decision Control module;
The Decision Control module is used to receive the Gray code from the Gray code conversion module, according to the Gray code that is received, determines to have only at most the Gray code current to be transmitted of a data bit generation conversion, and determined current Gray code to be transmitted is sent.
Wherein, described Decision Control module comprises: relatively controlling sub and Gray code transmit submodule, wherein,
Compare controlling sub, be used to receive Gray code from the Gray code conversion module, with the Gray code that received and exported to Gray code last time and transmit the Gray code to be transmitted that submodule transmits and compare, when the two has only a data bit not simultaneously, to wait that this different pieces of information position of transmitting Gray code carries out conversion last time, obtain Gray code current to be transmitted, transmit submodule output to Gray code; And/or, not only a data bit is not simultaneously when the two, one that then will wait last time to transmit in the Gray code different pieces of information position is carried out conversion, obtain Gray code current to be transmitted, and make that this data bit of conversion obtains current wait to transmit Gray code less than and the most approaching Gray code that receives, transmit submodule output to Gray code; And/or, when the two data bit is all identical, will wait to transmit Gray code last time as Gray code current to be transmitted, transmit submodule output to Gray code;
Gray code transmits submodule, is used to receive the Gray code current to be transmitted from comparing controlling sub, and the Gray code current to be transmitted that is received is sent.
From such scheme as can be seen, the present invention determines current operation of waiting to transmit Gray code by having increased after Gray code conversion, promptly in the clock zone of source, Gray code according to scale-of-two read/write pointer conversion to be passed, determine to have only at most the Gray code current to be transmitted of a data bit generation conversion, determined current Gray code to be transmitted is delivered to the purpose clock zone.Make when multidata reads while write, when the Gray code of front transfer has only a data bit to change at most, thereby guarantee the correctness of institute transport address, reach the purpose of supporting that multibyte data reads while write, improve the speed of reading and writing data, further improved dirigibility and efficient that bus is utilized.
Wherein, determine to have only the current method that transmits Gray code of waiting of a data bit generation conversion to be at most: the Gray code of conversion and the Gray code to be transmitted of last time are compared, if the two has only a data bit difference, transmit behind this different pieces of information position of Gray code conversion then will last time to be transmitted; If and/or the two not only data bit difference, in the Gray code conversion different pieces of information position then will last time to be transmitted one, make after this data bit of conversion Gray code less than and the Gray code of the most approaching conversion after transmit; If and/or the two is identical, then keep the Gray code of current transmission constant.Thereby make the Gray code transmit all the time smaller or equal to and approach the Gray code that pointer to be passed is changed most, avoided reading invalid data or write the fashionable mistake that is coated with the effect data.
Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer, below in conjunction with embodiment and accompanying drawing, the present invention is described in more detail.
For convenience, this paper is called the source clock zone with the transmission side of pointer respectively, and the take over party of pointer is called the purpose clock zone, the clock zone of the clock zone of write pointer work and read pointer work the other side's purpose clock zone each other then, and be we's source clock zone.
Basic thought of the present invention is: increase after the Gray code conversion in the clock zone of source and determine current operation of waiting to transmit Gray code, promptly in the clock zone of source, Gray code according to scale-of-two read/write pointer conversion to be passed, determine to have only at most the Gray code current to be transmitted of a data bit generation conversion, determined current Gray code to be transmitted is delivered to the purpose clock zone.
Wherein, determine to have only the current key that transmits Gray code of waiting of a data bit generation conversion to be at most: the pointer value that obtains at the purpose clock zone can not be the pointer value of current reality, but can not surpass the pointer value of current reality, otherwise just might read invalid data or write the fashionable mistake of imitating data that is coated with.
Referring to Fig. 2, Fig. 2 is an exemplary process diagram of using the asynchronism first in first out method of above-mentioned basic thought in the embodiment of the invention.This flow process comprises the steps:
Step 201 in the clock zone of source, according to the Gray code of scale-of-two read/write pointer conversion to be passed, determines to have only at most the Gray code current to be transmitted of a data bit generation conversion, and determined current Gray code to be transmitted is delivered to the purpose clock zone.
Before this step, need scale-of-two read/write pointer to be passed is converted to Gray code, and it is identical in operation and the prior art of conversion Gray code, be not sent to the purpose clock zone immediately after just being converted to Gray code, but determine to have only at most the Gray code current to be transmitted of a data bit generation conversion according to the Gray code of being changed.
Wherein, the current method of waiting to transmit Gray code of determining to have only at most a data bit generation conversion can for: with the Gray code changed and last time Gray code to be transmitted compare, if the two has only a data bit difference, to wait that then this different pieces of information position of transmitting Gray code carries out conversion last time, obtain Gray code current to be transmitted, the Gray code that is about to conversion is directly as Gray code current to be transmitted; If and/or the two not only data bit difference, one that then will wait last time to transmit in the Gray code different pieces of information position is carried out conversion, obtain Gray code current to be transmitted, wherein, the data bit of conversion can make obtain current wait to transmit Gray code less than and the most approaching Gray code of changing; If and/or the two data bit is all identical, then will wait to transmit Gray code last time as Gray code current to be transmitted.Thereby make the Gray code transmit all the time smaller or equal to and approach the Gray code that pointer to be passed is changed most.
Wherein, if the two has only a data bit not simultaneously, or the two data bit also can be transmitted according to prior art when all identical.
And above-mentioned comparison procedure can all be carried out once in each clock period.
With size is that the write pointer of 4 bits is an example, when only writing 1 byte at every turn, wherein along with the change of pointer, the Gray code of corresponding conversion and the relation of waiting to transmit Gray code as shown in Table 1:
Clock week |
Write byte |
Actual write pointer |
The Gray code of conversion |
Gray code to be transmitted |
Transmit write pointer |
Issue |
Number |
|
|
|
|
0 |
|
0000 |
0000 |
0000 |
0000 |
1 |
1 |
0001 |
0001 |
0001 |
0001 |
2 |
1 |
0010 |
0011 |
0011 |
0010 |
3 |
1 |
0011 |
0010 |
0010 |
0011 |
4 |
1 |
0100 |
0110 |
0110 |
0100 |
5 |
1 |
0101 |
0111 |
0111 |
0101 |
6 |
1 |
0110 |
0101 |
0101 |
0110 |
7 |
1 |
0111 |
0100 |
0100 |
0111 |
8 |
1 |
1000 |
1100 |
1100 |
1000 |
9 |
1 |
1001 |
1101 |
1101 |
1001 |
10 |
1 |
1010 |
1111 |
1111 |
1010 |
11 |
1 |
1011 |
1110 |
1110 |
1011 |
12 |
1 |
1100 |
1010 |
1010 |
1100 |
13 |
1 |
1101 |
1011 |
1011 |
1101 |
14 |
1 |
1110 |
1001 |
1001 |
1110 |
15 |
1 |
1111 |
1000 |
1000 |
1111 |
16 |
1 |
0000 |
0000 |
0000 |
0000 |
… |
… |
… |
… |
… |
… |
Table one
In the table, because only write a byte at every turn, so Gray code that the Gray code of n clock period internal conversion and last time are to be transmitted, promptly n-1 the interior Gray code of determining to be transmitted of clock period compared, has only a data bit difference, then this different pieces of information position of Gray code Direct Transform that this moment can be to be transmitted with last time can obtain Gray code current to be transmitted, the i.e. Gray code of determining in n clock period to be transmitted, and current to wait to transmit the Gray code that Gray code and write pointer to be passed change identical.And, from table one, as seen, under the situation that only writes a byte, determinedly in each clock period wait to transmit Gray code and to wait to transmit the Gray code that pointer changes identical.As seen, in this case, identical in the realization effect of present embodiment and the prior art.Wherein, n is the natural number greater than 0.
In the above-mentioned table one, all there to be byte to be written as the description that example is carried out in each clock period, in the practical application, there is not byte to write in possible certain clock period, do not have in the then above-mentioned table one in clock period that byte writes still can with the Gray code changed and last time Gray code to be transmitted compare, just this moment, the two was identical, so Gray code current to be transmitted is a Gray code to be transmitted last time, promptly two interior Gray codes that transmit of clock period remain unchanged, at this moment, realize effect also with prior art in identical.
As seen, when byte of read/write, the implementation of present embodiment can be compatible mutually with prior art.
Be that the write pointer of 4 bits is an example still with size, when the byte number that writes not fixedly the time at every turn, wherein along with the change of pointer, the Gray code of corresponding conversion and the relation of waiting to transmit Gray code as shown in Table 2:
Clock periodicity |
Write byte number |
Actual write pointer |
The Gray code of conversion |
Gray code to be transmitted |
Transmit write pointer |
0 |
|
0000 |
0000 |
0000 |
0000 |
1 |
1 |
0001 |
0001 |
0001 |
0001 |
2 |
2 |
0011 |
0010 |
0011 |
0010 |
3 |
0 |
0011 |
0010 |
0010 |
0011 |
4 |
0 |
0011 |
0010 |
0010 |
0011 |
5 |
3 |
0110 |
0101 |
0110 |
0100 |
6 |
1 |
0111 |
0100 |
0100 |
0111 |
7 |
4 |
1011 |
1110 |
1100 |
1000 |
8 |
2 |
1101 |
1011 |
1110 |
1011 |
9 |
1 |
1110 |
1001 |
1010 |
1100 |
10 |
0 |
1110 |
1001 |
1011 |
1101 |
11 |
1 |
1111 |
1000 |
1001 |
1110 |
12 |
1 |
0000 |
0000 |
1000 |
1111 |
13 |
2 |
0010 |
0011 |
0000 |
0000 |
14 |
1 |
0011 |
0010 |
0010 |
0011 |
15 |
4 |
0111 |
0100 |
0110 |
0100 |
16 |
4 |
1011 |
1110 |
1110 |
1011 |
… |
… |
… |
… |
… |
… |
Table two
In the table two, the byte number that each clock period writes is unfixing, sometimes byte of write-once, sometimes more than a byte, sometimes then do not write byte, but which kind of situation no matter, each clock period, interior determine current waited to transmit Gray code all smaller or equal to the Gray code of waiting to transmit the pointer conversion, and determined current to wait to transmit Gray code all be as much as possible near the Gray code of waiting to transmit the pointer conversion, the write pointer value that promptly arrives the purpose clock zone always smaller or equal to and as much as possible near actual write pointer value.
With the 7th clock period in the table two be example, 4 bytes have been write in this clock period, this moment, write pointer became 1011 by 0111, the Gray code of corresponding conversion is 1110, and last time Gray code to be transmitted, promptly the 6th the interior Gray code of determining to be transmitted of clock period is 0100, wherein, 1110 and 0100 have two data bit different, during then with data bit of 0100 conversion, can obtain 0110, or 1100 since 1100 less than and more approach 1110, therefore data bit of 0100 conversion is obtained 1100, as the Gray code to be transmitted in the 7th clock period, in like manner other situation too.
When writing 0 byte in certain clock period, the Gray code of this clock period internal conversion is constant, but still whether the Gray code that will relatively change is with to wait to transmit Gray code last time identical, with the 3rd clock period be example, wherein, the Gray code of conversion still is the Gray code of the 2nd clock period internal conversion, promptly 0010, and last time Gray code to be transmitted, promptly second interior Gray code of determining to be transmitted of clock period is 0011, wherein 0010 and 0011 differ a data bit, then can directly this data bit of 0011 conversion be obtained 0010 as the Gray code to be transmitted in this clock period, for the 4th clock period because the conversion Gray code and last time Gray code to be transmitted be 0010, therefore two interior Gray codes that transmit of clock period remain unchanged, and will wait to transmit Gray code last time as the Gray code current to be transmitted in this clock period.
Step 202 in the purpose clock zone, is the scale-of-two read/write pointer with the Gray code conversion that is received, and the read/write pointer changed and the Writing/Reading pointer in self clock zone compared, determine the full state of sky of working storage,, carry out write/read operation according to the full state of sky of working storage.
Operation in this step is identical with prior art, after promptly the purpose clock zone receives Gray code from the source clock zone, is the scale-of-two read/write pointer with the Gray code conversion that is received, and is example with the scale-of-two write pointer, then as the transmission write pointer in table one and the table two.Then the read/write pointer changed and the Writing/Reading pointer in self clock zone are compared, determine the full state of sky of working storage,, carry out write/read operation according to the full state of sky of working storage.
Referring to Fig. 3, Fig. 3 is the asynchronous first-in first-out system construction drawing based on method flow shown in Figure 2.As shown in Figure 3, this system has added the Decision Control module on the basis of asynchronous first-in first-out of the prior art shown in Figure 1 system.
Wherein, clock zone 1 and clock zone 2 be the other side's purpose clock zone each other, and is we's source clock zone.The source clock zone is used for the Gray code according to scale-of-two read/write pointer conversion to be passed, determines to have only at most the Gray code current to be transmitted of a data bit generation conversion, and determined current Gray code to be transmitted is delivered to the purpose clock zone; The purpose clock zone, be used to receive Gray code from the source clock zone, and be the scale-of-two read/write pointer with the Gray code conversion that is received, and the read/write pointer changed and the Writing/Reading pointer in self clock zone compared, determine the full state of sky of working storage, according to the full state of sky of working storage, carry out write/read operation.
Wherein, Decision Control module in the clock zone of source is used to receive the Gray code of the Gray code conversion module output in this clock zone, according to the Gray code that is received, determine to have only at most the Gray code current to be transmitted of a data bit generation conversion, send determined current Gray code to be transmitted to the purpose clock zone.
During specific implementation, for read operation, write pointer control module in the clock zone 1 is exported to the Gray code conversion module with the scale-of-two write pointer, the Gray code conversion module is converted to Gray code with the scale-of-two write pointer that is received and exports to the Decision Control module, the Decision Control module is according to the definite Gray code current to be transmitted that has only a data bit generation conversion at most of the Gray code that is received, with the determined current Gray code process sends clock zone 2 to synchronously the Binary Conversion module of waiting to transmit.
The Binary Conversion module of clock zone 2 is the scale-of-two write pointer with the Gray code conversion that is received, export to the counting logic in this clock zone, the interior read pointer control module of this clock zone this moment has also been exported to the scale-of-two read pointer this counting logic, the position relation of counting write pointer that logical foundation received and read pointer, determine the full state of sky of working storage, promptly determine the byte number that can read this moment,, carry out read operation according to the byte number that can read.
Equally, for write operation, read pointer control module in the clock zone 2 is exported to the Gray code conversion module with the scale-of-two read pointer, the Gray code conversion module is converted to Gray code with the scale-of-two read pointer that is received and exports to the Decision Control module, the Decision Control module is according to the definite Gray code current to be transmitted that has only a data bit generation conversion at most of the Gray code that is received, with the determined current Gray code process sends clock zone 1 to synchronously the Binary Conversion module of waiting to transmit.
The Binary Conversion module of clock zone 1 is the scale-of-two read pointer with the Gray code conversion that is received, export to the counting logic in this clock zone, the interior write pointer control module of this clock zone this moment has also been exported to the scale-of-two write pointer this counting logic, the position relation of counting read pointer that logical foundation received and write pointer, determine the full state of sky of working storage, promptly determine writeable byte number this moment,, carry out write operation according to writeable byte number.
Wherein, the Decision Control module determine to have only at most a data bit generation conversion according to the Gray code that is received current specific implementation when waiting to transmit Gray code can with the introduction in the step 201 of flow process shown in Figure 2.Be the Decision Control module with the Gray code that received and last time Gray code to be transmitted compare, if the two has only a data bit difference, behind this different pieces of information position of Gray code conversion then will last time to be transmitted, obtain Gray code current to be transmitted; If and/or the two not only data bit difference, then will wait to transmit in the Gray code conversion different pieces of information position last time, obtain Gray code current to be transmitted, and make after this data bit of conversion Gray code less than and the most approaching Gray code that receives; If the two is identical, then will wait to transmit Gray code last time as Gray code current to be transmitted.Thereby make the Gray code transmit all the time smaller or equal to and approach the Gray code that received most.
During specific implementation, the Decision Control module can specifically comprise: relatively controlling sub and Gray code transmit submodule.
Wherein, compare controlling sub, be used to receive Gray code from the Gray code conversion module, with the Gray code that received and exported to Gray code last time and transmit the Gray code to be transmitted that submodule transmits and compare, when the two has only a data bit not simultaneously, to wait that this different pieces of information position of transmitting Gray code carries out conversion last time, obtain Gray code current to be transmitted, transmit submodule output to Gray code; And/or, not only a data bit is not simultaneously when the two, one that then will wait last time to transmit in the Gray code different pieces of information position is carried out conversion, obtain Gray code current to be transmitted, and make that this data bit of conversion obtains current wait to transmit Gray code less than and the most approaching Gray code that receives, transmit submodule output to Gray code; And/or, when the two data bit is all identical, will wait to transmit Gray code last time as Gray code current to be transmitted, transmit submodule output to Gray code;
Gray code transmits submodule, is used to receive the Gray code current to be transmitted from comparing controlling sub, the Gray code current to be transmitted that is received is sent to the Binary Conversion module of purpose clock zone.
Wherein, method embodiment illustrated in fig. 2 and system embodiment illustrated in fig. 3 are increases the operation of waiting to transmit Gray code of determining to have only at most a data bit generation conversion according to the Gray code of conversion on the basis of existing technology, realize simple, and institute makes an amendment less, is the preferred embodiment among the present invention.
In addition, during specific implementation, in the clock zone of source, the Gray code of scale-of-two read/write pointer conversion to be passed, can also be: scale-of-two read/write pointer to be passed is divided into high-order and low level two parts, respectively high-order and low level are carried out Gray code conversion then, and the high position after will changing and low level are combined the Gray code that obtains; And in the purpose clock zone, with the Gray code conversion that received for the scale-of-two read/write pointer can also for: the Gray code that is received is divided into high-order and low level two parts, respectively high-order and low level are carried out Binary Conversion then, a high position and low level after the conversion are combined, obtained the scale-of-two read/write pointer.
As with read/write pointer low two as the byte offset address, with other high position as word address, because a word is 32 bits, i.e. so 4 bytes are the byte offset address of low two each word of bit representation of available pointer, and with the start address of other high each word of bit representation, so read/write pointer being divided into high-order and low level two parts, is the pointer of 4 bits for size, and high two is high-order, for size is the pointer of 5 bits, and the Senior Three position is high-order.Respectively a high position and the low level that is divided carried out Gray code conversion then, determine to have only at most the Gray code to be transmitted of a data bit generation conversion afterwards according to the Gray code after the conversion, wherein, determine to have only at most a data bit generation conversion wait transmit the method for Gray code with Fig. 2 and description embodiment illustrated in fig. 3.
Certainly, in system shown in Figure 3, the Gray code conversion module is further used for: the scale-of-two read/write pointer that is received is divided into high-order and low level two parts, respectively high-order and low level are carried out the operation of conversion Gray code then, and after the high-order Gray code after will changing and low level Gray code make up, carry out described operation of exporting to the Decision Control module; The Binary Conversion module is further used for: the Gray code that is received is divided into high-order and low level two parts, respectively high-order and low level are carried out the operation of Binary Conversion then, and the high position after will changing and low level make up, and obtains described scale-of-two read/write pointer.
Be that the write pointer of 4 bits is an example still with size, when only writing 1 byte at every turn, wherein along with the change of pointer, the Gray code of corresponding conversion and the relation of waiting to transmit Gray code as shown in Table 3:
Clock periodicity |
Write byte number |
Actual write pointer |
The Gray code (high position, low level) of conversion |
Gray code to be transmitted (high position, low level) |
Transmit write pointer |
0 |
|
0000 |
00,00 |
00,00 |
0000 |
1 |
1 |
0001 |
00,01 |
00,01 |
0001 |
2 |
1 |
0010 |
00,11 |
00,11 |
0010 |
3 |
1 |
0011 |
00,10 |
00,10 |
0011 |
4 |
1 |
0100 |
01,00 |
00,00 |
0000 |
5 |
1 |
0101 |
01,01 |
01,00 |
0100 |
6 |
1 |
0110 |
01,11 |
01,01 |
0101 |
7 |
1 |
0111 |
01,10 |
01,11 |
0110 |
8 |
1 |
1000 |
11,00 |
01,10 |
0111 |
9 |
1 |
1001 |
11,01 |
01,00 |
0100 |
10 |
1 |
1010 |
11,11 |
11,00 |
1000 |
11 |
1 |
1011 |
11,10 |
11,10 |
1011 |
12 |
1 |
1100 |
10,00 |
11,00 |
1000 |
13 |
1 |
1101 |
10,01 |
10,00 |
1100 |
14 |
1 |
1110 |
10,11 |
10,01 |
1101 |
15 |
1 |
1111 |
10,10 |
10,11 |
1110 |
16 |
1 |
0000 |
00,00 |
10,01 |
1101 |
17 |
1 |
0001 |
00,01 |
00,01 |
0001 |
… |
… |
… |
… |
… |
… |
Table three
In the table three, the Gray code of conversion is all operated according to high-order and low level respectively with Gray code to be transmitted.But the description in the step 201 of the principle of determining to wait to transmit Gray code according to the Gray code of conversion and method and flow process shown in Figure 2 is identical.
When only writing 2 bytes at every turn, wherein along with the change of pointer, the Gray code of corresponding conversion and the relation of waiting to transmit Gray code as shown in Table 4:
Clock periodicity |
Write byte number |
Actual write pointer |
The Gray code (high position, low level) of conversion |
Gray code to be transmitted (high position, low level) |
Transmit write pointer |
0 |
|
0000 |
00,00 |
00,00 |
0000 |
1 |
2 |
0010 |
00,11 |
00,01 |
0001 |
2 |
2 |
0100 |
01,00 |
00,00 |
0000 |
3 |
2 |
0110 |
01,11 |
01,00 |
0100 |
4 |
2 |
1000 |
11,00 |
11,00 |
1000 |
5 |
2 |
1010 |
11,11 |
11,01 |
1001 |
6 |
2 |
1100 |
10,00 |
11,00 |
1000 |
7 |
2 |
1110 |
10,11 |
10,00 |
1100 |
8 |
2 |
0000 |
00,00 |
00,00 |
0000 |
9 |
2 |
0010 |
00,11 |
00,01 |
0001 |
… |
… |
… |
… |
… |
… |
Table four
In like manner, the Gray code of conversion is also all operated according to high-order and low level respectively with Gray code to be transmitted in the table four.Wherein the principle of determining to wait to transmit Gray code according to the Gray code of conversion and method are also identical with the description in the step 201 of flow process shown in Figure 2.
The clock zone 1 in the above-mentioned system shown in Figure 3 or the formation of clock zone 2 can be used as dispensing device separately, and promptly this dispensing device comprises at least: Gray code conversion module and Decision Control module.
Wherein, the Gray code conversion module is used for scale-of-two read/write pointer to be passed is converted to Gray code, and the Gray code of being changed is exported to the Decision Control module.
The Decision Control module is used to receive the Gray code from the Gray code conversion module, according to the Gray code that is received, determines to have only at most the Gray code current to be transmitted of a data bit generation conversion, and determined current Gray code to be transmitted is sent.
Wherein, the Decision Control module can specifically comprise equally: relatively controlling sub and Gray code transmit submodule.
Wherein, compare controlling sub, be used to receive Gray code from the Gray code conversion module, with the Gray code that received and exported to Gray code last time and transmit the Gray code to be transmitted that submodule transmits and compare, when the two has only a data bit not simultaneously, to wait that this different pieces of information position of transmitting Gray code carries out conversion last time, obtain Gray code current to be transmitted, transmit submodule output to Gray code; And/or, not only a data bit is not simultaneously when the two, one that then will wait last time to transmit in the Gray code different pieces of information position is carried out conversion, obtain Gray code current to be transmitted, and make that this data bit of conversion obtains current wait to transmit Gray code less than and the most approaching Gray code that receives, transmit submodule output to Gray code; And/or, when the two data bit is all identical, will wait to transmit Gray code last time as Gray code current to be transmitted, transmit submodule output to Gray code.
Gray code transmits submodule, is used to receive the Gray code current to be transmitted from comparing controlling sub, and the Gray code current to be transmitted that is received is sent.
Above-described specific embodiment; purpose of the present invention, technical scheme and beneficial effect are further described; institute is understood that; the above only is specific embodiments of the invention; and be not intended to limit the scope of the invention; within the spirit and principles in the present invention all, any modification of being made, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.