RTL Coding 读书笔记3: Finite State Machine

################################################
# 1) The Fundamentals of Efficient Synthesizable Finite State Machine Design using NC-Verilog and BuildGates
################################################

Style

Usage

Reason

one always block

dont use 

1) more verbose
2) output assignments are more error prone to coding mistakes
3) cannot code asynchronous Mealy outputs without making the output  assignments with separate continuous assign statements.

two always block 

to code FSM designs with combinational outputs

1) efficient
2) easy to code
3) easily handle Mealy FSM designs

three always block

to code FSM designs with registered outputs

Note, another recommended coding style for FSM designs with registered outputs is the"output encoded" FSM coding style

1) efficient
2) easy to code

 

################################################
# 2) Coding And Scripting Techniques For FSM Designs With Synthesis-Optimized, Glitch-Free Outputs
################################################

Reason for register the output of FSM
  1) for better timing synthesis result of multi-module design
  2) output is glitch-free

Method
  1)  Three Always Block FSM
  2)  Output Encoded FSM
        it is an efficient technique for coding FSMs to drive registered outputs directly from the state register bits.
        Detailed design step is discussed in this paper.

 

################################################
# 3) Synthesizable Finite State Machine Design Techniques Using the New SystemVerilog 3.0 Enhancements
################################################

1.0 Introduction

1.1 FSM Coding Goals
  easily modifiable
  easy to code and understand
  compact
  facilitate debugging
  efficient synthesis results

1.2 Important coding style notes:
  1. Make each FSM design a separate Verilog module
  2. Use parameters to define state encodings instead of the Verilog `define macro
  3. make state and next (next state) declarations right after the parameter assignments.
  4. Code all sequential always block using nonblocking assignments
  5. Code all combinational always block using blocking assignments

2.0 Review of standard Verilog FSM coding styles

2.1. Two always block style with combinational outputs (Good Style)
     X's help to debug the design during simulation
     X's help to optimize the design during synthesis

2.2. One sequential always block style with registered outputs - (Avoid this style!)

2.3 Three always block style with registered outputs (Good style)

2.4 Onehot coding styles
    Index-parameter style with registered outputs (Good style)
    Encoded-parameter style with registered outputs (Avoid this style!)

2.5 Output encoded style with registered outputs (Good style)

3.0 fsm7 Example

one always blocks style (Avoid this style!)
three always blocks style (Good style)

4.0 fsm8 Example

one always blocks style (Avoid this style!)
three always blocks style (Good style)

5.0 prep4 Example

one always blocks style (Avoid this style!)
three always blocks style (Good style)

6.0 Coding benchmarks for standard FSM coding styles

best:   output encoded style
worst:  one always block style

7.0 Synthesis benchmarks for standard FSM coding styles

Timing & Area
 

8.0 DC-Ultra 2002.05 FSM Tool

 

9.0 Verliog-2001 Enhanced Coding Styles

 

10.0 SystemVerilog enhancements

 

11.0 Implicit port connections

 

12.0 FSM coding with SystemVerilog 3.0

x = all X's, 'z = all Z's and '1 = all 1's

13.0 Ask your vendor to support SystemVerilog, NOW!

14.0 Conclusions

Guideline: do not use the one always block FSM coding style.

Guideline: do not use state-encoded parameters to code a onehot FSM design. Use the index-encoded parameter style to implement an efficient onehot FSM design.

15.0 fsm7 Verilog & SystemVerilog code

RTL Code Example of different styles

16.0 fsm8 Verilog & SystemVerilog code

RTL Code Example of different styles

17.0 prep4 Verilog & SystemVerilog code

RTL Code Example of different styles

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值