|
請教各位前輩一下:: ?/ f2 y1 h# c
小弟目前要在 t5 的狀態機下做六次的話,! j' Y+ s* g8 Y0 N' i- Q
讓它在t6 的地方判斷,如果大於六就做 t7,/ t) P3 g p% S
不然就一直跳回 t5,這種寫法是否有誤呀?
. w- n t0 t8 f+ x因為他一直狂讀n筆資料進來,不受我的t6控制?( o6 F3 O5 C0 E' Q; J7 B/ ~
' S5 o9 T' x+ h4 q; e% O
麻請前輩們不吝指導一下,這個問題困擾小弟好久了,
& N% j7 K, @" E0 a$ c0 ]5 s; J試了好多天,都是一樣的結果,感謝再感謝。
6 {: }) C6 y Y% M+ T9 u) H/ d: r9 e! S% P6 F0 J6 U; A! \. ]
when t5 => -- read LSB (lo-byte), send acknowledge, sent stop
2 c. m1 e+ J8 c) L' _ if (cmd_ack = '1') then9 x d; f6 E% H1 m) D7 e% q. _
nxt_state :=t6;
4 w* S# ^, c) | l; C if (lack = '1') then
6 O {/ G, l9 D) }$ c' @6 S ierr := '1'; -- no acknowledge received from last command, expected ACK; E) _0 N/ O9 g. t* W
end if;' g2 j( y4 D$ a6 U7 U' ?
istart := '0';
z$ F$ A( `. u, T9 \ iread := '1';
( e) R5 ?3 D O8 [8 k iwrite := '0';
" L3 Y; r& ~+ F9 H7 \ iack := '0'; --NACK
) s; S! ~# u* J5 }/ V e' q* E istop := '0';& r% m' }$ x% G9 ?/ u: U$ _
END IF; ! G3 M7 S/ o( b9 ?, g ^2 a/ B' A
when t6 =>
# i) B1 R$ n2 q6 |" P8 l8 ` if (counter_i >= 6) then
" |# t, N8 Q7 @9 k counter_i <= 0; 8 Z2 } W3 F, I8 @) X+ V% E/ v
nxt_state :=t7; 9 B2 N2 j6 U1 N7 H% I/ B6 m% ^2 b
else
' B% D' Y1 g; {6 b+ I# G, X2 j counter_i <= counter_i + 1 ; 3 T% d% O: d" D# A$ R
end if;
0 ^% n$ n% G* M* J if (counter_i < 6 ) then
# [+ U- N1 p( Q nxt_state := t5;
( u. P/ x: U/ B5 h end if;
4 J' S, T$ i, d" Y1 K
9 i" V) Q) C8 O4 ~ when t7 => -- read LSB (lo-byte), send acknowledge, sent stop: }) \8 n3 s) H* C- Z
istart := '0';# V6 h9 N5 P% S' s* A6 m
iread := '1';
' M! ?# I! b- A. g iwrite := '0';8 r% H6 ^+ s) S/ V% A1 x1 H
iack := '1'; --NACK2 A% O0 f- \5 k! w& |* O% m2 Q6 D
istop := '1'; - V% ~8 x8 @9 M) U- h7 f: p" _
istore_dout := '1'; |
|