|
EDA365欢迎您!
您需要 登录 才可以下载或查看,没有帐号?注册
x
本帖最后由 Annhu 于 2009-10-26 16:08 编辑
3 }( F# c Z. }9 T& b: }7 \, [
5 c8 I0 m# I8 i' z+ p4 f:) 下面的程序是一款CCD的驱动程序,clk1=2MHZ,enable主要是控制sh的周期是10us还是10ms icg的周期不变始终为10ms,delay用于控制sh、icg的延时0.5us。编译错误见最下方,小弟把clk和enable的位置换了一下即先判断clk1上升沿然后在判断enable问题就解决了,麻烦高手帮忙看一下这到底是什么原因呢?还有j就是程序的代码有没有可以优化的地方呢,谢谢大家!
+ r( x' t2 j5 x$ T; v--CCDshixu
7 j1 W* `' \. @% BLIBRARY IEEE;4 @% _8 X: i- O( n" p: U
USE IEEE.STD_LOGIC_1164.ALL;
3 i" `! I5 ~, t% j# V% FUSE IEEE.STD_LOGIC_UNSIGNED.ALL;0 T" y; b7 M) G2 U
entity divclk is
. B- c M# f2 o port(clk: in std_logic;
2 l- o7 [ E8 R6 L: l& B) t4 m start:in std_logic;4 N2 V q$ ~ l& o+ R
enable:in std_logic_vector(1 downto 0);7 [( w8 B9 h V/ p
o_m_clk out std_logic;
% |7 H' x! t5 J3 C2 v o_sh,o_icg out std_logic;
3 f5 p# a- ^6 A# w stop out std_logic);
" N" `* f: U3 P% Tend divclk;
7 ?" m# z) D5 k- B' w3 N. g+ Varchitecture behave1 of divclk is
2 ]' p. c0 r$ I- T' {( vconstant halftime :std_logic_vector(3 downto 0):="0101";; J7 g: {0 Z% h$ X
signal divcounter: std_logic_vector(3 downto 0);--shizhong fenpinjishu1 f" g1 _/ J' Q6 Z4 W0 l0 ^
signal shcounter : std_logic_vector(13 downto 0);--tiaozheng sh zhouqi he zhan kong bi
' z( S- |& ~) q( I9 P5 |signal icgcounter :std_logic_vector (14 downto 0);--tiao zheng icg zhouqi he zhan kong bi
) C; k. \. y0 W9 M$ |+ @: tsignal delay :std_logic_vector(1 downto 0);--shixian ICG/SH de mai chong jian ge
: {7 x# r; ?: M! b( F" Xsignal clk1: std_logic;
" _3 z/ i, P" ?8 P/ K8 X9 y* ?begin
( f6 j5 H! p( g' B8 BP1:process(clk,start)--24MHZ,12fenpin
* s! h7 H4 X' W begin
M$ c& M x. \% y9 H if start='1' then0 {1 D t6 Y. K- w8 ]" l7 J
clk1<='0';& R/ Z j/ I- w
divcounter<="0000"; ; N3 I% j5 X9 P8 d* P/ A
elsif clk'event and clk='1' then1 d1 ]0 |, J& g2 s$ a( `& R
if divcounter = halftime then5 |' u; g; j& _0 C8 l, `
clk1 <= not clk1;
, y% K4 p k& Q% ], b divcounter <= "0000";
8 ]! f! k' D; P% o! ` else 6 A9 X+ u2 Z* C) r5 p
divcounter <= divcounter + 1;
3 \- n8 f- d4 w' f8 P2 Q. u C. M2 B end if;$ n, Y9 I6 h1 z) M! ]2 A
end if;
. D& }2 b; _5 |' ^+ N; D/ | o_m_clk <= clk1;
+ C4 C& m; G6 P5 i+ T5 m$ [; ^ end process P1;' a C. k& x% h" W
P2:process(clk1,start,enable)
7 K" V8 J6 m, sbegin4 C# s9 O O, x4 R# w
if start = '1' then0 P0 B+ z, @) I. x3 ~
delay <="00";
# \# N+ a' Z. f2 o3 W shcounter <= "00000000000000";
$ I' u1 X* a$ J- S# c icgcounter <= "000000000000000";
; }) ~" D) v1 W8 v$ F" q o_sh <= '0';
8 { [9 y; i5 K( D0 |& Q, l o_icg <='1';' G% K& R. n( l5 y4 F; B
stop <= '0';) B$ t0 m3 v, s8 {
elsif enable = "01" then
, i2 u; u* R$ W if clk1'event and clk1='1' then4 j$ u( N% H% u/ V5 s
if icgcounter <"100111000100000" then -- 20000分频产生10ms的周期
, m/ y: C( z/ Z- m- u- @) | icgcounter <= icgcounter +1;- ~, J+ T* X8 K
if icgcounter <"000000000010100" then 3 [" r& U a* l% a
o_icg <= '0';
. m: F0 }- C- O0 Z; j else
" z! s8 ]1 f9 P- ^2 I. i4 J+ ? o_icg <= '1';
9 P6 N/ k5 c" B+ f3 b end if;
. Q& h6 o0 q) }% [ else 1 L1 a3 Y' Q9 z$ B
icgcounter <= "000000000000000"; , `" n8 b! ]: Q" q4 s
stop<='1';# D$ Y# y: v, t- v
end if;
+ \# Z; c8 U/ {( X: | if delay = "01" then2 ?- E0 {: v# t% ^1 s
delay <= "00";
1 W( j2 W' B9 p: m$ l if shcounter < "00000000001001" then -- delay用于产生ICG、SH的脉冲间隔0.5us,10us SH. C' X! v; n( s! j1 k1 ]& T
shcounter <= shcounter +1;% j2 ~ w- D9 H/ ] U7 k
if shcounter <"00000000000101" then o_sh <= '1';
8 m# s% ^/ _3 r8 T, a- G c- q' | else o_sh <= '0'; ) M" v$ {7 H$ b6 v. K
end if;
. J2 G% w. e* \9 @ else5 G( o% e5 }9 L) q
shcounter<= "00000000000000";
2 ?% z# U+ ^1 M. t, ^: j: y end if;
- F8 r& C$ m1 S6 y. Z, h% C else
9 s# i' U/ T1 _4 x! M delay <= delay +1;5 b2 D2 H) Y) x+ r
end if;
2 f+ i1 t5 l$ M3 F5 U( F end if;
) i2 t; y$ d+ m# u; }( h( q
% Z/ j! a5 ?* S- ~ elsif enable = "10" then1 n! c0 g# c" y
if clk1'event and clk1='1' then0 g% f/ z. ~, b1 G
if icgcounter <"100111000100000" then -- 10ms ICG$ q1 [5 F- E; v- l
icgcounter <= icgcounter +1;0 M" h+ ?9 l/ w% }
if icgcounter <"000000000010100" then
4 k: E5 [! H8 ^" |* _+ Q o_icg <= '0'; 4 Q v4 @: {; U
else
0 C# E9 l: B' r o_icg <= '1';
1 t9 U! O7 g/ K0 N2 ~ end if;( }9 w" q' R! o1 z
else
7 f6 }4 f5 O8 |# ~- F icgcounter <= "000000000000000"; ) Q# E+ {1 x, x7 B- _) r
stop<='1';
1 M' v9 ?& g# l end if;# p8 q5 Y' ?- R0 u4 t! l
if delay = "01" then# Y# r) U* X4 O
delay <= "00";6 l- @9 a9 |4 z" o& [
if shcounter < "10011100010000" then -- 2次10000分频delay用于产生ICG、SH的脉冲间隔0.5us,10ms SH
" T' P; L3 [- \! r8 }2 w5 Y* c shcounter <= shcounter +1;
1 S, f8 P3 W! S* l) T if shcounter <"00000000000101" then2 b; ^5 T! d9 {' r' g- N
o_sh <= '1';% _4 ~, M. r$ W
else
+ F; T! O) r: Z" K. b; N o_sh <= '0'; 9 q3 N' |9 J& d
end if; ; M" H, K3 B7 T; L
else3 p" s, _6 p! c2 z
shcounter<= "00000000000000";, T h7 K2 F. ?( H
end if;
# g. U: M+ o! T8 p r: ] else
1 E1 J+ L, }* p) a& c5 F2 e# f( N4 W delay <= delay +1;) l1 p4 [2 |% _6 v: z x
end if;
9 n5 V9 n$ |$ m: p& f& _8 x end if;" U& y, B3 g5 Y3 [
end if;
! ~+ L: A3 {5 C0 B end process P2;/ o7 @! A; q( e
end behave1;! Y1 v; A8 }% o" d
Error (10821): HDL error at divclk.vhd(42): can't infer register for "stop" because its behavior does not match any supported register model
" z4 b5 y" n8 o/ iError (10821): HDL error at divclk.vhd(42): can't infer register for "o_icg" because its behavior does not match any supported register model
1 n( H0 ?# [% n. BError (10821): HDL error at divclk.vhd(42): can't infer register for "o_sh" because its behavior does not match any supported register model. U- M- r) ~2 Q% n: g; L' T' O& a0 r
Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[0]" because its behavior does not match any supported register " s9 r% P+ J$ V8 F9 q$ g
model( X8 M- N* v& T1 e
Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[1]" because its behavior does not match any supported register
9 X; D& q5 I$ {" x$ c. s1 bmodel
/ u2 B7 |( l, w0 A: aError (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[2]" because its behavior does not match any supported register
5 n( t: D/ q7 {2 ~! N: p) r+ Umodel- Y" l( h: e- R: U/ o1 v2 U
Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[3]" because its behavior does not match any supported register
. W! |( J2 `" omodel
K" R) Y- \1 h* h/ p( T: \$ hError (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[4]" because its behavior does not match any supported register
$ m$ ^! x$ I8 F4 p# \: }model% G4 @: E2 |) |7 f9 V
Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[5]" because its behavior does not match any supported register
. b5 @% o' H* m$ u" u! X7 dmodel
& S: l7 S9 M: ~Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[6]" because its behavior does not match any supported register ; O B; j' ^" F
model
) `) V6 W+ W: I/ H7 Q8 dError (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[7]" because its behavior does not match any supported register 6 D3 x2 b7 b* x; o$ Q" l. a
model7 S; J# l# Z" q8 K/ K5 X" a* q% B$ Z% N
Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[8]" because its behavior does not match any supported register
7 {( B9 t) B- E/ ^2 b0 \! Cmodel+ U v! K# u* [$ L1 A+ P
Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[9]" because its behavior does not match any supported register 1 q* H9 n0 c" i6 ^
model
4 c( s* f+ n3 Z0 T& H/ fError (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[10]" because its behavior does not match any supported register
. N' ~( ]$ P" Q+ y6 G# @5 [model: E- C$ `/ a* X. \" ~- h4 w9 a
Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[11]" because its behavior does not match any supported register 4 b: h, G8 A) b5 U- a8 _
model
+ j0 c5 o+ B& w( A* R- UError (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[12]" because its behavior does not match any supported register , p7 N1 C6 ]. i# A5 q" M1 F$ C
model
/ X3 I6 K4 V( c3 aError (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[13]" because its behavior does not match any supported register
1 Y ^ o6 G! B; M! i! ymodel
% L) t* @- ~/ R1 VError (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[14]" because its behavior does not match any supported register . |; T' ~* \7 F; z: i* x2 T
model
) G8 j' e5 A8 \3 U: ?Error (10821): HDL error at divclk.vhd(42): can't infer register for "shcounter[0]" because its behavior does not match any supported register 3 x3 `9 j: M$ {7 q/ r; G
model5 M) O+ v f3 |# E
Error: Can't elaborate top-level user hierarchy |
|