|
Dear all8 k% o* M- X# O k! M2 H
小弟最近用VHDL在power pc平台上第一次設計一顆CPLD去控制整塊板子,+ F7 g8 Z7 L$ E+ Y; x' E
裡面包含的功能有power/reset/LED control, hardware watchdog, ?5 y0 c5 p# h8 F+ l6 Y
slide switch/push button detect, CPLD to CPU interrupt event,0 D( Q1 B. X# l
CPU read/write CPLD register這些功能,
6 ?$ Y9 k% O# A# ]! S7 ~/ y在開發時,為了能夠快速的看一些裡面定義signal的狀態,
) X c3 j. f2 t4 O' e$ a就在外面接了7顆chip type LED做debug用,
1 |8 ^7 x5 w0 y- ~/ g4 N3 J而這7顆LED是拿來看slide switch/push button以及interrupt狀態,
' Y! D4 S; @8 x8 c& f而slide switch/push button只要有動作都會發interrupt給CPU,0 \* e/ Y( T i
這些功能都一一完成並且「各別」驗證後,才全部組合在同一個.vhd檔,
$ h. ]' ]+ |& F/ w0 x" E/ W- n0 v( l而slide switch/push button的interrupt event "AND"起來後,7 l# y; k; j& f {, q
再指到CPLD nINT pin,如 nINT <= nSLIDE_INT and nPUSH_INT;
# S( o, W c5 n+ K- D r只要這兩個功能的process同時compile,nINT在high or low level,8 T- r- F' ?+ {0 g- v
有機會發生抖動,或是有時會發生無法將nSLIDE_INT or nPUSH_INT拉high或low,# R8 t: ]3 o6 t$ h$ t
但各別把各自的process mark起來不compile就會正常," d) w2 X4 |1 X3 _1 w
在修改code以後,已經有解決這問題或應該算是改善吧,
1 |' I( A' j; P0 ^' l6 @ B因為更重要的問題來了,我把debug LED拿掉,
9 A9 d$ s+ i! @% @& N! U" F這兩個要發給CPU的interrupt功能就出問題,9 n N2 J+ V! J- M' d
只要把debug LED的東西留在code裡面,就正常了,3 V1 T& ]- n f4 _
不知道板上個各位前輩有遇過這樣的問題嗎?2 c' b1 z% j# V# k* ]
! C; ?( h9 u! F J* G) t
example:. {3 w3 O( z3 _' S1 h) c
......
! }4 X) y4 ^3 Q' }4 a! O3 \port(6 U8 c4 {; |( J
nINT : std_logig;
* S- c+ }, `- e3 A# b0 mLED_S : std_logic;, _0 I3 {5 }. w
LED_P : std_logic
$ Z C& R( s- T6 X);2 I+ o9 y, z* v, J" o
......
/ b( d4 ? I9 R4 ]signal nSLIDE_INT, nPUSH_INT, LED_INT, LED_SLIDE, LED_PUSH : std_logic;) C# a, R# |! R# c
......
& c3 z3 {7 V* s \# {$ I. ?/ ebegin
! U3 A4 F* T' u. Z# onINT <= nSLIDE_INT and nPUSH_INT;6 y# ?1 n& t2 _, A/ i
LED_INT <= LED_SLIDE and LED_PUSH;
) y+ G) T, k3 Z: y4 ]LED_SLIDE <= nSLIDE_INT;
* R1 {$ X+ M B& G1 H4 h. k/ _; Y: f! \LED_PUSH <= nPUSH_INT;7 z# T4 D" X% E5 q
......
( e! r3 m. z) H+ N3 ](包含的process如下): n: z( f0 A i5 U
power control process
- v1 U/ P9 {; @+ S+ @* @: K" q8 H+ F; Yreset control process' _% k; {/ q, \" o2 l! A
watchdog process
# ? Q5 |1 A4 a9 }) n, X# H) sread process( @0 s/ H0 w% Q/ q
write process7 L `( @' t: D) V. O& R1 b2 F% n
slide switch detect and de-bouncing process
$ X% Z, H: p& `/ O- i# K G: l! opush button detect process% y! x P4 M; T N; B4 f) C
slide switch interrupt event process
) Y1 z5 x8 o1 @7 W" m2 kpush button interrupt event process8 x- G2 d2 }8 @ T- \
......
\/ L; M9 k2 i) ?! H
( |0 h/ i8 d5 f2 z' l+ |, L6 j現在的code上面的寫法已經正常,: |7 m" q" X. A, u/ y
但是只要把這三行都mark起來,
2 s" c' a {5 u/ _* ]& CLED_INT <= LED_SLIDE and LED_PUSH;
4 C2 d: q0 ^) ^7 FLED_SLIDE <= nSLIDE_INT;$ z% _6 g; j4 b8 E2 W5 `! v/ L
LED_PUSH <= nPUSH_INT;: E8 q8 y, M3 l, F
整個code動作就不正常了!
1 H: P! r9 w: g) `2 J9 m我是用Altera EPM570 -5ns那顆來做,8 d: ]+ _$ W& m, V1 o
不知道說這麼多有沒有表達清楚,其實有很多問題想請教,
( l6 j( o% E+ v5 |. `9 {7 i+ y不過還是希望能夠先把這問題解決!
0 r# n0 I! m+ Y: e希望各位能給小弟一些建議,謝謝! |
|