小弟从大三上自学FPGA,从入门到现在未做过任何相关FPGA的项目,毕设有幸选中了这个题目,基于FPGA的视频采集及处理,虽然是一直在仿照实验箱上的一个模块在做,但到现在为止,连采集的功能都还没能实现。从硬件制作到系统调试,最后停止在ADV7181b的初始化上,但相同的程序在实验箱上运行却没有问题,用示波器能在8位数据口上测到正常的输出波形,而自己制作的硬件板子上输出的却是未经过初始化的波形,在fpga输出端口也能测试到I2C总线的时钟和数据波形。下为初始化代码:
///////////////////// I2C Control Clock ////////////////////////
always@(posedge iCLK or negedge iRST_N)
begin
if(!iRST_N)
begin
mI2C_CTRL_CLK <= 0;
mI2C_CLK_DIV <= 0;
end
else
begin
if( mI2C_CLK_DIV < (CLK_Freq/I2C_Freq) )
mI2C_CLK_DIV <= mI2C_CLK_DIV+1;
else
begin
mI2C_CLK_DIV <= 0;
mI2C_CTRL_CLK <= ~mI2C_CTRL_CLK;
end
end
end
////////////////////////////////////////////////////////////////////
I2C_Controller u0 ( .CLOCK(mI2C_CTRL_CLK), // Controller Work Clock
.I2C_SCLK(I2C_SCLK), // I2C CLOCK
.I2C_SDAT(I2C_SDAT), // I2C DATA
.I2C_DATA(mI2C_DATA), // DATA:[SLAVE_ADDR,SUB_ADDR,DATA]
.GO(mI2C_GO), // GO transfor
.END(mI2C_END), // END transfor
.ACK(mI2C_ACK), // ACK
.RESET(iRST_N) );
////////////////////////////////////////////////////////////////////
////////////////////// Config Control ////////////////////////////
always@(posedge mI2C_CTRL_CLK or negedge iRST_N)
begin
if(!iRST_N)
begin
LUT_INDEX <= 0;
mSetup_ST <= 0;
mI2C_GO <= 0;
end
else
begin
if(LUT_INDEX<LUT_SIZE)
begin
case(mSetup_ST)
0: begin
if(LUT_INDEX<SET_VIDEO)
mI2C_DATA <= {8'h34,LUT_DATA};
else
mI2C_DATA <= {8'h40,LUT_DATA};
mI2C_GO <= 1;
mSetup_ST <= 1;
end
1: begin
if(mI2C_END)
begin
if(!mI2C_ACK)
mSetup_ST <= 2;
else
mSetup_ST <= 0;
mI2C_GO <= 0;
end
end
2: begin
LUT_INDEX <= LUT_INDEX+1;
mSetup_ST <= 0;
end
endcase
end
end
end
////////////////////////////////////////////////////////////////////
///////////////////// Config Data LUT //////////////////////////
always
begin
case(LUT_INDEX)
// Audio Config Data
SET_LIN_L : LUT_DATA <= 16'h001A;
SET_LIN_R : LUT_DATA <= 16'h021A;
SET_HEAD_L : LUT_DATA <= 16'h047B;
SET_HEAD_R : LUT_DATA <= 16'h067B;
A_PATH_CTRL : LUT_DATA <= 16'h08F8;
D_PATH_CTRL : LUT_DATA <= 16'h0A06;
POWER_ON : LUT_DATA <= 16'h0C00;
SET_FORMAT : LUT_DATA <= 16'h0E01;
SAMPLE_CTRL : LUT_DATA <= 16'h1002;
SET_ACTIVE : LUT_DATA <= 16'h1201;
// Video Config Data
SET_VIDEO+0 : LUT_DATA <= 16'h0080;// Force PAL input only mode.
SET_VIDEO+1 : LUT_DATA <= 16'h0701;// Enable PAL autodetection only.
SET_VIDEO+2 : LUT_DATA <= 16'h1001;// Slow down digital clamps.//////
SET_VIDEO+3 : LUT_DATA <= 16'h1500;// Set CSFM to SH1.//////
SET_VIDEO+4 : LUT_DATA <= 16'h1741;// Stronger dot crawl reduction./
SET_VIDEO+5 : LUT_DATA <= 16'h19fa;// Enable 28 MHz crystal.
SET_VIDEO+6 : LUT_DATA <= 16'h37a0;// TRAQ.
SET_VIDEO+7 : LUT_DATA <= 16'h3A16;// Power down ADC 1 and ADC 2.//////
SET_VIDEO+8 : LUT_DATA <= 16'h500a;// MWE enable manual window.
SET_VIDEO+9 : LUT_DATA <= 16'hc305;// BGB to 36.
SET_VIDEO+10 : LUT_DATA <= 16'hc480;// Set higher DNR threshold.
SET_VIDEO+11 : LUT_DATA <= 16'h0e80;// Man mux AIN6 to ADC0 (0101).
SET_VIDEO+12: LUT_DATA <= 16'h5020;// Enable manual muxing.
SET_VIDEO+13: LUT_DATA <= 16'h5218;// ADI recommended programming sequence. This sequence must be followed exactly when setting up the decoder.
SET_VIDEO+14 : LUT_DATA <= 16'h58ed;// Recommended setting.
SET_VIDEO+15 : LUT_DATA <= 16'h77c5;
SET_VIDEO+16 : LUT_DATA <= 16'h7c93;
SET_VIDEO+17 : LUT_DATA <= 16'h7d00;
SET_VIDEO+18 : LUT_DATA <= 16'hd048;
SET_VIDEO+19 : LUT_DATA <= 16'hd5a0;
SET_VIDEO+20 : LUT_DATA <= 16'hd7ea;
SET_VIDEO+21 : LUT_DATA <= 16'he43e;
SET_VIDEO+22 : LUT_DATA <= 16'he93e;
SET_VIDEO+23 : LUT_DATA <= 16'hea0f;
SET_VIDEO+24 : LUT_DATA <= 16'h0e00;