⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 v_sync.v

📁 something is very important in life. So read it. Try reading it,. I do not care. Please read it/ Ple
💻 V
📖 第 1 页 / 共 2 页
字号:
                        if (v_p_cnt_tc == 0) VSYNC_ns = PULSE;                     
                        else VSYNC_ns = BACK_PORCH;
                end
                /////////////////////////////////////////////////////////////////////////
                //      BACK PORCH STATE
                // -- Enable back porch counter
                // -- De-enable others
                /////////////////////////////////////////////////////////////////////////
                BACK_PORCH: begin
                        v_p_cnt_ce = 0;
                        v_p_cnt_clr = 1;
                        v_bp_cnt_ce = 1;
                        v_bp_cnt_clr = 0;
                        v_l_cnt_ce = 0;
                v_l_cnt_clr = 1;
                        v_fp_cnt_ce = 0;
                        v_fp_cnt_clr = 1;
                        VSYNC = 1;
                        V_DE = 0;                               
                        if (v_bp_cnt_tc == 0) VSYNC_ns = BACK_PORCH;                                                       
                        else VSYNC_ns = LINE;
                end
                /////////////////////////////////////////////////////////////////////////
                //      LINE STATE
                // -- Enable line counter
                // -- De-enable others
                /////////////////////////////////////////////////////////////////////////
                LINE: begin
                        v_p_cnt_ce = 0;
                        v_p_cnt_clr = 1;
                        v_bp_cnt_ce = 0;
                        v_bp_cnt_clr = 1;
                        v_l_cnt_ce = 1;
                v_l_cnt_clr = 0;
                        v_fp_cnt_ce = 0;
                        v_fp_cnt_clr = 1;
                        VSYNC = 1;
                        V_DE = 1;  
                        if (v_l_cnt_tc == 0) VSYNC_ns = LINE;                                                      
                        else VSYNC_ns = FRONT_PORCH;
        end
                /////////////////////////////////////////////////////////////////////////
                //      FRONT PORCH STATE
                // -- Enable front porch counter
                // -- De-enable others
                // -- Wraps to PULSE state
                /////////////////////////////////////////////////////////////////////////
                FRONT_PORCH: begin
                        v_p_cnt_ce = 0;
                        v_p_cnt_clr = 1;
                        v_bp_cnt_ce = 0;
                        v_bp_cnt_clr = 1;
                        v_l_cnt_ce = 0;
                v_l_cnt_clr = 1;
                        v_fp_cnt_ce = 1;
                        v_fp_cnt_clr = 0;
                        VSYNC = 1;
                        V_DE = 0;       
                        if (v_fp_cnt_tc == 0) VSYNC_ns = FRONT_PORCH;                                                      
                        else VSYNC_ns = PULSE;
                end
                /////////////////////////////////////////////////////////////////////////
                //      DEFAULT STATE
                /////////////////////////////////////////////////////////////////////////
                default: begin
                        v_p_cnt_ce = 0;
                        v_p_cnt_clr = 1;
                        v_bp_cnt_ce = 0;
                        v_bp_cnt_clr = 1;
                        v_l_cnt_ce = 0;
                v_l_cnt_clr = 1;
                        v_fp_cnt_ce = 1;
                        v_fp_cnt_clr = 0;
                        VSYNC = 1;      
                        V_DE = 0;
                        VSYNC_ns = SET_COUNTERS;
                end
                endcase
        end

///////////////////////////////////////////////////////////////////////////////
//      Vertical Pulse Counter - Counts 2 clocks(~HSYNC) for pulse time                                                                                                                                 
///////////////////////////////////////////////////////////////////////////////
        always @(posedge clk)
        begin
                if (v_p_cnt_clr) begin
                        v_p_cnt = 2'b0;
                        v_p_cnt_tc = 0;
                end
                else if (clk_ce_neg) begin
                        if (v_p_cnt_ce) begin
                                if (v_p_cnt == 1) begin
                                        v_p_cnt = v_p_cnt + 1;
                                        v_p_cnt_tc = 1;
                                end
                                else begin
                                        v_p_cnt = v_p_cnt + 1;
                                        v_p_cnt_tc = 0;
                                end
                        end
                end
        end

///////////////////////////////////////////////////////////////////////////////
//      Vertical Back Porch Counter - Counts 31 clocks(~HSYNC) for pulse time                                                                   
///////////////////////////////////////////////////////////////////////////////
        always @(posedge clk)
        begin
                if (v_bp_cnt_clr) begin
                        v_bp_cnt = 5'b0;
                        v_bp_cnt_tc = 0;
                end
                else if (clk_ce_neg) begin
                        if (v_bp_cnt_ce) begin
                                if (v_bp_cnt == 30) begin
                                        v_bp_cnt = v_bp_cnt + 1;
                                        v_bp_cnt_tc = 1;
                                end
                                else begin
                                        v_bp_cnt = v_bp_cnt + 1;
                                        v_bp_cnt_tc = 0;
                                end
                        end
                end
        end

///////////////////////////////////////////////////////////////////////////////
//      Vertical Line Counter - Counts 480 clocks(~HSYNC) for pulse time                                                                                                                                
///////////////////////////////////////////////////////////////////////////////                                                                                                                                 
        always @(posedge clk)
        begin
                if (v_l_cnt_clr) begin
                        v_l_cnt = 9'b0;
                        v_l_cnt_tc = 0;
                end
                else if (clk_ce_neg) begin
                        if (v_l_cnt_ce) begin
                                if (v_l_cnt == 479) begin
                                        v_l_cnt = v_l_cnt + 1;
                                        v_l_cnt_tc = 1;
                                end
                                else begin
                                        v_l_cnt = v_l_cnt + 1;
                                        v_l_cnt_tc = 0;
                                end
                        end
                end
        end

///////////////////////////////////////////////////////////////////////////////
//      Vertical Front Porch Counter - Counts 12 clocks(~HSYNC) for pulse time
///////////////////////////////////////////////////////////////////////////////
        always @(posedge clk)
        begin
                if (v_fp_cnt_clr) begin
                        v_fp_cnt = 4'b0;
                        v_fp_cnt_tc = 0;
                end
                else if (clk_ce_neg) begin
                        if (v_fp_cnt_ce) begin
                                if (v_fp_cnt == 11) begin
                                        v_fp_cnt = v_fp_cnt + 1;
                                        v_fp_cnt_tc = 1;
                                end
                                else begin
                                        v_fp_cnt = v_fp_cnt + 1;
                                        v_fp_cnt_tc = 0;
                                end
                        end
                end
        end
endmodule

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -