当前位置:网站首页>Verilog -- state machine coding method

Verilog -- state machine coding method

2022-07-05 08:00:00 Drink more hot water-

Contained in the state machine N States usually need to be represented by some coding , Status code , Or status assignment .

Choose the appropriate coding scheme , It will contribute to the utilization of circuit area and resources .

The three most common types of state coding are : Sequential binary encoding Gray code and Hot code alone 、 Johnson code

Sequence code (Sequential State Machine Encoding)

Binary coding is the most compact coding , Each state encoded with sequential binary numbers .

eg. state0 state1 state2 state3 Expressed as '00'  '01' '10' '11'

The advantage is that it uses the smallest number of bits of the state vector . But when it changes from one state to another , Many bits may change ,[ There are intermediate states ] Many transients , Easy to produce burr , Cause a logical error

Gray code (Gray Code )

In the transition of adjacent states , Only one bit at a time changes , It can reduce the possibility of burrs and some transients , But it is not suitable for situations with many state jumps .

Recursively generate code table

This method is based on the fact that gray code is reflection code , Use the following rules of recursion to construct :

  1. 1 Bit gray code has two codewords

  2. (n+1) The first bit of gray code 2n Codeword equals n Codeword of bit gray code , Write in order , Prefixed 0

  3. (n+1) After... In gray code 2n Codeword equals n Codeword of bit gray code , Write in reverse order , Prefixed 1 [4] 

  4. n+1 A collection of bit gray codes = n Bit gray code set ( The order ) Prefixed 0 + n Bit gray code set ( The reverse ) Prefixed 1

2 Bit code

3 Bit code

4 Bit code

4 Bit natural binary code

00

000

0000

0000

01

001

0001

0001

11

011

0011

0010

10

010

0010

0011

110

0110

0100

111

0111

0101

101

0101

0110

100

0100

0111

1100

1000

1101

1001

1111

1010

1110

1011

1010

1100

1011

1101

1001

1110

1000

1111

Hot coding alone

namely One-Hot code , Also known as a bit effective code , Only one bit of each symbol value is '1', The others are '0',

Such as S0=3'b001,S1=3'b010,S2=3'b100

namely N A state needs N Trigger . The speed of the hot code state machine is only related to the number of transitions to a particular state, but not to the number of States , fast . And because its state decoding is simple , Therefore, the combinational logic circuit is saved and simplified .FPGA Due to the large number of registers, the logic gate resources of devices are tight , Using heat only coding can effectively improve FPGA Resource utilization and circuit speed . Single hot code also has simple design 、 Flexible modification and easy debugging 、 Easy to integrate 、 Easy to find critical path 、 Easy to carry out static timing analysis and other advantages . Therefore, try to use unique coding .

NEXT PAGE:

Specify the encoding method in the synthesizer

原网站

版权声明
本文为[Drink more hot water-]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140547485728.html