BT1120时序,可以用于自测用

    module bt1120_gen #(
        parameter H_SYNC                 =  44,
        parameter H_FRONT_PORCH =  88,
        parameter H_BACK_PORCH  = 148,
        parameter V_SYNC            =   5,
        parameter V_FRONT_PORCH =   4,
        parameter V_BACK_PORCH  =  36
    
    
    )(
        input             clk,
        input             rst_p,
//        input [5:0] h_sync_pixcels,
//        input [5:0] h_front_porch_pixcels,
//        input [5:0] h_back_porch_pixcels,
//        input [5:0] v_sync_lines,
//        input [5:0] v_front_porch_lines,
//        input [5:0] v_back_porch_lines,
                
        input [12:0] col,
        input [12:0] row,
        
        output reg[15:0] odata,
        output reg v_sync,
        output reg h_sync,
        output reg de
        
        
        
    );
    
    
    parameter S_H_SYNC = 2'b00;
    parameter S_H_BACK_PORCH = 2'b01;
    parameter S_H_ACTIVE   = 2'b10;
    parameter S_H_FRONT_PORCH = 2'b11;
    parameter S_V_SYNC = 2'b00;
    parameter S_V_BACK_PORCH = 2'b01;
    parameter S_V_ACTIVE   = 2'b10;
    parameter S_V_FRONT_PORCH = 2'b11;
    
    
    
    reg [1:0] h_pre_state = S_H_FRONT_PORCH;
    reg [1:0] h_nx_state = S_H_FRONT_PORCH;
    reg [1:0] v_pre_state = S_V_SYNC;
    reg [1:0] v_nx_state = S_V_SYNC;
    
    reg [12:0] h_cnt     = 0;
    reg [12:0] v_cnt     = 0;
    reg [15:0] sync_code = 0;
    reg           de_r     = 1'b0;
    reg             vid_sop_r = 1'b0;
    wire            pos_vid_sop;
    reg                fifo_rd_valid = 1'b0;
    reg [15:0] fifo_rd_data_r = 16'd0;
    reg [15:0] sync_code_r = 16'd0;
    reg [15:0] sync_code_r1 = 16'd0;
    reg                  de_r1 = 1'b0;
    reg                    de_r2 = 1'b0;
    reg                    h_sync_r = 1'b0;
    reg                    h_sync_r1 = 1'b0;
    reg                    h_sync_r2 = 1'b0;
    reg                    v_sync_r  = 1'b0;
    reg                    v_sync_r1 = 1'b0;
    reg                    v_sync_r2 = 1'b0;
        

    
    
    
    
    
    
    reg data_en = 1'b0;
    reg data_en_dly = 1'b0;
    always @( posedge clk )
    begin
            if( h_nx_state == S_H_ACTIVE && v_nx_state == S_V_ACTIVE )
                    data_en <= 1'b1;
            else
                    data_en <= 1'b0;
    end
    
    always @( posedge clk )
    begin
            data_en_dly <= data_en;
    end
    
    always @( posedge clk )
    begin
            if( data_en_dly )
                    fifo_rd_data_r <= fifo_rd_data_r + 1'b1;
            else
                    fifo_rd_data_r <= 16'd0;
    end
    
/***********************************************************************

***********************************************************************/    
    
    always @( posedge clk )//or posedge rst_p
    begin
            if( rst_p ) begin 
                h_pre_state <= S_H_FRONT_PORCH;
                v_pre_state <= S_V_SYNC;

            end else begin 
                h_pre_state <= h_nx_state;
                v_pre_state <= v_nx_state;
            end 
    end
    
    always @( * )
    begin
            case( h_pre_state )
            S_H_SYNC :
                    if( h_cnt == H_SYNC -1 )
                            h_nx_state  <= S_H_BACK_PORCH;
                    else
                            h_nx_state <= S_H_SYNC;
            
            S_H_BACK_PORCH :
            begin
                    if( h_cnt == H_BACK_PORCH -1 )        
                            h_nx_state  <= S_H_ACTIVE;
                    else                            
                            h_nx_state <= S_H_BACK_PORCH;       
            end
            S_H_ACTIVE    :
            begin
                   if( h_cnt == col -1 )     
                        h_nx_state  <= S_H_FRONT_PORCH;           
                else                                   
                        h_nx_state <= S_H_ACTIVE;        
                    
            end
            S_H_FRONT_PORCH :    
            begin
                if( h_cnt == H_FRONT_PORCH -1 )                
                        h_nx_state  <= S_H_SYNC;    
                else                                 
                        h_nx_state <= S_H_FRONT_PORCH;          
                  
            end        
            default:;
            endcase    
                            
    end
    
    always @( * )
    begin
            case( v_pre_state )
            S_V_SYNC :
            begin 
                    if( h_nx_state == S_H_FRONT_PORCH &&  h_pre_state  == S_H_ACTIVE   ) begin
                            if( v_cnt == V_SYNC -1 )
                                    v_nx_state = S_V_BACK_PORCH;
                            else
                                v_nx_state = S_V_SYNC;
                    end else begin
                            v_nx_state = S_V_SYNC;
                    end
            end
            S_V_BACK_PORCH :
            begin
                    if( h_nx_state == S_H_FRONT_PORCH &&  h_pre_state  == S_H_ACTIVE   ) begin
                            if( v_cnt == V_BACK_PORCH -1 )        
                                    v_nx_state = S_V_ACTIVE;
                            else
                                    v_nx_state = S_V_BACK_PORCH;    
                    end else begin
                            v_nx_state = S_V_BACK_PORCH;  
                    end  
            end
            S_V_ACTIVE    :
            begin
                    if( h_nx_state == S_H_FRONT_PORCH &&  h_pre_state  == S_H_ACTIVE   ) begin
                           if( v_cnt == row -1 )     
                                v_nx_state = S_V_FRONT_PORCH;
                            else
                                    v_nx_state = S_V_ACTIVE; 
                end else begin
                        v_nx_state = S_V_ACTIVE; 
                end       
                    
            end
            S_V_FRONT_PORCH :    
            begin
                    if( h_nx_state == S_H_FRONT_PORCH &&  h_pre_state  == S_H_ACTIVE   ) begin
                        if( v_cnt == V_FRONT_PORCH -1'b1 )                
                                v_nx_state = S_V_SYNC;
                            else
                                    v_nx_state = S_V_FRONT_PORCH; 
                    end else begin
                            v_nx_state = S_V_FRONT_PORCH;
                    end
            end        
            default:;
            endcase    
//            end else begin
//                    v_nx_state = v_nx_state;
//            end
//    
    end
/***********************************************************************
cnt
***********************************************************************/
    always @( posedge clk )
    begin
        if( rst_p ) begin
            h_cnt <= 0;
        end else begin 
            case( h_nx_state )
            S_H_SYNC :
            begin 
                     if( h_pre_state == S_H_FRONT_PORCH  )  //&& h_cnt == H_FRONT_PORCH -1
                            h_cnt <= 0;
                    else
                            h_cnt <= h_cnt + 1'b1;
            end 
            S_H_BACK_PORCH :
            begin
                    if( h_pre_state == S_H_SYNC )//&& h_cnt == H_SYNC -1)
                            h_cnt <= 0;
                    else                            
                            h_cnt <= h_cnt + 1'b1;       
            end
            S_H_ACTIVE    :
            begin
                if( h_pre_state == S_H_BACK_PORCH)// && h_cnt == H_BACK_PORCH -1)
                        h_cnt <= 0;           
                else                                   
                        h_cnt <= h_cnt + 1'b1;        
            end
            S_H_FRONT_PORCH :    
            begin
                if( h_pre_state == S_H_ACTIVE )//&& h_cnt == col -1)
                        h_cnt <= 0;   
                else                                 
                        h_cnt <= h_cnt + 1'b1;       
            end        
            default:;
            endcase    
    end
    end 
    
    always @( posedge clk or posedge rst_p )
    begin
        if( rst_p)
            v_cnt <= 0;
        else  begin 
            if( h_nx_state == S_H_FRONT_PORCH &&  h_pre_state  == S_H_ACTIVE   ) 
            begin
                case( v_nx_state )
                S_V_SYNC :
                begin
                    if( v_pre_state == S_V_FRONT_PORCH )
                            v_cnt <= 0;
                    else
                            v_cnt <= v_cnt + 1'b1;
                end
            
                S_V_BACK_PORCH :
                begin
                    if( v_pre_state  ==  S_V_SYNC )        
                            v_cnt <= 0;
                    else                            
                            v_cnt <= v_cnt + 1'b1;       
                end
                S_V_ACTIVE    :
                begin
                   if( v_pre_state  ==  S_V_BACK_PORCH )     
                        v_cnt <= 0;           
                else                                   
                        v_cnt <= v_cnt + 1'b1;        
                    
                end
                S_V_FRONT_PORCH :    
                begin
                if( v_pre_state  ==  S_V_ACTIVE )               
                        v_cnt <= 0;   
                else                                 
                        v_cnt <= v_cnt + 1'b1;       
                  
                end        
                default:;
                endcase    
            end
        end
    end
    
/***********************************************************************
h_sync v_sync de 
***********************************************************************/    
    always @( posedge clk )
    begin
            if( h_nx_state == S_H_SYNC )
                    h_sync_r <= 1'b1;
            else
                    h_sync_r <= 1'b0;
    end
    
    always @( posedge clk )
    begin
            if( v_nx_state == S_V_SYNC )
                    v_sync_r <= 1'b1;
            else
                    v_sync_r <= 1'b0;
    end
    
    always @( posedge clk )
    begin
            if( h_nx_state == S_H_ACTIVE && v_nx_state == S_V_ACTIVE )
                    de_r <= 1'b1;
            else
                    de_r <= 1'b0;
    end
/***********************************************************************

***********************************************************************/    
    
    always @( posedge clk )
    begin
        if( h_nx_state == S_H_ACTIVE && v_nx_state == S_V_ACTIVE )
                sync_code <= 16'd0;
        else if(( h_nx_state == S_H_BACK_PORCH) && ( v_nx_state == S_V_SYNC || v_nx_state == S_V_BACK_PORCH || v_nx_state == S_V_FRONT_PORCH))
                case( h_cnt )
                        H_BACK_PORCH -2 : sync_code <= 16'habab;//16'hab00;//
                        H_BACK_PORCH -3 : sync_code <= 16'h0000;//16'h00ff;//
                        H_BACK_PORCH -4 : sync_code <= 16'h0000;//16'h8010;//
                        H_BACK_PORCH -5 : sync_code <= 16'hffff;//16'h8010;//
                default:sync_code <= 16'h1080;
                endcase
        else if(( h_nx_state == S_H_FRONT_PORCH) && ( v_nx_state == S_V_SYNC || v_nx_state == S_V_BACK_PORCH || v_nx_state == S_V_FRONT_PORCH))
                if( h_pre_state == S_H_ACTIVE)
                        sync_code <= 16'hffff;//16'h00ff;//
                else begin
                    case(h_cnt )            
                        0 : sync_code <= 16'h0000;//16'hb600;//
                        1 : sync_code <= 16'h0000;//16'h8010;//
                        2 : sync_code <= 16'hb6b6;//16'h8010;//      
                    default:sync_code <= 16'h1080;
                    endcase
                end
        else if(( h_nx_state == S_H_BACK_PORCH)) begin // && ( v_nx_state == S_V_ACTIVE)
            case(h_cnt )                       
                      H_BACK_PORCH -2 : sync_code <= 16'h8080;//16'h8000;//      
                      H_BACK_PORCH -3 : sync_code <= 16'h0000;//16'h00ff;//      
                      H_BACK_PORCH -4 : sync_code <= 16'h0000;//16'h8010;//     
                      H_BACK_PORCH -5 : sync_code <= 16'hffff;//16'h8010;//         
              default:sync_code <= 16'h1080;                      
              endcase                        
        end
        else if(( h_nx_state == S_H_FRONT_PORCH)) begin// && ( v_nx_state == S_V_ACTIVE)
                if( h_pre_state == S_H_ACTIVE)
                        sync_code <= 16'hffff;//16'h00ff;//
                else begin
                    case(h_cnt )                       
                            0 : sync_code <= 16'h0000;//16'h9d00;//     
                            1 : sync_code <= 16'h0000;//16'h8010;//      
                            2 : sync_code <= 16'h9d9d;//16'h8010;//         
                    default:sync_code <= 16'h1080;                      
                    endcase  
                end                       
        end
        else begin
                    sync_code <= 16'h1080;
        end

    end
/***********************************************************************
sync
***********************************************************************/    
    
    always @( posedge clk )
    begin
        sync_code_r <= sync_code;
        sync_code_r1<= sync_code_r;
        de_r1 <= de_r;
        de_r2 <= de_r1;
        h_sync_r1 <= h_sync_r;
        h_sync_r2 <= h_sync_r1;
        v_sync_r1 <= v_sync_r;
        v_sync_r2 <= v_sync_r1;
        
    end
    always @( posedge clk )
    begin
            odata <= sync_code_r1 + fifo_rd_data_r;
            h_sync <= h_sync_r2;
            v_sync <= v_sync_r2;
            de     <= de_r2;
    end
    

    
    endmodule
    
        

 

转载于:https://www.cnblogs.com/zhongguo135/p/9121005.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: BT1120是一种用于数字视频传输的接口标准,它可以被用于将高清分辨率的视频信号传输到显示设备上。时序配置是指将BT1120接口的时序信号设置为适合特定分辨率的配置方式,以确保视频信号能够正确传输和显示。 针对720p分辨率的时序配置,我们可以按照以下步骤进行设置: 1. 首先需要选择适当的像素时钟频率。720p分辨率的像素时钟频率为74.25MHz,我们需要将BT1120接口的时钟设置为此频率。 2. 接下来,我们需要配置行和帧的同步信号。720p的行和帧同步信号采用的是ITU-R BT.656标准,所以我们需要将BT1120接口的行同步信号和帧同步信号设置为符合该标准的配置。 3. 确定像素时序和数据格式。720p的像素时序为1280x720,数据格式为16位RGB格式。因此,我们需要将BT1120接口的像素时序设置为1280x720,并将数据格式设置为16位RGB格式。 4. 最后,我们还需要根据具体的系统要求设置其他相关参数,例如时序延迟、时钟极性等。 通过以上步骤的配置,我们可以确保BT1120接口能够正确地传输和显示720p分辨率的视频信号。这样用户就可以在高清的画质下享受到优质的视频体验。 ### 回答2: bt1120是一种视频时序接口,用于传输高清视频信号。在720p分辨率下的时序配置是指配置bt1120接口传输720p分辨率的视频信号的时钟和同步信号。 具体的时序配置包括以下几个方面: 1. 时钟速率配置:在720p分辨率下,视频信号的时钟速率一般为74.25MHz。需要配置bt1120接口的发送端和接收端时钟速率为相同的数值,以保证数据传输的稳定和正确。 2. 水平同步信号配置:720p视频信号的水平同步信号为1280个时钟周期,需要通过配置bt1120接口使发送端和接收端正确识别水平同步信号的位置,以确保视频画面的稳定和完整。 3. 垂直同步信号配置:720p视频信号的垂直同步信号为720行,需要通过配置bt1120接口使发送端和接收端正确识别垂直同步信号的位置,以确保视频画面的稳定和完整。 4. VSYNC信号极性配置:bt1120接口支持配置VSYNC信号的上升沿或下降沿作为垂直同步信号。需要根据具体系统的需求,配置bt1120接口的VSYNC信号极性。 通过合理的时序配置,bt1120接口可以稳定传输720p分辨率的高清视频信号,使图像质量达到要求,并且保证数据的准确性和可靠性。 ### 回答3: bt1120是一种视频传输协议,可以传输高清视频信号。时序配置是为了确保视频数据在传输过程中的时序正确性。 针对720p分辨率的视频,我们需要进行适当的时序配置。首先,我们需要设置垂直同步信号的参数。对于720p来说,垂直同步信号的垂直前肩、垂直同步脉冲和垂直后肩的时长需要根据具体规格进行配置。同时,还需要配置水平同步信号的参数,包括水平前肩、水平同步脉冲和水平后肩的时长。 其次,还需要设置像素时钟和行/场信号的参数。像素时钟是指每个像素的时间间隔,需要根据720p的分辨率确定。行信号和场信号是用于指示视频的行数和场数的信号,也需要根据720p的规格进行配置。 最后,还需要设置数据传输的参数。bt1120协议中,一帧视频数据通常包括若干行像素数据以及同步信号。我们需要根据720p规格设置每行像素数据的时长、每帧的行数以及数据传输时的时钟频率等参数。 总之,bt1120时序配置720p需要根据具体规格设置垂直同步信号、水平同步信号、像素时钟和行/场信号的参数,以及数据传输的相关参数。通过正确的时序配置,可以确保720p视频信号在传输中的正确性和稳定性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值