verilog HDL基础程序(8)

2019-04-09 20:32

4'b1011: begin scan_key<=6; end 4'b0111: begin scan_key<=7; end endcase 4'b1011: case(column) 4'b1110: begin scan_key<=8; end 4'b1101: begin scan_key<=9; end 4'b1011: begin scan_key<=10; end 4'b0111: begin scan_key<=11; end endcase 4'b0111: case(column) 4'b1110: begin scan_key<=12; end 4'b1101: begin scan_key<=13; end 4'b1011: begin scan_key<=14; end 4'b0111: begin scan_key<=15; end endcase default: scan_key<=15; endcase end end

always@(scan_key) begin

case(scan_key) 4'b0000: dataout<=8'b11000000; 4'b0001: dataout<=8'b11111001; 4'b0010: dataout<=8'b10100100; 4'b0011: dataout<=8'b10110000; 4'b0100: dataout<=8'b10011001; 4'b0101: dataout<=8'b10010010; 4'b0110: dataout<=8'b10000010; 4'b0111: dataout<=8'b11111000; 4'b1000: dataout<=8'b10000000; 4'b1001: dataout<=8'b10010000; 4'b1010: dataout<=8'b10001000; 4'b1011: dataout<=8'b10000011; 4'b1100: dataout<=8'b11000110; 4'b1101: dataout<=8'b10100001; 4'b1110: dataout<=8'b10000110; 4'b1111: dataout<=8'b10001110; endcase end

endmodule 秒表 数码管显示

//程序的思想和我们用的51单片机的思想一样 //视频教程适合我们21EDA电子的所有学习板 module watch(clk,out_wei,out_duan,rst,key2); input rst; input clk; input key2; output [5:0]out_wei;

//key2==27pin

output [7:0]out_duan;

reg [5:0]out_wei=6'b000000;

reg [7:0]out_duan=8'b00000011; //a b c d e f g dp reg [4:0]count; reg [3:0]count1; reg [14:0]count2;

reg [7:0]sec_l=8'b00000011; //zero at first reg [7:0]sec_h=8'b00000011; reg [7:0]fen_l=8'b00000011; reg [7:0]fen_h=8'b00000011; reg [7:0]msec_l=8'b00000011; reg [7:0]msec_h=8'b00000011; reg [3:0]s_1=0; reg [3:0]s_2=0; reg [3:0]s_3=0; reg [3:0]s_4=0; reg [3:0]s_5=0; reg [3:0]s_6=0; reg clk_out; reg pause;//信号

always@(posedge clk) begin //fenpin if(count2==25000) begin //one of thousand secend count2<=0; clk_out<=~clk_out; end else count2<=count2+1; end

always@(posedge clk_out) begin //scan count<=count+1'b1; case(count) 1 :begin out_wei<=6'b111110; out_duan<=msec_l; end 3:begin out_wei<=6'b111101; out_duan<=msec_h; end 6:begin out_wei<=6'b111011; out_duan<=sec_l; end 9:begin out_wei<=6'b110111;

25000 out_duan<=sec_h; end 12:begin out_wei<=6'b101111; out_duan<=fen_l; end 15:begin out_wei<=6'b011111; out_duan<=fen_h; end 18:count<=0; endcase end

always@(negedge key2) begin pause<=~pause; end

always@(posedge clk_out or negedge rst) begin //minite secend if(!rst) begin s_1<=0; s_2<=0; s_3<=0; s_4<=0; s_5<=0; s_6<=0; end else if(count1==10)begin //if 1s l+1 count1<=0; if(s_6==9) begin s_6<=0; if(s_5==9) begin s_5<=0; if(s_1==9) begin s_1<=0; if(s_2==5) begin s_2<=0; if(s_3==9) begin s_3<=0; if(s_4==5) s_4<=0; else s_4<=s_4+1; end else s_3<=s_3+1; end else s_2<=s_2+1; end else s_1<=s_1+1;

end else s_5<=s_5+1; end else s_6<=s_6+1; end else if(pause==1) begin count1<=count1+1; end end

//这下面全部是扫描显示用的。 always@(s_1 or s_2 or s_3 or s_4 or s_5 or s_6) begin case(s_1) 0:sec_l=8'b11000000; 1:sec_l=8'b11111001; 2:sec_l=8'b10100100; 3:sec_l=8'b10110000; 4:sec_l=8'b10011001; 5:sec_l=8'b10010010; 6:sec_l=8'b10000010; 7:sec_l=8'b11111000; 8:sec_l=8'b10000000; 9:sec_l=8'b10010000; default:sec_l=1'bx; endcase case(s_2) 0:sec_h=8'b11000000; 1:sec_h=8'b11111001; 2:sec_h=8'b10100100; 3:sec_h=8'b10110000; 4:sec_h=8'b10011001; 5:sec_h=8'b10010010; 6:sec_h=8'b10000010; default:sec_h=1'bx; endcase case(s_3) 0:fen_l=8'b11000000; 1:fen_l=8'b11111001; 2:fen_l=8'b10100100; 3:fen_l=8'b10110000; 4:fen_l=8'b10011001; 5:fen_l=8'b01001001; 6:fen_l=8'b10010010; 7:fen_l=8'b10000010; 8:fen_l=8'b10000000; 9:fen_l=8'b10010000;


verilog HDL基础程序(8).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:冲孔灌注桩专项施工方案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: