|
6#
樓主 |
發表於 2009-1-10 22:13:00
|
只看該作者
- FWRITE: process (CLR, WCLK)
1 n9 L) w$ n6 z6 Z+ Z - begin
0 L( u7 l& J* E+ p" a - if CLR = '1' then
( `! o2 o$ [2 o4 X: P/ L - for INDEX in fmax downto 0 loop8 s5 a6 ?, c( H) K p5 {+ S
- fifo_array(INDEX) <= (others => '0');
0 o! q; |! C; y1 J. X" V - end loop;
1 |7 M, y2 a* T. I0 [ - WR_PTR <= 0;
7 R* y0 A2 D+ S. ~! p1 b - elsif rising_edge(WCLK) then! g7 i& g, f! u! V* ~
- if WE = '1' and count<depth then
6 x5 M& O9 ~' N; p( G. q: t - fifo_array(WR_PTR) <= DATA;0 A' J3 u4 e# _# W9 @2 G
- -- move pointer- h, c) p" o, U* Z$ n9 `
- if WR_PTR=fmax then & A3 ?$ a6 V% b5 y" ^3 G8 l
- WR_PTR <= 0; 8 n% U% _& i3 J! M- U1 T9 }$ a+ a+ c8 u
- else WR_PTR <= WR_PTR + 1;% N8 g" \, \4 ^2 z) T% p
- end if;" q, e- v `4 r
- end if;, a( z/ q5 ?; Y; b( e# J
- end if;- x$ ]& D6 v3 _1 S' e
- end process;) A) K/ P$ ?; m6 J
- FREAD: process (CLR, RCLK)
1 V$ x, N, P! |* c5 M! { - begin0 Q& h& T6 {( m) @5 r; O1 g j
- if CLR = '1' then6 ~, r$ c4 _* _4 I! M
- RD_PTR <= 0;! w" h: |( l) ?4 f/ r" w9 Z6 w
- elsif falling_edge(RCLK) then |6 J# f% _0 q W
- if RE = '1' and count>0 then
/ Z% V) g+ E/ e- G) _/ H2 t - Q <= fifo_array(RD_PTR);+ O7 ?' p' q+ p# C/ \
- -- move pointer 5 f6 t8 e! I; p& H+ B- m0 U
- if RD_PTR=fmax then
& R7 }8 g+ i7 `, z. \6 N ?% M - RD_PTR <= 0;
1 s. Q, O% x: {( w* R4 _$ H - else RD_PTR <= RD_PTR + 1;5 [4 H% M! E) z" r6 f2 L
- end if;# K, k1 C, P0 @# [
- end if;' D4 R9 r8 Z5 H
- end if;
2 T# Y) Z \' \: n* n, G - end process;1 b3 u2 s# ^# J+ p/ Y
- end architecture;
複製代碼 |
|