復(fù)位目的:使整個系統(tǒng)進(jìn)入一個指定的初始狀態(tài)
同步復(fù)位
always @(posedge clk)
begin
if(!rst_n)
......
else
......
end
優(yōu)點(diǎn):
- 可使整個電路為完全的同步設(shè)計,有利于靜態(tài)時序分析(STA)顶猜。
- 有利于仿真工具仿真(Modelsim沧奴、Vcs)。
- 只在時鐘觸發(fā)沿發(fā)生發(fā)生作用长窄,濾除毛刺滔吠。
缺點(diǎn)以及注意事項(xiàng):
- 復(fù)位脈寬必須超過一個時鐘周期。
- 復(fù)位依賴于時鐘信號挠日。
- 若復(fù)位信號發(fā)生在時鐘沿屠凶,可能產(chǎn)生亞穩(wěn)態(tài)。
- 對于同步復(fù)位信號管腳在數(shù)據(jù)通路中或者是沒有專用的同步復(fù)位管腳的器件肆资,同步復(fù)位將耗費(fèi)更多資源實(shí)現(xiàn)矗愧。
異步復(fù)位
always @(posedge clk or negedge rst_n)
begin
if(!rst_n)
......
else
......
end
優(yōu)點(diǎn):
- 復(fù)位不會出現(xiàn)在數(shù)據(jù)通路,減少額外邏輯以及數(shù)據(jù)延遲
- 復(fù)位不依賴于時鐘信號
缺點(diǎn)及注意事項(xiàng):
- 對毛刺敏感
- 若在始終觸發(fā)沿附近去除復(fù)位郑原,可能產(chǎn)生亞穩(wěn)態(tài)
復(fù)位策略
- 異步低復(fù)位
- 同步的異步復(fù)位唉韭。即異步復(fù)位,同步釋放犯犁。
- 能不用復(fù)位的地方盡量不用属愤。
- 對于RAM、ROM酸役、乘法器住诸、數(shù)據(jù)計算通路,不需要復(fù)位涣澡,同時也節(jié)省資源贱呐。
- 移位寄存器,若不復(fù)位入桂,則可充分進(jìn)行資源優(yōu)化奄薇。
- 對于控制信號、計數(shù)器抗愁、狀態(tài)機(jī)的狀態(tài)寄存器等必須要用復(fù)位馁蒂。
異步復(fù)位HDL代碼:
module arsr //Asynchronous reset, synchronous release
(
// input i_clk_a ,
input i_rst_n_a ,
input i_clk_b ,
output reg o_rst_n_b
)
//----------------------------- reg && wire -------------------------------
reg rst_n_temp_0 ;
reg rst_n_temp_1 ;
//-------------------------------- o_rst_b_n -----------------------------------
always @(posedge i_clk_b or negedge i_rst_n_a)
begin
if(!i_rst_n_a)
begin
rst_n_temp_0 <= 1'b0;
rst_n_temp_1 <= 1'b0;
o_rst_n_b <= 1'b0;
end
else
begin
rst_n_temp_0 <= 1'b1;
rst_n_temp_1 <= rst_n_temp_0;
o_rst_n_b <= rst_n_temp_1;
end
end
endmodule
如代碼那樣呵晚,即可將在(A時鐘域的復(fù)位信號)變成(B時鐘域也可以用的復(fù)位信號)。
來源:馬哥 - Marin
著作權(quán)歸作者所有沫屡。商業(yè)轉(zhuǎn)載請聯(lián)系作者獲得授權(quán)饵隙,非商業(yè)轉(zhuǎn)載請注明出處。