|
6#
樓主 |
發表於 2009-1-10 22:13:00
|
只看該作者
- FWRITE: process (CLR, WCLK)
6 m0 a" A: e3 J( A - begin5 D: R+ C; R& ?5 O) x* t! h! q0 @
- if CLR = '1' then
k. u$ Y* N1 `1 A, n6 Y - for INDEX in fmax downto 0 loop
: Q$ B2 ^# M& l - fifo_array(INDEX) <= (others => '0');
1 Q. I; g$ u. E# z3 w - end loop;" ]: B8 Y, a8 N* d6 [
- WR_PTR <= 0;
6 s* [8 r y, f) B, U( X - elsif rising_edge(WCLK) then
( t! t! R0 T9 o" g - if WE = '1' and count<depth then
- S" Z- F4 r M# ` - fifo_array(WR_PTR) <= DATA;! l% F' O, f/ n! T1 b! p3 [
- -- move pointer
r" Z8 j. q. ?( I; q/ v& \! p - if WR_PTR=fmax then
4 M' e8 _3 A! R: t8 h( k' Y - WR_PTR <= 0;
8 l# n, S# x' A \ - else WR_PTR <= WR_PTR + 1;
6 O! G7 D6 G2 U - end if;
" g7 L) F# l4 ^) l - end if;$ S+ w% ^' f2 \+ r" d& r6 c
- end if;
& o8 \. ?+ @- N5 _$ a$ l. L - end process;
; v6 R2 g" u. \2 x+ d - FREAD: process (CLR, RCLK)4 C3 M. \" z/ I! ?2 {+ g: l8 o
- begin
, _' }" }, l' R9 z: x - if CLR = '1' then
" M6 }' G6 w6 p. {: h6 ^ - RD_PTR <= 0;! l9 T K9 X+ |
- elsif falling_edge(RCLK) then
: j. O& [$ a3 n( W) t - if RE = '1' and count>0 then9 x: b3 h9 O7 \, T4 a+ E1 x
- Q <= fifo_array(RD_PTR);+ N1 T: x& b: j x- C9 r6 F
- -- move pointer
' a/ ?, }( V7 p. a1 y - if RD_PTR=fmax then
2 A7 I1 g9 ?5 A. d# ] - RD_PTR <= 0;
9 A5 C1 x0 Z3 Q9 s* J4 N" [ - else RD_PTR <= RD_PTR + 1;) H1 f( U/ X2 ~2 U- n
- end if;. m& Z' v+ `- q: i: O( k
- end if;
0 F! p7 I0 P# a$ q5 R" X - end if;0 ^4 D6 ?: V4 v- v: I' ?( m0 x% t1 @6 z
- end process;- ^0 d }$ j( I% j6 I9 C! L" x, A3 N
- end architecture;
複製代碼 |
|