马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
1 module CCD_Capture (
2 oDATA,
3 oDVAL,
4 oX_Cont,
5 oY_Cont,
6 oFrame_Cont,
7 iDATA,
8 iFVAL,
9 iLVAL,
10 iSTART,
11 iEND,
12 iCLK,
13 iRST
14 );
15
16 input [9:0] iDATA;
17 input iFVAL;
18 input iLVAL;
19 input iSTART;
20 input iEND;
21 input iCLK;
22 input iRST;
23 output [9:0] oDATA;
24 output [10:0] oX_Cont;
25 output [10:0] oY_Cont;
26 output [31:0] oFrame_Cont;
27 output oDVAL;
28 reg Pre_FVAL;
29 reg mCCD_FVAL;
30 reg mCCD_LVAL;
31 reg [9:0] mCCD_DATA;
32 reg [10:0] X_Cont;
33 reg [10:0] Y_Cont;
34 reg [31:0] Frame_Cont;
35 reg mSTART;
36
37 assign oX_Cont = X_Cont;
38 assign oY_Cont = Y_Cont;
39 assign oFrame_Cont = Frame_Cont;
40 assign oDATA = mCCD_DATA;
41 assign oDVAL = mCCD_FVAL&mCCD_LVAL;
42
43 always@(posedge iCLK or negedge iRST)
44 begin
45
if (!iRST)
46 mSTART <= 0;
47
else
48 begin
49
if (iSTART)
50 mSTART <= 1;
51
52
if (iEND)
53 mSTART <= 0;
54 end
55 end
56
57 always@(posedge iCLK or negedge iRST)
58 begin
59
if (!iRST)
60 begin
61 Pre_FVAL <= 0;
62 mCCD_FVAL <= 0;
63 mCCD_LVAL <= 0;
64 mCCD_DATA <= 0;
65 X_Cont <= 0;
66 Y_Cont <= 0;
67 end
68
else
69 begin
70 Pre_FVAL <= iFVAL;
71
if (({Pre_FVAL,iFVAL}==2'b01) && mSTART)
72 mCCD_FVAL <= 1;
73
else
if ({Pre_FVAL,iFVAL}==2'b10)
74 mCCD_FVAL <= 0;
75
76 mCCD_LVAL <= iLVAL;
77 mCCD_DATA <= iDATA;
78
79
if (mCCD_FVAL)
80 begin
81
if (mCCD_LVAL)
82 begin
83
if (X_Cont<1279)
84 X_Cont <= X_Cont + 1;
85
else
86 begin
87 X_Cont <= 0;
88 Y_Cont <= Y_Cont + 1;
89 end
90 end
91 end
92
else
93 begin
94 X_Cont <= 0;
95 Y_Cont <= 0;
96 end
97 end
98 end
99
100 always@(posedge iCLK or negedge iRST)
101 begin
102
if (!iRST)
103 Frame_Cont <= 0;
104
else
105 begin
106
if (({Pre_FVAL,iFVAL}==2'b01) && mSTART)
107 Frame_Cont <= Frame_Cont+1;
108 end
109 end
110
111 endmodule 希望得到高人的指点 |