完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
使用PMOD键盘,扫描并且在七段数码管显示,综合正确,但是下载后结果不对,可能与几个warnings 有关系,但是我不懂如何消除 。求大神指导
module keyscan(clk, rst_n, keyscan, keyin, real_number);///////////////////////////////////////////////////////////////////////////////// input clk,rst_n; input[3:0] keyin; output[3:0] keyscan; output reg[4:0] real_number; reg[3:0] state; reg[3:0] four_state; reg anykeypress; reg[4:0] numberout,number_reg,number_reg1;// reg[3:0] scancode; reg[3:0] scan_state; assign keyscan = scancode; always@(posedge clk or posedge rst_n) // part 1 : 状态机,确定是哪一行数据 if(rst_n) begin scancode <= 4'b0000; scan_state <= 4'b0000; end else if(anykeypress) // 有健按下 case(scan_state) 4'b0000 : begin scancode <=4'b1110 ; scan_state <= 4'b0001 ; end // 状态机 跳变 4'b0001 : begin scancode <= {scancode[0],scancode[3:1]} ; end // 状态依靠移位实现 endcase else /// initial state begin scancode<= 4'b0000; scan_state <= 4'b0000; end always@(posedge clk ) // part 2 : 检测按键是否按下 if(!(&keyin)) // begin anykeypress <=1; four_state<= 4'b0000; // end else /// fourstate 就是用来延时一下 if(anykeypress) case(four_state) 4'b0000 : begin anykeypress <= 1 ;four_state <= 4'b0001; end // 4'b0001 : begin anykeypress <= 1 ;four_state <= 4'b0010; end 4'b0010 : begin anykeypress <= 1 ;four_state <= 4'b0100; end 4'b0100 : begin anykeypress <= 1 ;four_state <= 4'b1000; end 4'b1000 : begin anykeypress <= 0 ; end /// ? default : anykeypress <= 0; endcase else four_state <= 4'b0000; always@(posedge clk) // 利用扫描码和输出值确定按下的键盘值 casex({scancode,keyin}) //x 代表无关项 8'b0111_1110 : numberout <= 5'd0; 8'b1011_1110 : numberout <= 5'd1; 8'b1101_1110 : numberout <= 5'd2; 8'b1110_1110 : numberout <= 5'd3; 8'b0111_1101 : numberout <= 5'd4; 8'b1011_1101 : numberout <= 5'd5; 8'b1101_1101 : numberout <= 5'd6; 8'b1110_1101 : numberout <= 5'd7; 8'b0111_1011 : numberout <= 5'd8; 8'b1011_1011 : numberout <= 5'd9; 8'b1101_1011 : numberout <= 5'd10; 8'b1110_1011 : numberout <= 5'd11; 8'b0111_0111 : numberout <= 5'd12; 8'b1011_0111 : numberout <= 5'd13; 8'b1101_0111 : numberout <= 5'd14; 8'b1110_0111 : numberout <= 5'd15; default:numberout <= 8; /// mistakes ... endcase always@(posedge clk or posedge rst_n) // part4 : 寄存数值 if(rst_n) number_reg <= 0; else number_reg <= numberout; always@(posedge clk or posedge rst_n) /// part5 :消除抖动 if(rst_n) state<=4'b000; else case(state) // 按键消除抖动 ,不记录按键时间低于15的按键值 4'd0:begin number_reg1 <= number_reg; state <= 4'd1 ; end 4'd1: begin if(number_reg == number_reg1) state <= 4'd2; else state <= 4'd0; end 4'd2 : begin if(number_reg == number_reg1) state <= 4'd3; else state <= 4'd0; end 4'd3 : begin if(number_reg == number_reg1) state <= 4'd4; else state <= 4'd0; end 4'd4 : begin if(number_reg == number_reg1) state <= 4'd5; else state <= 4'd0; end 4'd5 : begin if(number_reg == number_reg1) state <= 4'd6; else state <= 4'd0; end 4'd6 : begin if(number_reg == number_reg1) state <= 4'd7; else state <= 4'd0; end 4'd7 : begin if(number_reg == number_reg1) state <= 4'd8; else state <= 4'd0; end 4'd8 : begin if(number_reg == number_reg1) state <= 4'd9; else state <= 4'd0; end 4'd9 : begin if(number_reg == number_reg1) state <= 4'd10; else state <= 4'd0; end 4'd10 : begin if(number_reg == number_reg1) state <= 4'd11; else state <= 4'd0; end 4'd11 : begin if(number_reg == number_reg1) state <= 4'd12; else state <= 4'd0; end 4'd12 : begin if(number_reg == number_reg1) state <= 4'd13; else state <= 4'd0; end 4'd13 : begin if(number_reg == number_reg1) state <= 4'd14; else state <= 4'd0; end 4'd14 : begin if(number_reg == number_reg1) state <= 4'd15; else state <= 4'd0; end 4'd15:begin if(number_reg == number_reg1) begin state <= 4'd0; real_number <= number_reg;// 数据传输 end else state <= 4'b0000; end default: state <= 4'b0000; endcase endmodule warning: WARNING:Xst:1710 - FF/Latch WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch WARNING:Xst:2404 - FFs/Latches WARNING:Xst:2404 - FFs/Latches WARNING:Xst:2404 - FFs/Latches WARNING:Xst:2404 - FFs/Latches |
|
相关推荐
2个回答
|
|
求助啊
|
|
|
|
这个应该是没有设置初始值,后面用了并且赋值了的话就没问题。
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
基本FPGA或者树莓派或者其它微处理器(尽量压缩成本且完成项目)DFB激光器稳频
1397 浏览 1 评论
2498 浏览 1 评论
助力AIoT应用:在米尔FPGA开发板上实现Tiny YOLO V4
1198 浏览 0 评论
3645 浏览 1 评论
3259 浏览 0 评论
2317 浏览 58 评论
6163 浏览 113 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-31 15:58 , Processed in 0.629476 second(s), Total 74, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号