Gray Code & One_hot encoding

Source: Internet
Author: User

Gray Code & One_hot encoding

1. Gray Code (grey code)

Explain

Gray code is a set of numbers, each using two to indicate that the hypothesis uses n-bits to denote each number, and either of the two numbers is different, such as the following 3-bit gray code:

000 001 011 010 110 111 101 100


By definition, the order of gray code is not unique, for example, the above columns are written back, but also a group of gray code:

100 101 111 110 010 011 001 000


Gray Code was presented by Frank Gray of the lab in the 1940 and was used to avoid mistakes when using the PCM (Pusle Code modulation) method to deliver the message, and acquired U.S. expertise on March 17, 1953.

Solution

Since Gray code has changed only one bit to the next, it is possible to observe the location of gray code from 1 to 0 or from 0 to 1, with a 4-bit gray code as follows:

0000 0001 0011 0010 0110 0111 0101 0100
1100 1101 1111 1110 1010 1011 1001 1000


When we observe the changes in the odd number, we find that it is the number of gray Code that will change to the right-hand side forever, if it is 1 then 0, if 0 is 1.

When we observe the change of the even number, we find that the changed bit is the left-hand side of the first 1, which is calculated from the right side.

The above two changes are fixed, regardless of the number of bits; so as long as the location of the sentence is the odd or even number, you can decide which bit to change the value, in order to write a convenient program, the array index 0 as the right side of the value, and in the printing results, is the index number of large start reverse printing.

With the 2-bit gray code as the flat-top, you can create a quad, you can find out from either vertex, around the four-shape circumference, the vertex is a group of gray code, so you can get four group of gray Code.

The same kind of 3-bit gray code as a flat-panel to see, can form a cube, if you can from any point out, will all the edges, and do not repeat the vertex, the vertex of the order of the group is a group of gray Code, and so on.

2. One-hot Encoding (single hot Code)

Single hot code refers to any given state, the state vector only 1 bits is 1, the rest of you are 0. The state machine of n states requires n triggers, which are independent of the number of States, and depend on the number of transitions in a particular state, fast. When state machine state increases, if the use of two encoding, then the speed will be significantly reduced, but if the use of single-hot code, although the use of trigger, but because of the simple state decoding, saving and simplifying the combinational logic circuit.

In one-hot coding, the encoding should is:

state:a |      B |     C | D

assignment:0001 |   0010 |   0100 | 1000

Increase the number of flip-flops you use, but have the advantage that needs less logic for the excitation equations.

Give another example, for example:

Decimal: 0 | 1 |         2 |         3 |       4 |       5 |        6 |       7 |       8 | 9
Single Hot code: 000000000 | 000000001 |  000000010 |  000000100 | 000001000 | 000010000 | 000100000 | 001000000 | 010000000 | 100000000

http://www.vlsibank.com/sessionspage.asp?titl_id=4867

Design artical:

Http://www.trilobyte.com/pdf/golson_pldcon93.pdf

The use of single-hot code can improve the speed and reliability of the circuit and improve the utilization of the device resources for FPGA devices with more registers and less gate logic.

Gray Code & One_hot encoding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.