失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 七段LED数码管显示译码器设计

七段LED数码管显示译码器设计

时间:2019-10-16 00:38:38

相关推荐

七段LED数码管显示译码器设计

包含按键输入并显示模块,输入为四位16进制信号,同步在led数码管显示,如果没有输入,则自动脉冲计数

module led(comscan,clr,k,kon,kc,o,comscanout);

input clr,kon;

input [3:0]k;

input [3:0]kc;

input comscan;

output reg [7:0]o;

reg [31:0]counter;

reg [3:0]show;

reg [7:0]clk0;

reg [15:0]temp;

reg clk;

output reg [2:0]comscanout;

always @(posedge comscan)

begin

comscanout[2:0]=comscanout[2:0]+1'b1;

end

always @ (posedge clk)

begin

if (!clr)

counter[31:0]=counter[31:0]+1'b1;

else

counter[31:0]=1'b0;

end

always @(posedge comscan)

begin

case(comscanout[2:0])

3'b000:begin

if (!kon) show[3:0]=counter[3:0];

else

if(kc[0]==1)

begin

show[3:0]<=k[3:0];

temp[3:0]<=k[3:0];

end

else

show[3:0]<=temp[3:0];

end

3'b001:begin

if (!kon)

show[3:0]<=counter[7:4];

else if (kc[1]==1)

begin

show[3:0]=k[3:0];

temp[7:4]=k[3:0];

end

else

show[3:0]=temp[7:4];

end

3'b010:begin

if (!kon)

show[3:0]<=counter[11:8];

else if (kc[2]==1)

begin

show[3:0]=k[3:0];

temp[11:8]=k[3:0];

end

else

show[3:0]=temp[11:8];

end

3'b011:begin

if (!kon)

show[3:0]<=counter[15:12];

else if (kc[3]==1)

begin

show[3:0]=k[3:0];

temp[15:12]=k[3:0];

end

else

show[3:0]=temp[15:12];

end

3'b100:show[3:0]<=counter[19:16];

3'b101:show[3:0]<=counter[23:20];

3'b110:show[3:0]<=counter[27:24];

3'b111:show[3:0]<=counter[31:28];

endcase

begin

if (clk0[7:0]==8'b1111_1111)

begin

clk=~clk;

clk0[7:0]=8'b0000_0000;

end

else

clk0[7:0]=clk0[7:0]+1'b1;

end

end

always @(1)

begin

case(show[3:0])

4'b0000:o[7:0]<=8'h3f;

4'b0001:o[7:0]<=8'h06;

4'b0010:o[7:0]<=8'h5b;

4'b0011:o[7:0]<=8'h4f;

4'b0100:o[7:0]<=8'h66;

4'b0101:o[7:0]<=8'h6d;

4'b0110:o[7:0]<=8'h7d;

4'b0111:o[7:0]<=8'h07;

4'b1000:o[7:0]<=8'h7f;

4'b1001:o[7:0]<=8'h6f;

4'b1010:o[7:0]<=8'h77;

4'b1011:o[7:0]<=8'h7c;

4'b1100:o[7:0]<=8'h39;

4'b1101:o[7:0]<=8'h5e;

4'b1110:o[7:0]<=8'h79;

4'b1111:o[7:0]<=8'h71;

endcase

end

endmodule

tance 转载标明出处

如果觉得《七段LED数码管显示译码器设计》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。