完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
设计要求40秒倒计时,到10秒的时候发出SOS的警示信号,不知道为什么到最后SOS的警示信号一直发不出来,求各位大神指教,帮我修改一下~~~~代码如下
module led_rxd(clk,rst_n,SOS_En_Sig,led,led_seg); input clk,rst_n; output [7:0]led; output [5:0]led_seg; output SOS_En_Sig; parameter seg_num0=8'hc0, seg_num1=8'hf9, seg_num2=8'ha4, seg_num3=8'hb0, seg_num4=8'h99, seg_num5=8'h92, seg_num6=8'h82, seg_num7=8'hf8, seg_num8=8'h80, seg_num9=8'h90; parameter seg_en0=6'b111110, seg_en1=6'b111101, seg_en2=6'b111011, seg_en3=6'b110111, seg_en4=6'b101111, seg_en5=6'b011111; reg [26:0]count; reg [3:0] count1; reg [3:0] count2; reg [7:0] led_reg; reg [5:0] led_seg_reg; always@(posedge clk or negedge rst_n) if(!rst_n) count<=27'd0; else if(count==27'd49_999_999) count<=27'd0; else count<=count+1'b1; wire clk_div=(count==27'd49_999_999); always@(posedge clk_div or negedge rst_n) if(!rst_n) begin count1<=4'd0; count2<=4'd4; end else if((count1==4'd0)&&(count2==4'd0)) begin count1<=4'd0; count2<=4'd4; end else if(count1==4'd0) begin count2<= count2-1'b1; count1<=4'd9; end else count1<=count1-1'b1; reg [26:0]count_1ms;// always@(posedge clk or negedge rst_n) if(!rst_n) count_1ms<=27'd0; else if(count_1ms==27'd49_999) count_1ms<=27'd0; else count_1ms<=count_1ms+1'b1; wire clk_dis=(count_1ms==27'd49_999);// // reg [1:0]state; always@(posedge clk_dis or negedge rst_n) if(!rst_n) begin led_reg<=8'hff; led_seg_reg<=6'b111111; state<=2'b00; end else if(state==2'b00) begin state<=2'b01; led_seg_reg<=6'b111101; case(count2) 4'd0: led_reg<=seg_num0; 4'd1: led_reg<=seg_num1; 4'd2:led_reg<=seg_num2; 4'd3: led_reg<=seg_num3; 4'd4: led_reg<=seg_num4; 4'd5: led_reg<=seg_num5; 4'd6: led_reg<=seg_num6; 4'd7: led_reg<=seg_num7; 4'd8: led_reg<=seg_num8; 4'd9: led_reg<=seg_num9; default: led_reg<=seg_num0; endcase end else if(state==2'b01) begin state<=2'b00; led_seg_reg<=6'b111110; case(count1) 4'd0:led_reg<=seg_num0; 4'd1:led_reg<=seg_num1; 4'd2:led_reg<=seg_num2; 4'd3:led_reg<=seg_num3; 4'd4:led_reg<=seg_num4; 4'd5:led_reg<=seg_num5; 4'd6:led_reg<=seg_num6; 4'd7:led_reg<=seg_num7; 4'd8:led_reg<=seg_num8; 4'd9:led_reg<=seg_num9; default:led_reg<=seg_num0; endcase end //蜂鸣器部分 reg isEn; reg [27:0]count3; always@(posedge clk or negedge rst_n) if(!rst_n) begin isEn<=1'b0; count3<=28'd0; end else if((count2==0)&&(count3==28'd149_999_999)) begin isEn<=1'b1; count3<=1'b0; end else begin isEn<=1'b0; count3<=count3+1'b1; end assign led=led_reg; assign led_seg=led_seg_reg; assign SOS_En_Sig=isEn; endmodule |
|
相关推荐 |
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1600 浏览 1 评论
1366 浏览 0 评论
矩阵4x4个按键,如何把识别结果按编号01-16(十进制)显示在两个七段数码管上?
1577 浏览 0 评论
933 浏览 0 评论
2376 浏览 0 评论
1477 浏览 37 评论
5684 浏览 113 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-27 09:24 , Processed in 0.515325 second(s), Total 67, Slave 51 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号