|
EDA365欢迎您!
您需要 登录 才可以下载或查看,没有帐号?注册
x
本帖最后由 Annhu 于 2009-10-26 16:08 编辑 - c, F2 l Z3 E$ Y0 I H2 H
6 U/ l! ^/ Q. O$ J2 a
:) 下面的程序是一款CCD的驱动程序,clk1=2MHZ,enable主要是控制sh的周期是10us还是10ms icg的周期不变始终为10ms,delay用于控制sh、icg的延时0.5us。编译错误见最下方,小弟把clk和enable的位置换了一下即先判断clk1上升沿然后在判断enable问题就解决了,麻烦高手帮忙看一下这到底是什么原因呢?还有j就是程序的代码有没有可以优化的地方呢,谢谢大家!. C6 N0 W+ j" t5 c& a
--CCDshixu
) N K% A4 B% [6 t& _LIBRARY IEEE; N3 Q: {+ W) e- r, h$ g
USE IEEE.STD_LOGIC_1164.ALL;
$ v/ `6 R& W9 n& g) L: QUSE IEEE.STD_LOGIC_UNSIGNED.ALL;
& ?3 h& ]1 e- tentity divclk is + |# R3 q) W$ {+ |: e; @
port(clk: in std_logic;; B* k- \# n- y
start:in std_logic;% }; _& N0 F* Z1 E! d/ `2 B
enable:in std_logic_vector(1 downto 0);
3 t% f# k" j D! X o_m_clk out std_logic;
$ p7 e4 r$ s- I& S- q4 T2 B3 a o_sh,o_icg out std_logic;
. r' C% k& k8 b+ u8 e& B stop out std_logic);( F: J% S* q3 _2 P* Q, y: J
end divclk;
- X4 K* T I9 g1 j4 Darchitecture behave1 of divclk is
6 J3 P: K4 p) K% @( _3 X7 |constant halftime :std_logic_vector(3 downto 0):="0101";
8 U/ X- ?' H1 Ysignal divcounter: std_logic_vector(3 downto 0);--shizhong fenpinjishu9 G/ ?) |/ R1 P! N+ _/ U8 p
signal shcounter : std_logic_vector(13 downto 0);--tiaozheng sh zhouqi he zhan kong bi7 ]$ w. u7 `/ M- w2 j0 _1 e
signal icgcounter :std_logic_vector (14 downto 0);--tiao zheng icg zhouqi he zhan kong bi+ X# p7 {* t5 e: B/ X! N8 e4 a
signal delay :std_logic_vector(1 downto 0);--shixian ICG/SH de mai chong jian ge
4 l" x' B& r+ @signal clk1: std_logic;# V/ Q1 }. ]7 m7 ?" u) S* q
begin
% ?9 n: r0 J8 Z( j; ~+ [8 c. CP1:process(clk,start)--24MHZ,12fenpin
5 u9 n0 T- ]9 L! a, b) x2 c begin
4 G, Y+ L. R0 O# p% u: N) h if start='1' then0 S5 M3 q8 t! y
clk1<='0';1 E/ Q' m9 Q- U7 i k
divcounter<="0000";
o5 g$ V4 s; G+ p/ H' p7 O! f elsif clk'event and clk='1' then
% @1 q# k6 H# w' B* F, I if divcounter = halftime then
! R& ?1 D' T/ I; d# i& z* b clk1 <= not clk1;
7 L1 V* U. M, q divcounter <= "0000";3 J: D; S1 m `/ J$ r7 y
else 4 O" K) J( P. X2 [4 n# m( I: S
divcounter <= divcounter + 1;
+ L5 ~& C2 F0 H( s9 I" ]! E' M% [ end if; g7 @0 v1 r6 }3 g
end if;
+ S0 |& |% y F: p. ]5 }; o$ m o_m_clk <= clk1;% l. F9 f' U( u8 L
end process P1;
$ B4 e* ~) i6 C) |, m& `. Z3 mP2:process(clk1,start,enable)* [9 t: k+ v' k/ O
begin
" [4 G% X# H) G5 s7 u4 T if start = '1' then/ ~8 n! A8 d, s
delay <="00";
8 m: T p9 b1 j- w shcounter <= "00000000000000";1 J1 N3 d0 p& d8 N2 `# C
icgcounter <= "000000000000000"; - M3 A8 o: Z, z! F9 d
o_sh <= '0';; p4 w1 s0 D$ r; v& W5 i! D; `
o_icg <='1';4 F0 K% }3 [. P* |; ~% ?& K" p
stop <= '0';
- E& O- D9 r. N elsif enable = "01" then
! k$ c# P. c& u% J7 s9 k if clk1'event and clk1='1' then$ ~8 t( b [0 d0 `
if icgcounter <"100111000100000" then -- 20000分频产生10ms的周期; z% a+ p7 o2 m" T
icgcounter <= icgcounter +1;
9 C( w c2 \; k: J% `5 O if icgcounter <"000000000010100" then - `. D! l+ k4 }1 _" t, j$ S
o_icg <= '0'; . a' v. H% e& C; {5 C ?
else 7 C5 D7 R! m! n4 U y' Q
o_icg <= '1'; 5 g' y( W- R2 A" t! U8 D
end if;9 o$ J$ W+ l W& o7 Y5 n0 o% ?1 d
else
0 i( U/ _9 g! q* c: Q icgcounter <= "000000000000000"; 5 R5 F3 v; T) O5 M2 W/ l- }) w
stop<='1';
; n; j! v" W3 K: w; `! O end if;
( K+ y& H0 K0 g' L) ~% {; h if delay = "01" then
: U3 x6 y. r/ i) H! j6 g$ g delay <= "00";5 ~+ K& C" R4 F. H, }. Q9 z8 {
if shcounter < "00000000001001" then -- delay用于产生ICG、SH的脉冲间隔0.5us,10us SH3 c0 \6 P. ]6 }- j8 o; l4 x3 V* m5 W7 K
shcounter <= shcounter +1;2 t. E; ~' `- R( u1 i2 @7 H# v
if shcounter <"00000000000101" then o_sh <= '1';
$ o) e9 [3 l/ K# m6 L1 b ~ else o_sh <= '0';
* }4 S; o6 O6 O5 T end if; 5 K& h Z* L1 c* W9 N6 D
else6 `" _: D1 W" D, G4 z
shcounter<= "00000000000000";3 d: `% s( ~8 b0 C$ s! C
end if;3 u. l6 x5 O0 T4 v9 w( z9 {
else
. Q" X c# _! |! R# D delay <= delay +1;& D$ h5 X9 R) G. D1 ?
end if;
3 n2 Q O5 _1 q end if;
5 ~ }- f0 k$ b. y; x/ o8 e' ^ 7 h# r* a( ] j" i$ k2 F% u
elsif enable = "10" then
0 ?9 v8 z {% l; V' s- d. l3 ]2 t2 G if clk1'event and clk1='1' then* L: v3 l1 n# V) ~3 K, ]' `, \
if icgcounter <"100111000100000" then -- 10ms ICG" x7 ?8 p- S6 q1 J" g0 R$ u: ~
icgcounter <= icgcounter +1;
U) h( R+ P5 I9 I0 I! k: s if icgcounter <"000000000010100" then 7 b5 f' b3 n6 U0 h4 Q* d. ^
o_icg <= '0';
u$ R1 J' p, d4 ]8 Z! Z, r else
1 z9 q$ F# W( E; b& ^$ z$ b o_icg <= '1';
! J# x/ e5 P: G3 |0 i! c0 A v( J1 W end if;
2 D3 M0 |" r' I else
7 p; }3 h9 q B |# C- E* d icgcounter <= "000000000000000"; ! p0 [2 |7 [! M! g) h
stop<='1';7 H y# F. k( w0 X' C# f
end if;
# b7 D/ M4 Z# C9 D+ w if delay = "01" then, s5 l! H! K3 X: j2 s2 |4 s# m
delay <= "00";
& a; `+ N; u/ s if shcounter < "10011100010000" then -- 2次10000分频delay用于产生ICG、SH的脉冲间隔0.5us,10ms SH
2 h: B7 Z7 ]6 T- i6 z' s shcounter <= shcounter +1;* s6 X; t8 [) J8 d s
if shcounter <"00000000000101" then( [: D9 W! T7 ?( C/ R
o_sh <= '1';! C# i, F% ]! m: n
else/ ?: F, u2 R4 X, X- J: P
o_sh <= '0';
4 u, z: i" P: _* G8 c end if; 0 x: C7 Y, z6 @& j; j
else
* r* V& u+ p6 @6 W1 b7 I9 v shcounter<= "00000000000000";6 ?; W# m; g6 ^! k/ E
end if;
& |4 T+ J. Z6 v1 R5 E, I6 z else3 U5 K& _7 T- m
delay <= delay +1;
U( X7 L* v1 D7 ]" g/ d end if;
3 S7 }. u/ }$ F& h. e- g% k" g end if;2 q: ~% c: K# S2 u: a- X) O8 q
end if; ) d! n* t% w' `( W
end process P2;0 ~6 j! m2 P2 U1 C+ y, w! V
end behave1;
6 ?# z1 }( A5 z7 IError (10821): HDL error at divclk.vhd(42): can't infer register for "stop" because its behavior does not match any supported register model
& L2 U& }# z' }( h3 [0 {7 S; x; 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
3 O* K7 v" U' M# N k1 o/ b x8 kError (10821): HDL error at divclk.vhd(42): can't infer register for "o_sh" because its behavior does not match any supported register model
( ?3 Z! @3 @- |5 Z1 tError (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[0]" because its behavior does not match any supported register
, p+ W4 N& a ]% Zmodel2 H7 b; \6 r8 N8 {5 G4 y- y: i
Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[1]" because its behavior does not match any supported register
7 @7 K B- U2 r R) [" X& }+ T% Cmodel; U& G* q8 Y! E. S/ N
Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[2]" because its behavior does not match any supported register
$ p3 L7 C' [! W) s0 g' c/ Lmodel/ T0 R7 g/ e& z* ^4 X
Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[3]" because its behavior does not match any supported register 5 J5 v- l/ N/ W5 J. K s, W
model
Z/ Y# m$ H3 y' Y. m( YError (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[4]" because its behavior does not match any supported register 2 Y1 a* S. [: _" f2 F
model
% [. G8 t8 o! p" kError (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[5]" because its behavior does not match any supported register 5 u* |5 U$ V( }! r0 o y( w
model
' X2 `3 E1 I8 W' [+ t4 ?6 V" ]Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[6]" because its behavior does not match any supported register 1 q% ~6 W- q% N- E7 i, p
model" |5 M3 L1 ?4 Z1 h: A, g
Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[7]" because its behavior does not match any supported register ( {5 X9 ?6 ?, Z4 h7 m
model
4 N3 L0 }) `/ ~Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[8]" because its behavior does not match any supported register
r' i* V# t7 ~0 I7 f/ Qmodel
5 w0 q6 i ?. H ]1 O& r( HError (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[9]" because its behavior does not match any supported register 5 Q+ p3 K; w2 C1 k: r
model
; J4 U% c& h1 }/ r" K- M5 @. UError (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[10]" because its behavior does not match any supported register 3 u7 U2 l2 G# O6 S" v# l
model7 `" c8 [3 ^3 y9 D9 T
Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[11]" because its behavior does not match any supported register
) H6 h6 Z$ Y! Y- D) Dmodel0 m; j: m1 i/ V, Z3 B- q
Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[12]" because its behavior does not match any supported register
0 _$ q- u; X' F9 Z, b% z nmodel
8 P7 |0 l5 L- h b$ dError (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[13]" because its behavior does not match any supported register
, T+ z7 Z; n. N, I: m" {- bmodel% w. H4 S2 v. \ R
Error (10821): HDL error at divclk.vhd(42): can't infer register for "icgcounter[14]" because its behavior does not match any supported register
, G C+ D5 e4 y1 q; o/ h; Pmodel
# G9 M; A8 o9 L# f* e) `; L2 uError (10821): HDL error at divclk.vhd(42): can't infer register for "shcounter[0]" because its behavior does not match any supported register
3 B3 l0 k( T% {4 O1 Kmodel
1 `) I+ W) `+ C3 BError: Can't elaborate top-level user hierarchy |
|