|
EDA365欢迎您!
您需要 登录 才可以下载或查看,没有帐号?注册
x
各位大神此设计有什么毛病吗,能麻烦你们帮我指出来吗?
1 S/ R/ m+ ?7 X% m2 X4 y 设计要求,40秒倒计时,9秒之后3秒一次的SOS警示,我调试之后蜂鸣器不响,怎么回事,跪求大神指教!!!!
5 t2 j" S2 x& {module led_rxd(clk,rst_n,SOS_En_Sig,led,led_seg);5 h( Z2 D: s! P. H# o6 {0 H
input clk,rst_n;* S; a# U9 i! k: y, k x
output [7:0]led;4 |5 B/ n+ ]( V0 @. h9 m
output [5:0]led_seg;
/ E; P& Z E, n) soutput SOS_En_Sig;, Y V% D" o% S2 H
parameter seg_num0=8'hc0,0 s- j, c( Y* K- f+ V. o* G
seg_num1=8'hf9,
3 T1 F3 j x4 O seg_num2=8'ha4,
, f$ F4 Y+ t# a2 ^: R seg_num3=8'hb0,
! u' a; j/ F& F: H* d7 j S# | seg_num4=8'h99,
) k' J1 j, r* e. K) D: Z. S seg_num5=8'h92,
( n) Q& _$ g2 E; @- x# @* C: r9 P seg_num6=8'h82,
/ ?# r! y D# V) y seg_num7=8'hf8,
/ @* W' q* V' w- Q* p5 O9 ?9 _ seg_num8=8'h80,
& D) F" b- p' b4 g/ M; Y* \# E seg_num9=8'h90;( k$ o5 M$ t1 g) G* B
parameter seg_en0=6'b111110,
, g( Y) D: e) k7 g$ s: s seg_en1=6'b111101,0 M9 g) b D- A7 o# e( a# i. a9 F
seg_en2=6'b111011,6 S) L% `) e2 W) u* p* f3 H, u) D3 M
seg_en3=6'b110111,0 q( K" K. x9 x, l8 {% x
seg_en4=6'b101111,2 Q% H+ K3 h- s7 f0 J
seg_en5=6'b011111;
3 ^$ q+ e5 p; _reg [26:0]count;3 U+ e! O6 Q: J9 _6 l3 I
reg [3:0] count1;- t# b8 E- s* G8 W
reg [3:0] count2;/ N( }+ n* S, R' L2 }4 h
reg [7:0] led_reg;
( C% t' J, m& vreg [5:0] led_seg_reg;
3 B# i; c! s- u; c" balways@(posedge clk or negedge rst_n)
. O/ l/ V$ Y+ @% B; x# R7 U) xif(!rst_n) count<=27'd0;
. P, {0 z ?" H* Relse if(count==27'd49_999_999) count<=27'd0;' E2 f7 W Z, M! Z+ Q
else count<=count+1'b1;) d2 S+ U* M. h; C
wire clk_div=(count==27'd49_999_999);
- f( u9 ]7 N _/ A/ ^always@(posedge clk_div or negedge rst_n)
% \. Z8 w8 o/ R3 l7 Dif(!rst_n)
6 e3 D$ b8 h) @0 U' Kbegin4 f5 h# `: f% J. r* I4 x6 p+ U5 P
count1<=4'd0; f" M% a8 s3 B5 s
count2<=4'd4;, E3 k8 W6 X' U6 t6 K
end- n2 r! a4 X# d) U
else if((count1==4'd0)&&(count2==4'd0))
9 J0 P3 n! M: S0 u P; G8 Tbegin: X& ^0 \: x3 ]4 P+ @
count1<=4'd0; # Y+ Y. `% n& X
count2<=4'd4;
2 m* ~6 B1 L' ]- v2 }7 kend
. E6 K" Q1 R- g l8 `2 Yelse if(count1==4'd0)
, i6 I7 [+ z, j: a; v# \( c0 i' Qbegin
2 }$ n" ?8 y1 w4 C& pcount2<= count2-1'b1;, E9 h1 ?- B8 [( V
count1<=4'd9;0 |- E a& o; Q( g
end% c3 G& v0 y, G# P9 I
else count1<=count1-1'b1;
" Q6 x" |; s, a2 W3 I2 }, \6 creg [26:0]count_1ms;//
# O, @8 K! v/ q5 u/ K E* yalways@(posedge clk or negedge rst_n)& Q, A" u8 d- ], ~# L1 x) D- _
if(!rst_n) count_1ms<=27'd0;
2 @$ ~% w0 u( E5 U: Qelse if(count_1ms==27'd49_999) count_1ms<=27'd0;+ s8 J# B$ f. ~: w8 F. {- o! k. N: X
else count_1ms<=count_1ms+1'b1;
/ G6 W, K2 n6 y3 h- d8 [* `' Dwire clk_dis=(count_1ms==27'd49_999);//
1 _) k6 B; V6 W. X4 W( e9 B8 @//
! i* K0 y5 x ]1 E6 Nreg [1:0]state;
4 y& W7 H. l% j; U9 P! h3 C1 \2 R; e! zalways@(posedge clk_dis or negedge rst_n)
4 f# i$ |' P+ _- xif(!rst_n)3 b# a5 ~$ _ D; u- b
begin4 J2 I9 X2 e# ^
led_reg<=8'hff;
5 _ u* L4 _% `0 ^+ Uled_seg_reg<=6'b111111;: P, t7 c6 W' S- D; V: @, c8 x
state<=2'b00;$ H. W2 j8 K1 d& G, ]
end9 a3 D i" S; m5 }$ @) l
else if(state==2'b00) 9 P, z; n1 B l& \
begin
0 B2 l2 Y1 O* g I* Lstate<=2'b01;
; p* z2 B7 ^* ^; Z2 G( dled_seg_reg<=6'b111101;
( \7 q. E% [# l- r9 Wcase(count2)4 \$ A* b0 Q7 j l1 q: ]' P' f
4'd0: led_reg<=seg_num0; 7 ~( E& m) M* Z3 Z
4'd1: led_reg<=seg_num1;
" V0 b7 m' s- V1 l7 o! ]4'd2:led_reg<=seg_num2;
0 |: d4 |9 f [6 R' v4'd3: led_reg<=seg_num3;
$ B$ L& [' B k# e, x o4'd4: led_reg<=seg_num4; 2 G! U/ \) n+ U4 q" O- u# Y- L
4'd5: led_reg<=seg_num5;
! D( S) a, H" W9 R, z: t0 v7 P4'd6: led_reg<=seg_num6; # F1 V1 F# h$ C; O) G) C4 Z
4'd7: led_reg<=seg_num7; . g2 f M9 o. m
4'd8: led_reg<=seg_num8;
. ~6 I' g! E3 Q# I# C4'd9: led_reg<=seg_num9;
$ }0 ]- X& S# ?4 ~- e2 x* i0 _* tdefault: led_reg<=seg_num0;
4 X! r6 o' O5 T/ Jendcase1 R( h3 _" y3 K& [
end% A" v3 W% b) C
else if(state==2'b01)7 F7 [! @: L8 P0 N( D, \
begin
; B+ ~0 G% y8 n1 N1 u% o9 z2 N% Mstate<=2'b00;1 U8 G8 ~& X1 h& X, e* X4 R; y6 e! m0 X
led_seg_reg<=6'b111110;
, o- u& g* w- j. Jcase(count1)
, m# k I- l- E5 i+ ~4'd0:led_reg<=seg_num0;
# |) \# X2 H. _; I5 b. I4'd1:led_reg<=seg_num1;
, w$ g% Y6 Q5 o5 E! I# ]& B8 A4'd2:led_reg<=seg_num2;( i" e4 w; M) L7 s$ |
4'd3:led_reg<=seg_num3;
, _( k3 B! s; l/ e2 M1 o; R4'd4:led_reg<=seg_num4;' R: }6 M7 `# ~6 b& {
4'd5:led_reg<=seg_num5;, i: M' f( M7 h) E9 O, r& F K
4'd6:led_reg<=seg_num6;: h. g0 Q0 a, O0 O0 O+ L
4'd7:led_reg<=seg_num7;2 e1 o% k& ~- ?& o& Z+ H
4'd8:led_reg<=seg_num8;7 I; O0 ]! ]7 ?1 m6 x$ e; m' m
4'd9:led_reg<=seg_num9;
/ I: m( w; B! T4 A8 E' b8 ]2 |default:led_reg<=seg_num0; [3 L" ?8 p- n2 t4 l
endcase
- _- Q) f4 B3 T: Tend
2 e# ^1 u9 d) j8 a# D" P' vreg isEn;1 W: F" j+ O/ [
reg [27:0]count3;0 A$ G9 A! ^- d- S
always@(posedge clk or negedge rst_n)6 ]6 w6 v/ y2 ]/ [+ h& G. F2 L* U5 i* `
if(!rst_n)
" @/ _( v: F$ J- I( fbegin
" T. R. i1 U. W K4 lisEn<=1'b0;4 y& c4 c! F' U( F6 s2 a
count3<=28'd0;
$ O! J5 y3 V! t9 u' f+ @end7 z7 x& b5 {7 f- b% L2 W- U
else if((count2)&&(count3==28'd149_999_999))/ ~9 r3 U/ k. h* M$ P. q n3 {
begin
" G4 [9 S( b, c+ L% YisEn<=1'b1;$ v! O, j. r p" w
count3<=1'b0;
# f- w/ y0 F$ R4 g0 m/ }0 yend
1 T Z; c) R+ k3 t3 @9 g; ^else% F7 h1 p. r% h+ v+ x1 }
begin
' B) d6 z1 m6 d. I, B% U2 ^- xisEn<=1'b0;" P9 Z* I; y; b0 \7 _- I, T
count3<=count3+1'b1;4 N- Z* [6 w8 {/ q7 t
end% {% B" T2 p% S. V3 v. H
assign led=led_reg;
0 l9 h! }) B @# L' N9 V$ bassign led_seg=led_seg_reg;
* T) a4 Q' ^0 h3 [6 Y1 _- J9 Vassign SOS_En_Sig=isEn;
1 D" H1 ?6 X$ c# ?3 J7 Uendmodule c! o- C, H, ]) J
|
|