国产FPGA图像采集与图像显示

采用复旦微电子的K7系列FPGA芯片,实现SDI图像输入和SDI图像输出。

芯片开发环境为Vivado2017.4。

芯片型号为JFM7K325T,该芯片与Xilinx的XC7K325T芯片pin-to-pin兼容。

图像输入格式为标准的BT1120格式,可兼容25帧,30帧,60帧不同频率的信号输入。

其主要模块主要有参数获取模块,图像采集模块,异步FIFO模块以及图像输出模块

参数获取模块:获取图像的帧频,图像的行消隐周期以及图像的开始信号。

图像采集模块:利用图像开始信号,以及BT1120格式的同步码进行数据采集,并将采集的数据送入异步FIFO中。

异步FIFO模块:缓存图像的有效像素。在每帧图像的最后一行进行清零,以做好写入数据的准备。另外,图像写入的时钟与像素时钟取反,图像读出的时钟与图像输出模块的时钟取反。

图像输出模块:根据BT1120格式进行帧数据重组。其模块精髓主要在于该模块与图像采集模块输出的帧开始信号进行同步,然后在执行完最后一行的同步码后提前回到状态零位置,等待下一个帧开始信号。

代码的主要框架如下所示:

`timescale 1ns / 1ps
//
// Company: 
// Engineer: 
// 
// Create Date: 2022/08/12 17:29:04
// Design Name: 
// Module Name: SDI
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//


module SDI(
    //系统时钟和复位
    input FPGA_Clk,  //50Mhz               
    input FPGA_Rst_n,
    //SDI输入
    input SDI_Clk_in,               
    input [19:0]SDI_Data_in,
    //SDI输出                                
    output SDI_Clk_out,             
    output [15:0]SDI_Data_out,    
    );
    
    //PLL
    wire clk74p25m;
    wire clk148p5m;
    wire clk14p85m_ph90;
    wire locked;
    wire SDI_Rst_n= FPGA_Rst_n & locked;
    
    //SDI_Parameter
    wire [31:0]Hsync_Parameter;
    wire [47:0]Vsync_Parameter;
    wire frame_start;
    
    //SDI_Collect
    wire [15:0]SDI_Collect_data_out;
    wire SDI_Collect_data_en;
    wire SDI_Collect_fs_out;
       
    //SDI_FIFO_Gen
    wire SDI_FIFO_Gen_rd_en;
    wire [15:0]SDI_FIFO_Gen_dout;
    wire full;
    wire empty;

    //SDI_Creat
    wire SDI_Creat_clr;
           
    //CLK_Gen
    CLK_Gen CLK_Gen(
        .clk_out1       (clk74p25m),     // output clk_out1
        .reset          (~FPGA_Rst_n),   // input reset
        .locked         (locked),        // output locked
        .clk_in1        (FPGA_Clk)
    ); 
    
    //ILA_CLK_Gen 
    ILA_CLK_Gen ILA_CLK_Gen(
        .clk_out1       (clk148p5m),     // output clk_out1
        .reset          (~FPGA_Rst_n),   // input reset
        .locked         (),        // output locked
        .clk_in1        (clk74p25m)
      ); 
    
    //SDI视频参数提取
    SDI_Parameter SDI_Parameter(
        .SDI_Clk_in         (SDI_Clk_in),
        .rst_n              (SDI_Rst_n),
        .SDI_Data_in        (SDI_Data_in),
        .Hsync_Parameter    (Hsync_Parameter),
        .Vsync_Parameter    (Vsync_Parameter),
        .Frame_Start        (frame_start)
        );
    
    //视频图像采集
    SDI_Collect SDI_Collect(
        .rst_n              (SDI_Rst_n),
        .clk_in             (SDI_Clk_in),
        .data_in            (SDI_Data_in),
        .frame_start        (frame_start),
        .Hsync_Parameter    (Hsync_Parameter),
        .Vsync_Parameter    (Vsync_Parameter),
        .data_out           (SDI_Collect_data_out),
        .data_en            (SDI_Collect_data_en),
        .fs_out             (SDI_Collect_fs_out)
        );  
              
    //有效像素缓存
    SDI_FIFO_Gen SDI_FIFO_Gen (
        .rst                    (~SDI_Rst_n || SDI_Creat_clr),
        .wr_clk                 (~SDI_Clk_in),               // input wire wr_clk
        .rd_clk                 (~clk74p25m),                // input wire rd_clk
        .din                    (SDI_Collect_data_out),      // input wire [15 : 0] din
        .wr_en                  (SDI_Collect_data_en),       // input wire wr_en
        .rd_en                  (SDI_FIFO_Gen_rd_en),        // input wire rd_en
        .dout                   (SDI_FIFO_Gen_dout),         // output wire [15 : 0] dout
        .full                   (full),                      // output wire full
        .empty                  (empty),                     // output wire empty
        .rd_data_count          (),                          // output wire [11 : 0] rd_data_count
        .wr_data_count          (),                          // output wire [11 : 0] wr_data_count
        .wr_rst_busy            (),                          // output wire wr_rst_busy
        .rd_rst_busy            ()                           // output wire rd_rst_busy
    );

    //视频帧重组
    SDI_Creat SDI_Creat(
        .clk_in             (clk74p25m),
        .rst_n              (SDI_Rst_n),
        .frame_start        (SDI_Collect_fs_out),
        .Hsync_Parameter    (Hsync_Parameter),   //高16位是消隐长度,低16位是有效数据长度。
        .Vsync_Parameter    (Vsync_Parameter),   //高16位是帧前消隐长度,中间16位是帧有效长度,低16位是帧后消隐长度
        .data_in            (SDI_FIFO_Gen_dout),
        .rd_en              (SDI_FIFO_Gen_rd_en),
        .clr                (SDI_Creat_clr),
        .clk_out            (SDI_Clk_out),
        .data_out           (SDI_Data_out)
        );    

endmodule

你可能感兴趣的:(FPGA,Vivado,fpga,fifo)