找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

巢课
电巢直播8月计划
查看: 118|回复: 0
打印 上一主题 下一主题

各位大神,请进来看看,急急急~~~

[复制链接]

2

主题

2

帖子

21

积分

二级会员(20)

Rank: 2Rank: 2

积分
21
跳转到指定楼层
1#
发表于 2016-4-13 10:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您!

您需要 登录 才可以下载或查看,没有帐号?注册

x
              各位大神此设计有什么毛病吗,能麻烦你们帮我指出来吗?
4 X- i8 K7 ~9 R/ P  设计要求,40秒倒计时,9秒之后3秒一次的SOS警示,我调试之后蜂鸣器不响,怎么回事,跪求大神指教!!!!
) m' v# x. X8 A8 W" umodule led_rxd(clk,rst_n,SOS_En_Sig,led,led_seg);3 L. h+ a/ n& e; T; J$ N
input clk,rst_n;0 ?6 ~) B! G: M
output [7:0]led;4 {1 Q$ ]) u* {2 l& G: l- I
output [5:0]led_seg;* E+ k7 N; d( J
output SOS_En_Sig;
% R0 s( N; {: l( A+ bparameter seg_num0=8'hc0,$ I8 {# ?4 g$ G* \+ X  ~7 x1 K
          seg_num1=8'hf9,
% ]! L- e$ `4 W, ?4 M7 k# _    seg_num2=8'ha4,; z7 ?# t' j, t: b0 g0 V) Q* Y, A! G& X
    seg_num3=8'hb0,, R" Y* j* `; f4 S
    seg_num4=8'h99,1 l+ v- p& w) p. j
    seg_num5=8'h92,
% }$ h9 I1 I# J/ w0 d    seg_num6=8'h82,
( G- O; e( T; ]' p/ a, t: F    seg_num7=8'hf8,
1 ^# w0 z: m. V6 J9 l& ~    seg_num8=8'h80,- y) G5 D2 M5 ?, O) ^
    seg_num9=8'h90;! ^, V. Z7 l5 J# [- r! q
parameter seg_en0=6'b111110,* a2 |; m3 U8 e' \
          seg_en1=6'b111101,
4 D9 S. L4 G1 Q    seg_en2=6'b111011,
, m+ e" y! h3 @    seg_en3=6'b110111,
( C; P: y9 d0 [7 G    seg_en4=6'b101111,; V0 w. R7 f, ^: X  Y: c8 ?
    seg_en5=6'b011111;7 o3 j- [9 ]8 F) r, N2 d9 q0 z$ w6 y
reg [26:0]count;% n' |9 W! T  R( j$ v
reg [3:0] count1;
  R- G$ _. i7 Jreg [3:0] count2;& [5 O. s* v9 I, a, `" _
reg [7:0] led_reg;
  W( u1 X4 F# U6 {reg [5:0] led_seg_reg;$ U) a& K" Y8 C+ }  X+ z1 p4 F1 p1 S! B
always@(posedge clk or negedge rst_n)- W/ g8 D1 P* g3 E( q9 H
if(!rst_n) count<=27'd0;7 t8 V! L4 |+ Z8 i
else if(count==27'd49_999_999) count<=27'd0;7 K8 @$ y0 O; n- F
else count<=count+1'b1;
1 p  [$ m  q, `. |, ]wire clk_div=(count==27'd49_999_999);1 N. |. E$ d9 s" l- j8 ^* g
always@(posedge clk_div or negedge rst_n)
" l8 r, ^* L2 V( l5 K& h* Tif(!rst_n)
* Z& `& m( I3 j* D& U1 cbegin
, `% M( j! g4 m9 |9 G# T. ecount1<=4'd0;+ z/ `0 O" K; X1 Q
count2<=4'd4;  m# a& p, ~+ U% y' N4 X4 O
end, \/ u4 D' [0 {
else if((count1==4'd0)&&(count2==4'd0))
! \' d; l+ f1 ?* t+ j' Sbegin$ q3 s7 x2 L* G# u: X. R
count1<=4'd0;
. @; ?! k1 X; ~& h% z  U: vcount2<=4'd4;
% a" K- B, B8 o- B4 lend( [  D( b  c' `0 F, k2 Q3 ]
else if(count1==4'd0)2 v' q! g7 n) y9 f# h: j
begin
! A  L, d& o, G3 Icount2<= count2-1'b1;( ^' n" H3 G+ v2 `
count1<=4'd9;
  g' |) E6 \5 B" o' d. W/ n& r8 g$ ?- cend
2 X, p9 s! Z, [else count1<=count1-1'b1;
- Z! h, T8 u" l: k4 f' mreg [26:0]count_1ms;//
5 n( |: I7 l( ?$ |0 j3 Ealways@(posedge clk or negedge rst_n): f; ~3 M3 M4 B5 z* Y
if(!rst_n) count_1ms<=27'd0;  ( m$ |! Y3 f% V" r4 y: }7 X
else if(count_1ms==27'd49_999) count_1ms<=27'd0;% S, C) N% m* A& V9 P/ }9 G( x
else count_1ms<=count_1ms+1'b1;, l$ ~# o! B3 H- V
wire clk_dis=(count_1ms==27'd49_999);//# W2 V/ y+ v! a4 j# _3 P/ r6 Z
//8 U$ m- Z1 `. j2 H5 I
reg [1:0]state;0 u) J4 s' o7 R) R* m
always@(posedge clk_dis or negedge rst_n)
$ R7 C) k& U  zif(!rst_n)
, T, v# V# q! b& Kbegin
. e3 Q) @$ `( R7 c% \* q! D: Uled_reg<=8'hff;6 f) d. R) a+ o+ r7 w& t
led_seg_reg<=6'b111111;
2 A. {$ s) e) H: m) j: cstate<=2'b00;" H3 R! x7 b- Z, A8 m4 O! y1 ?
end; j& m) w. l; \
else if(state==2'b00)
/ ?2 N' ~1 C  ?& t! H0 Kbegin
$ [; y+ j1 b4 {5 R) v1 t$ gstate<=2'b01;
7 X! M) f7 k' b5 rled_seg_reg<=6'b111101;
, K- E2 B: v) d8 G* j; Lcase(count2)
/ c9 U) g- w. N4'd0: led_reg<=seg_num0;  
% P% F! j" _  Y' t, B7 b2 x4'd1: led_reg<=seg_num1;  1 x9 @2 d) Y" F3 N2 m! _
4'd2:led_reg<=seg_num2; 6 Z& c: `$ `# G, e- I! ^
4'd3: led_reg<=seg_num3;  9 u7 M. f; c/ M9 [# K
4'd4: led_reg<=seg_num4;  5 |: j+ J' B# n8 s" L& H
4'd5: led_reg<=seg_num5;  ; a% C1 r8 N1 g
4'd6: led_reg<=seg_num6;  ; t& x6 ~3 C) {" x' `
4'd7: led_reg<=seg_num7;    @' d. X7 {6 `; u
4'd8: led_reg<=seg_num8;   # M3 ?) j' I  Z( A: H5 P
4'd9: led_reg<=seg_num9;  7 S% a/ V* m- M4 ^% N, P
default: led_reg<=seg_num0;  
& V3 L) l% a: P% a) D7 Mendcase2 A* w+ Z- }6 v. r( z
end, l* n4 c$ [$ c4 ^# G8 _9 ?1 H( G
else if(state==2'b01)8 n0 p8 v) R; _  Z: r
begin   q+ ^7 Y9 g1 c8 F) X& L
state<=2'b00;
# @( ?+ t  c. G' Eled_seg_reg<=6'b111110;; o5 `8 V' i* k" J5 F
case(count1)
/ O4 |- ^2 ~8 c  [4 G* y% @4'd0:led_reg<=seg_num0;
% Z( Z; x0 }( U/ e0 x& R+ y4'd1:led_reg<=seg_num1;
! z3 w9 O6 k" y, g4'd2:led_reg<=seg_num2;3 h. E) V" m+ A6 q! k
4'd3:led_reg<=seg_num3;$ d. C: U4 r7 w( M+ t3 N& C
4'd4:led_reg<=seg_num4;
4 K: }3 n6 [: C. q( `4'd5:led_reg<=seg_num5;6 R4 [2 J$ Y/ [, Y; P* x
4'd6:led_reg<=seg_num6;* ^3 {: i% g( ^" N# T# n
4'd7:led_reg<=seg_num7;+ G  _& H% m; V6 n% l0 b: u$ S' ~( {
4'd8:led_reg<=seg_num8;
6 j) o1 S0 q7 W: u4'd9:led_reg<=seg_num9;
: R1 K, U  R4 sdefault:led_reg<=seg_num0;
2 w4 V, `; Z6 U, P7 m, Oendcase+ x& }" g3 L; }6 R1 j3 v* R' r
end
1 B3 ]) R5 S' areg isEn;
8 `7 u$ Z& ~/ G3 z  G* T- rreg [27:0]count3;
1 M. T" L9 K* V0 T' T- l% ~always@(posedge clk or negedge rst_n)# M/ H$ P6 E/ b0 x9 B9 {$ M3 P* H
if(!rst_n)8 B# W" B8 y! B  n
begin
& G: ?  ]$ c- \7 D( h1 misEn<=1'b0;3 Q- E. w# M! w4 d
count3<=28'd0;5 g* p7 y! o: \
end
8 g7 w! T( m9 _2 G6 ~else if((count2)&&(count3==28'd149_999_999))5 w! _5 E' K! w# w; G8 T9 e
begin! b# q3 h  I$ s( j
isEn<=1'b1;
2 w1 P8 ^5 I3 }% c$ Z! R* N: R2 u3 kcount3<=1'b0;
% Y8 Z+ c& ]3 g1 Oend, d0 @; }* y1 D+ v9 F
else
' e" k3 l& Z2 @" kbegin
3 U7 F4 @7 S& I+ }8 |; L* uisEn<=1'b0;/ Q, a, y2 n8 C/ F
count3<=count3+1'b1;- F7 h4 b5 c8 K. r) N6 ^+ O
end
3 X1 v) s  w: w8 aassign led=led_reg;) J3 P  ^$ b0 {: d
assign led_seg=led_seg_reg;
/ r6 z7 t  R3 g# bassign SOS_En_Sig=isEn;) ]% q/ J9 f- |* v. o0 W0 ?
endmodule' ]& k, v5 T" T0 ]1 F8 {
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 支持!支持! 反对!反对!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

巢课

技术风云榜

关于我们|手机版|EDA365 ( 粤ICP备18020198号 )

GMT+8, 2024-11-23 16:20 , Processed in 0.063580 second(s), 32 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

快速回复 返回顶部 返回列表