|
reg state;
* ^1 ?' Q) p0 j1 W& [assign sram_cs = 1'b0;: z0 y, E& F8 I/ b0 q
assign sram_data =we?8'hz:wirte_data;
3 {" {: e- Q R2 Palways @(posedge clk or negedge rst)
% F: R+ a) Z+ L: v" T- hif(!rst)
- [0 ]. s% q3 l$ S/ d clk <= 1'b1;
6 c' x( A `3 Zelse i4 H% b) n) W0 l* O
state <= ~state;% D% @" i: o8 b9 K1 j2 s: Z5 n: Y
+ q2 |; O5 f) ?8 d( palways @(posedge clk or negedge rst)
5 ~, t' m% V# T: Z8 F9 C8 }; bif(!rst)
/ r$ S! M0 f; b! h' F; k& S begin
7 h2 J' R( ]! o o s1 ^: X end
. ]! G) U- C3 t" \& R$ s6 Eelse
% s- r) m) Y( V begin
+ q/ s: u+ N- b; F* g9 b% { if(state ) //读,) `& l* J; r3 y) ]0 C+ g: ?# x- S
begin
2 g3 M% ~3 T; o6 K! r9 }3 ? sram_addr <= read_addr;
7 \7 U: b5 y7 J5 R% a) j* L sram_we <= 1'b1;
; c0 F& p# h# Q( [' J sram_oe <= 1'b1;+ z/ x7 |( g) p$ n5 }( X: j
end; W% O h" F0 e( t' ]
else
5 W6 }! I7 p, e/ }8 r1 V( p begin //写
- O2 c- G! |" D# M3 U5 ~, E7 ?" V- a read_data <=sram_data ) J9 d) n& Q% @ E- M4 d
sram_addr <= write_addr;. x1 [9 b2 t$ e& o" I5 s- M
write_data <= video_data;
9 r) e2 a" |8 D8 ^ sram_we <= 1'b0;5 Z1 X$ H- U9 R
sram_oe <= 1'b0; Z1 h m- }) N' x1 Q
end
( X0 g/ ]' F5 z; m. A/ { end2 L0 t5 Q) n( l! U2 }# d" l7 [3 s
" A( G# ^: R6 j: O+ g/ k& r
6 U3 `7 V) F u. \" v4 A6 g7 N& @: N" Q! b
' i- ?, y9 Z2 f {% h; Lendmodule |
|