9) 除非是低功耗设计,不然不要用门控时钟--这会增加设计的不稳定性,在要用到门控时钟的地方,也要将门控信号用时钟的下降沿 打一拍再输出与时钟相与。
clk_gate_en -------- ----
-----------------|D Q |------------------| \ gate_clk
_out
| | ---------| )--------
-
------o|> | | | /
clk | -------- | ----
------------------------------------
10)禁止用计数器分频后的信号做其它模块的时钟,而要用改成时钟使能的方式,否则这种时钟满天飞的方式对设计的可靠性极为不利,也增加了静态时序分析的复杂性。如FPGA的输入时钟是25M的,现在系统内部要通过RS232与PC通信,要以rs232_1xclk的速率发送数据。
不要这样做:
always (posedge rs232_1xclk or negedge rst_n)
begin
...
end
而要这样做:
always (posedge clk_25m or negedge rst_n)
begin
...
else if ( rs232_1xclk == 1'b1 )
...
end
11)状态机要写成3段式的(这是最标准的写法),即
...
always @(posedge clk or negedge rst_n)
...
current_state <= next_state;
...
always @ (current_state ...)
...
case(current_state)
...
s1:
if ...
next_state = s2;
...
...
always @(posedge clk or negedge rst_n)
...
else
a <= 1'b0;
c <= 1'b0;
c <= 1'b0; //赋默认值
case(current_state)
s1:
a <= 1'b0; //由于上面赋了默认值,这里就不用再对b
、c赋值了
s2:
b <= 1'b1;
s3:
c <= 1'b1;
default:
...
...
3.ALTERA参考设计准则
1) Ensure Clock, Preset, and Clear configurations are free of glitch
es.
2) Never use Clocks consisting of more than one level of combinatori
al logic.
3) Carefully calculate setup times and hold times for multi-Clock sy
stems.
4) Synchronize signals between flipflops in multi-Clock systems when
the setup and hold time requirements cannot be met.
5) Ensure that Preset and Clear signals do not contain race conditio
ns.
6) Ensure that no other internal race conditions exist.
7) Register all glitch-sensitive outputs.
Synchronize all asynchronous inputs.
9) Never rely on delay chains for pin-to-pin or internal delays.
10)Do not rely on Power-On Reset. Use a master Reset pin to clear al
l flipflops.
11)Remove any stuck states from state machines or synchronous logic.
其它方面的规范一时没有想到,想到了再写,也欢迎大家补充。