
测试设置低端信号发生器输出20K的方波FPGA工作在100M的时钟下抓取触发信号上升沿FPGA程序为assign o_rise_edge i_ex_trig_3p3v !r_ex_trig_3p3v;always (posedge clk) beginr_ex_trig_3p3v i_ex_trig_3p3v; // 打一拍保存上一周期值end测试现象o_rise_edge 时有时无。原因解决方案reg r_ex_trig_3p3v_sync1, r_ex_trig_3p3v_sync2;// 第一级同步打两拍解决亚稳态always (posedge clk) beginr_ex_trig_3p3v_sync1 i_ex_trig_3p3v; // 第一拍r_ex_trig_3p3v_sync2 r_ex_trig_3p3v_sync1; // 第二拍end// 然后用同步后的信号做边沿检测assign o_rise_edge r_ex_trig_3p3v_sync2 !r_ex_trig_3p3v_sync1;// 注意这里用 sync2 和 sync1 比较而不是用 r_ex_trig_3p3v