鉴相器实现代码
鉴相器,pf_up是local相比reference朝前,pf_down是滞后, 经仿真可以实现功能。请各位评判下这样实现好不好,还有更好或可靠的方法没有,谢谢!
module top_jianxiang(reference_frq, local_frq, pf_up, pf_down );
input reference_frq;
input local_frq;
output pf_up;
output pf_down ;
reg pf_up,pf_down;
always @(posedge reference_frq or posedge local_frq)
begin
if (local_frq == 0)
pf_down <= 1;
else
if (local_frq == 1)
pf_down <= 0;
end
always @(posedge reference_frq or posedge local_frq)
begin
if (reference_frq == 0)
pf_up <= 1;
else
if (reference_frq == 1)
pf_up <= 0;
end
endmodule |