Rabu, 27 Juni 2018

Sponsored Links

Generate gray code disk - File Exchange - MATLAB Central
src: www.mathworks.com

reflects binary code ( RBC ), also known simply as reflecting binary ( RB ) or ash code after Frank Gray, is ordering a binary number system such that two consecutive values ​​differ only in one bit (binary digits). The reflected binary code was originally designed to prevent false output from electromechanical switches. Currently, Gray code is widely used to facilitate error correction in digital communications such as digital terrestrial television and some cable TV systems.


Video Gray code



Name

Bell Labs researcher Frank Gray introduced the term that reflects binary code in his patent application in 1947, commenting that the code "does not have a recognized name". He takes the name from the fact that it's "probably built from conventional binary code by some kind of reflection process".

The code was later named Gray by others who used it. Two different patent applications in 1953 used "Gray code" as an alternative name for "reflected binary code"; one of them also lists the "minimum error code" and "cyclic permutation code" between the names. The patent application of 1954 refers to the "Gray Bell Telephone Code". Other names include "cyclic binary code" and "cyclic development code".

Maps Gray code



Motivation

Many devices show position by closing and opening button. If the device uses natural binary codes, positions 3 and 4 are next to each other, but the three bits of the binary representation are different:

The problem with natural binary code is that physical switches are not ideal: it is very unlikely that the physical switch will change the state exactly in sync. In the transition between the two states shown above, the three switches change status. In a brief period while all changed, the switch will read some false positions. Even without a keybounce, the transition may look like 011 - 001 - 101 - 100. When the switch looks at 001, the observer can not tell whether it is a "real" 001 position, or a transition state between two other positions. If output goes into a sequential system, perhaps through combinational logic, the sequential system can store the wrong value.

The reflected binary code solves this problem by changing only one button at a time, so there is never ambiguity of position:

Gray Code for decimal 15 rolls to decimal 0 with only one switch changed. This is called the "cyclic" property of the Gray code. In the Gray coding standard, the most significant bits follow the repeating pattern 2 on, 2 off (... 11001100...); next digit a pattern 4 on, 4 off; Etc.

Formally, the Gray code is the code that assigns to each set of adjacent integers, or to each member of the circular list, the word symbol so that no two identical code words and each two adjacent code words differ with exactly one symbol. This code is also known as one spacing code , which reflects the distance of Hamming 1 between adjacent code. In principle, there can be more than one such code for the given word length, but Gray code terms are first applied to a specific binary code for non-negative integers, binary-reflected gray code , or BRGC , the four-bit version shown above.

Digital Logic: Binary to Gray Code Converter | Quickgrid
src: quickgrid.files.wordpress.com


History and practical applications

The reflected binary codes are applied to mathematical puzzles before they are known by engineers. Martin Gardner wrote the popular account of the Gray code in the Mathematical Mathematics column of August 1972 in Scientific American. French engineer ÃÆ' â € ° mile Baudot used the Gray code in telegraphy in 1878. He received a Medal of Honor France for his work. Gray code is sometimes linked, wrongly, to Elisha Gray.

Frank Gray, who became famous for discovering the signaling method used for compatible color television, invented a method for converting analog signals into binary code groups that were reflected using vacuum tube-based equipment. The method and apparatus was patented in 1953 and the name Gray was attached to the code. Gray's patented "PCM tube" equipment was made by Raymond W. Sears of Bell Labs, working with Gray and William M. Goodall, who praised Gray for the idea of ​​binary code reflected.

Gray is most interested in using code to minimize errors in converting analog to digital signals; the code is still used today for this purpose.

Position encoder

Gray code is used in position coding (linear encoder and swivel encoder), in preference for direct binary encoding. This avoids the possibility that, when multiple bits change in a binary representation of an angle, misreading will result from some bits being changed before the other. Initially, the code pattern is electrically conductive, supported (in rotary encoder) by the isolation disk. Each track has its own stationary spring contact; one more contact makes a connection to the pattern. The common contacts are linked by patterns to any of the path contacts that are based on a conductive pattern. However, shift contacts wear out and need care, so non-contact detectors, such as optical or magnetic sensors, are often used instead.

Regardless of the care in aligning the contacts, and the accuracy of the pattern, the naturally-binary code will have errors in certain disk positions, since it is not possible to make all bits change at exactly the same time as the disk is spinning. The same applies to optical encoders; transitions between opaque and transparent can not be performed simultaneously for certain definite positions. The Rotary Encoders benefit from the cyclic nature of the Gray code, since successive positions of different sequences are only one bit. This means that, for transition from state A to state B, time mismatch can only affect when A - -> B transitions occur, rather than entering one or more (up to N Ã, -Ã, 1 for < i> N -bit codeword) false intermediate status, as would happen if standard binary code is used.

Math puzzle

The binary-reflected gray code can serve as a solution guide to the Hanoi Tower problem, as well as the Chinese classical ring puzzles, sequential mechanical puzzle mechanisms. It also forms the Hamiltonian cycle on the hypercube, where each bit is seen as a single dimension.

Genetic algorithm

Due to the nature of Hamming distance from Gray code, they are sometimes used in genetic algorithms. They are very useful in this field, because mutations in the code allow for most of the gradual changes, but sometimes single bit changes can lead to big jumps and lead to new properties.

Minimize boolean circuits

The gray code is also used in the Karnaugh map axis map as well as in the HÃÆ'¤ndler circle graph, both graphical methods to minimize the logic sequence.

Error correction

In modern digital communication, Gray code plays an important role in error correction. For example, in a digital modulation scheme such as QAM where data is usually transmitted in 4 bit or more symbols, the signal constellation diagram is arranged so that the bit pattern conveyed by adjacent constellation points differs by only one bit. By combining this with forward error correction capable of correcting single-bit errors, it is possible for the receiver to correct transmission errors that cause the constellation point to deviate to adjacent point areas. This makes the transmission system less susceptible to noise.

Communication between clock domains

Digital logic designers use the Gray code extensively to pass on multi-bit count information between synchronous logic operating at different clock frequencies. Logic is considered to operate in a different "clock domain". This is the basis for large chip designs that operate with many different clocking frequencies.

Biking through states with little effort

If a system must rotate all possible combinations of on-off states from multiple control sets, and control changes require less trivial costs (eg time, wear, human work), the gray code minimizes the number of change settings for only one change for each combination country. An example would be to test the piping system for all combinations of manually operated valve settings.

Gray and arithmetic code counters

The typical use of Gray code counters is to build FIFO (first-in, first-out) data buffers that have read and write ports that are in different clock domains. The input and output counter inside a dual-port FIFO is often stored using Gray code to prevent invalid transient status from being captured when the count passes over the clock domain. Updated read and write references must be passed between clock domains as they change, in order to track empty FIFO and full status in each domain. Each bit pointer is taken non-deterministically for this clock domain transfer. So for every bit, either the old value or the new value are reproduced. Therefore, if more than one bit in the multi-bit pointer changes at the sampling point, the "wrong" binary value (both new and old) can be reproduced. By guaranteeing only one bit is subject to change, Gray code guarantees that the only possible sample values ​​are new or old multi-bit values. Usually Gray code with a power of two lengths is used.

Sometimes a digital bus in an electronic system is used to convey an amount that can only increase or decrease one by one, such as the output of an event counter passed between the clock domain or the digital-to-analog converter. The advantage of Gray code in this application is that the difference in the propagation delay of many wires representing the code bits can not cause the received value to pass the exit status of the Gray code sequence. This is similar to Gray's code gain in the construction of a mechanical encoder, but Gray's code source is an electronic counter in this case. The counter itself should count in Gray code, or if the counter runs in binary then the output value of the counter must be re-locked after being converted to Gray code, because when the value is converted from binary to Gray code, it is possible that the binary data arrival time difference of binary bits into the circuit a binary-to-Gray conversion would mean that the code can go briefly through a status that is wildly out of sequence. Adding a list of clocks after a circuit that converts a count value into a code Gray can introduce a clock cycle of latency, so direct calculations in the Gray code may be beneficial. The Gray code counters are patented in 1962 US3020481 , and there have been many others since then. In some times Gray code counters can be implemented as state machines in verilog. To generate the next count value, it is necessary to have some combinational logic that will raise the current count value stored in the Gray code. Probably the clearest way to raise the Gray code number is to convert it into a regular binary code, add one to it with a standard binary exchanger, and then convert the result back to Gray code. This approach was discussed in a paper in 1996 and later patented by others in 1998 US5754614 . Other counting methods in the Gray code are discussed in the report by Robert W. Doran, including taking the output of the first hook of the master-slave flip-flops on the binary ripple counter.

Probably the most common electronic counter with "only one bit change at a time" property is a Johnson counter.

The addressed gray code

Because program code execution usually causes the instruction memory access pattern from locally consecutive addresses, encoding the bus using Gray code addressing instead of binary addressing can reduce the number of address bit status changes significantly, thus reducing CPU power consumption in some low power designs.

GRAY CODE(हिन्दी )!LEARN AND GROW - YouTube
src: i.ytimg.com


Generate code n -bit Gray

The binary-binary-polarized code list for n bits can be recursively generated from the list for n Ã,-1 bits by reflecting the list (ie the list of entries in reverse order), the prefix entry in the original list with binary 0, the entry prefix in the list reflected with binary 1, and then merge the original list with the reverse list. For example, create a list of n Ã, = 3 3 from the list n Ã, = Ã, 2:

The one-bit gray code is G 1 Ã, = Ã, (0, Ã, 1). This can be regarded as constructed recursively as above from the zero-bit Gray code G 0 Ã, = Ã, (Ã,? Ã,) consisting of one zero entry long. This iterative process produces G n 1 of G n makes the following properties of the code reflect a clear standard:

  • G n is a permutation of numbers 0,..., 2 n -1. (Each number appears exactly once in the list.)
  • G n pinned as the first half G n 1 .
  • Therefore, the encoding is stable , in the sense that once the binary number appears in G n it appears in the same position on all longer lists; so it makes sense to talk about the reflective Gray code value of a number: G ( m ) = m - reflects Gray code, counting from 0.
  • Each entry in G n differs only one bit from the previous entry. (Hamming Distance is 1.)
  • The last entry in G n differs only one bit from the first entry. (The code is cyclic.)

This characteristic suggests a simple and quick method of translating binary values ​​into appropriate gray codes. Each bit is reversed if the bit is higher than the input value set to one. This can be done in parallel by bit-shift and exclusive operations-or if they are available: the gray code n is obtained by counting                    n         ?         ?         n         /                 2         ?           {\ displaystyle n \ oplus \ lfloor n/2 \ rfloor}  Â

Untuk membuat kode Gray yang dipantulkan-biner secara iteratif, pada langkah 0 mulai dengan                                                 c              o              d              e                                    0                              =          0                  {\ displaystyle \ mathrm {code} _ {0} = 0}    , dan pada langkah                         saya          & gt;          0                  {\ displaystyle i & gt; 0}    menemukan posisi bit yang paling tidak signifikan 1 dalam representasi biner                         saya                  {\ displaystyle i}    dan membalikkan bit pada posisi itu di kode sebelumnya                                                 c              o              d              e                                    saya              -              1                                      {\ displaystyle \ mathrm {code} _ {i-1}}    untuk mendapatkan kode berikutnya                                                 c              o              d              e                                    saya                                      {\ displaystyle \ mathrm {code} _ {i}}    . Posisi bit mulai 0, 1, 0, 2, 0, 1, 0, 3,... (urutan A007814 dalam OEIS). Lihat temukan set pertama untuk algoritma yang efisien untuk menghitung nilai-nilai ini.

Lecture 3 Topics IEEE 754 Floating Point Binary Codes - ppt download
src: slideplayer.com


Mengonversi ke dan dari kode Gray

The following functions in C convert between binary numbers and associated Gray code. While it may seem that Gray-to-binary conversions require each bit to be handled one by one, faster algorithms exist.

Binary To Gray Code Conversion Method - YouTube
src: i.ytimg.com


A special type of Gray code

In practice, "gray code" almost always refers to binary-binary gray code (BRGC). However, mathematicians have found other types of gray code. Like BRGCs, each consists of a word list, where each word differs from the next in just one digit (each word has a Hamming 1 spacing from the next word).

n -Gray gray code

There are many special types of gray code in addition to the gray code reflected by the binary. One of the types of Gray code is n -Code grease , also known as the non-Boolean gray code . As the name implies, this type of Gray code uses non-Boolean values ​​in the encoding.

For example, a 3-ary gray (ternary) code would use value {0, 1, 2}. - Gray is n -gray Gray code with n i> k digits. The sequence of elements in the code (3, Ã, 2) -Gray is: {00, 01, 02, 12, 11, 10, 20, 21, 22}. ( n , å, k ) - The gray code can be created recursively, as BRGC, or iteratively constructs. The algorithm to generate repeat ( N , Ã, k ) - Gray code is presented (in C):

There is another Gray code algorithm for ( n , k ) - Code is gray. ( n , k ) - The gray code generated by the above algorithm is always cyclic; some algorithms, like that by Guan, do not have this property when k odd. On the other hand, while only one digit at a time changes with this method, it can change by wrapping (looping from n Ã,-1 to 0). In the Guan algorithm, the count turns up and down, so the numerical difference between the two digits of the Gray code is always one.

Gray code is not uniquely defined, because the permutation of such code columns is also Gray code. The above procedure generates code where the lower the digit significance, the more it changes, making it similar to the normal counting method.

See also the Skew binary number system, the ternary variant system in which at most 2 digits changes at each increment, since each increment can be performed by a single digit transport operation.

Gray Balance Code

Although binaries that reflect Gray's code are useful in many scenarios, it is not optimal in certain cases due to the lack of "uniformity". In a Balanced Gray code , the number of changes in different coordinate positions is as close as possible. To make this more accurate, let G be R -better full Gray cycle has a transition sequence            ()                   ?                      k                           )           {\ displaystyle (\ delta _ {k})}   ; transition count ( spectrum ) G is a set of integers determined by

                             ?                      k                           =                   |                 {         j         ?                              Z                                              R                               n                                                     :                   ?                      j                           =         k         }                   |                 ,                   for                 k         ?                              Z                                n                                 {\ displaystyle \ lambda _ {k} = | \ {j \ in \ mathbb {Z} _ {R ^ {n}}: \ delta _ {j} = k \} | \ ,, {\ text {for}} k \ in \ mathbb {Z} _ {n}}  Â

Kode Abu-abu seragam atau seragam seimbang jika jumlah transisinya sama, dalam hal ini kita memiliki                                   ?                         k                              =                     R                         n                                        /                   n                  {\ displaystyle \ lambda _ {k} = R ^ {n}/n}    untuk semua k . Jelas, ketika                         R          =          2                  {\ displaystyle R = 2}    , kode tersebut hanya ada jika n adalah kekuatan 2. Jika tidak, jika n tidak membagi                                    R                         n                                      {\ displaystyle R ^ {n}}    secara merata, adalah mungkin untuk membangun kode seimbang di mana setiap jumlah transisi adalah                        ?                     R                         n                                        /                   n         ?                  {\ displaystyle \ lfloor R ^ {n}/n \ rfloor}    atau                        ?                     R                         n                                        /                   n         ?                  {\ displaystyle \ lceil R ^ {n}/n \ rceil}    . Kode abu-abu juga dapat secara eksponensial seimbang jika semua jumlah transisi mereka bersebelahan dengan dua kekuatan, dan kode semacam itu ada untuk setiap kekuatan dua.

For example, a balanced 4-bit Gray code has 16 transitions, which can be equally distributed among the four positions (four transitions per position), making them well balanced:

 0  1  1 1 1 1 1  0  0 0 0 0 0  1  1  0   0 0  1  0 1  1  1 1 1  0  0 0 0  0 0 0 0  1  1 1 1 1  0  0  1  1 1  0  0   0  0 0  1  1  0  0 0 0 0  1  1 1 1 1 1  

while a balanced 5-bit Gray code has a total of 32 transitions, which can not be distributed evenly between positions. In this example, four positions have six transitions each, and one has eight:

  1  1 1 1 1  0  0 0 0  1  1 1 1 1 1  0  0  1  1 1 1 1  0  0 0 0 0 0 0 0 0 0  0 0 0  1  1 1 1 1 1 1 1  0  0 0 0 0 0 0  1  1 1 1 1 1  0  0 0  1  1  0  0 0  1 1  0  0  1  1 1  0  0 0 0 0 0  1  1 1  0  0 0  1  1 1 1 1 1  0  0 0 0 0  1  1  1  0  0 0 0 0 0 0  1  1 1 1 1 1  0  0 0 0 0 0  1  1 1 1 1 1 1 1  0  0 0  1   1 1 1 1 1 1  0  1  0  0 0 0 0 0 0 0 0  1   1  0  0 0  1  1 1 1 1 1  

Jika kita mendefinisikan multiplikasi transisi                                    m                         saya                              =                     |                   {          j         :                    ?                                        k                                 j                                                          =          saya         ,          1          <=          j          <=          L         }                     |                           {\ displaystyle m_ {i} = | \ {j: \ delta _ {k_ {j}} = i, 1 \ leq j \ leq L \} |}    menjadi berapa kali digit pada posisi i berubah di antara blok-blok yang berurutan dalam sebuah partisi, lalu untuk ( n   2) -digit Kode abu-abu yang diinduksi oleh partisi ini spektrum transisi                                   ?                         saya                      ?                           {\ displaystyle \ lambda '_ {i}}    adalah

                                  ?                         saya                      ?                   =                                  {                                                                 4                                        ?                                             saya                                                            -                    2                                         m                                             saya                                                           ,                                                                           jika                                       0                    <=                    saya                    & lt;                    n                                                                                    L                   ,                                                                           jika tidak                                                                                                                   {\ displaystyle \ lambda '_ {i} = {\ begin {cases} 4 \ lambda _ {i} -2m_ {i}, & amp; {\ text {if} } 0 \ leq i & lt; n \\ L, & amp; {\ text {otherwise}} \ end {cases}}}   

The tricky part of this construction is to find adequate partitioning of the balanced Gray-dated digits so that the code induced by it remains balanced, but for this it is only a transition multiplicity problem; join two consecutive blocks above the numbers                 me           {\ displaystyle i}   transition and separate other blocks in other digits                 me           {\ displaystyle i} transition produces a different Gray code with the same transition spectrum                        ?                         me                     ?                      {\ displaystyle \ lambda '_ {i}}   , so someone can choose the first                        m                         me                                {\ displaystyle m_ {i}} transition on digits                 me           {\ displaystyle i}   as that falls between two blocks. Uniform code can be found when               R         ?         0                             (           mod             Â 4          )                       {\ displaystyle R \ equiv 0 {\ pmod {4}}}   and                        R                 Â ·                           ?         0                             (           mod                     n          )                       {\ displaystyle R ^ {n} \ equiv 0 {\ pmod {n}}}   , and this construction can be extended to R - events as well.

Code of Monotonic Gray

Monotonic code is useful in network interconnection theory, especially to minimize widening for linear array of processors. If we define a weight binary string to be number 1 in the string, then even though we obviously can not have Gray code with strict weight gain, we might want to estimate this by having the code run through two adjacent weights before reach the next one.

Kami dapat meresmikan konsep kode monoton Abu-abu sebagai berikut: pertimbangkan partisi dari hypercube                                    Q                         n                              =          (                     V                         n                             ,                     E                         n                             )                  {\ displaystyle Q_ {n} = (V_ {n}, E_ {n})}    ke tingkat simpul yang memiliki bobot yang sama, yaitu

                                   V                         n                              (          saya         )          =          {          v         ?                     V                         n                             :          v                     memiliki bobot                   saya         }                  {\ displaystyle V_ {n} (i) = \ {v \ in V_ {n}: v {\ text {has weight}} i \}}   

Source of the article : Wikipedia

Comments
0 Comments