1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | //------------------------------------------- //帧率采样计算 reg fps_state; reg [7:0] fps_data; always@(posedge iCLK or negedge iRST_N) begin if(!iRST_N) begin fps_data <= 0; fps_state <= 0; CMOS_FPS_DATA <= 0; end else if(Frame_valid) begin case(fps_state) 0: begin CMOS_FPS_DATA <= CMOS_FPS_DATA; if(delay_2s == 0) begin fps_state <= 0; if(CMOS_VSYNC_over == 1'b1) //VS上升沿,1帧写入完毕 fps_data <= fps_data + 1'b1; end else fps_state <= 1; end 1: begin fps_state <= 0; fps_data <= 0; CMOS_FPS_DATA <= fps_data >>1; end endcase end else begin fps_data <= 0; fps_state <= 0; CMOS_FPS_DATA <= 0; end end endmodule |
更多回帖