|
請教各位前輩一下:7 a* p; R+ w. a" ?; y
小弟目前要在 t5 的狀態機下做六次的話,& A, a" z' y4 H! ~) \1 @/ S% W
讓它在t6 的地方判斷,如果大於六就做 t7,
% T, z0 b7 Q8 }+ k& X' I不然就一直跳回 t5,這種寫法是否有誤呀?
+ J5 C5 ?3 B% U3 X+ ^- e, b因為他一直狂讀n筆資料進來,不受我的t6控制?5 ?* E2 m0 S& F
+ d% ]) c/ G: z. M$ s4 y N4 I6 r
麻請前輩們不吝指導一下,這個問題困擾小弟好久了," d7 L s! F0 b" m
試了好多天,都是一樣的結果,感謝再感謝。
& k C& N# `1 J3 w Y+ ?1 }2 T: m
" T. [/ Z* C/ j ~! e0 B, awhen t5 => -- read LSB (lo-byte), send acknowledge, sent stop
) @ K# q4 n0 G9 P3 Z3 z if (cmd_ack = '1') then
" H: l7 ^! H' ~) R9 ~/ }# J nxt_state :=t6;8 L) v7 _# w4 }# k
if (lack = '1') then
" ]# x! |! \4 g$ G/ A- o6 D ierr := '1'; -- no acknowledge received from last command, expected ACK
& i8 m2 \5 [: D$ [8 V4 n: T. n! j end if;+ ]% @6 ]$ v" a9 ?% Y0 Z
istart := '0';, @: e" g. `3 q/ q" T# K- H
iread := '1';6 M; V+ v2 L2 t; G- _
iwrite := '0';
( R& |9 h( S: e- p/ s) B+ W iack := '0'; --NACK Q A, [- q( _) k# S" T" n
istop := '0';+ z; ]! Q4 S N @' |
END IF; 6 h E0 a. Y) A& s' J
when t6 => . ?1 G) R$ _8 |
if (counter_i >= 6) then4 a# L8 K3 X& i6 j7 E5 a( ?8 ?
counter_i <= 0; 1 V8 r+ K& M3 m
nxt_state :=t7;
1 B+ A+ C6 O* H; X& b* l' @ else Q& E" T1 `) P' i
counter_i <= counter_i + 1 ; 9 ?: v' H0 G2 j
end if;
3 a$ R, L! v8 Q8 R) J if (counter_i < 6 ) then 0 y3 K& s- L F: d" ~
nxt_state := t5;, v, q y1 R4 W) _6 M' J9 A" z
end if;
7 g) T V# G8 U+ G2 A ( x7 T" {; U7 m1 ?8 z5 C
when t7 => -- read LSB (lo-byte), send acknowledge, sent stop4 x. D. v0 \- E. Y( y
istart := '0';
* C) ^. e( V3 u( Q6 X5 @% P$ N; b# ] iread := '1';
& \: ^8 R% s9 L) K8 Z) J5 Y6 } iwrite := '0';
5 O |" L2 E6 _8 ~+ h/ w iack := '1'; --NACK) r7 }) l7 \& Z: t3 ]' S5 ^
istop := '1'; / ?6 Z0 g' i4 l
istore_dout := '1'; |
|