【EDA】循环扫描显示的七段数码管译码控制电路的设计

🌵🌵🌵前言

✨你好啊,我是“ 怪& ”,是一名在校大学生哦。
🌍主页链接:怪&的个人博客主页
☀️博文主更方向为:课程学习知识、作业题解、期末备考。随着专业的深入会越来越广哦…一起期待。
❤️一个“不想让我曾没有做好的也成为你的遗憾”的博主。
💪很高兴与你相遇,一起加油!

一、题目要求

  • 在 8 个数码管上循环显示 1~8,每个数字显示时间为 1s;要求必须用有限状态机来做。
  • 每种状态都要分别给 8 个数码管赋值,不显示的数码管可以用十六进制数常量 7’h7F 赋值。

二、代码

module led7_8(clk50,clr,hex0,hex1,hex2,hex3,hex4,hex5,hex6,hex7);
(*chip_pin="Y2"*)input clk50;
(*chip_pin="M23"*)input clr;

(*chip_pin="G18,F22,E17,L26,L25,J22,H22"*)output reg[6:0]hex0;
(*chip_pin="M24,Y22,W21,W22,W25,U23,U24"*)output reg[6:0]hex1;
(*chip_pin="AA25,AA26,Y25,W26,Y26,W27,W28"*)output reg[6:0]hex2;
(*chip_pin="V21,U21,AB20,AA21,AD24,AF23,Y19"*)output reg[6:0]hex3;
(*chip_pin="AB19,AA19,AG21,AH21,AE19,AF19,AE18"*)output reg[6:0]hex4;
(*chip_pin="AD18,AC18,AB18,AH19,AG19,AF18,AH18"*)output reg[6:0]hex5;
(*chip_pin="AA17,AB16,AA16,AB17,AB15,AA15,AC17"*)output reg[6:0]hex6;
(*chip_pin="AD17,AE17,AG17,AH17,AF17,AG18,AA14"*)output reg[6:0]hex7;


parameter s0=0,s1=1,s2=2,s3=3,s4=4,s5=5,s6=6,s7=7;//8个状态
reg [32:0]count;
reg [3:0]cs,ns;	//cs:当前状态	ns:下一时态
reg clk1;

always @(posedge clk50)
begin
	if(count=='d24999999)
		begin
			count<=0;
			clk1<=~clk1;
		end
	else
		count<=count+1;
end

always@(posedge clk1 or negedge clr )	//定义cs
begin
	if(~clr) cs=s0;
	else	cs=ns;
end


always@(cs)	//定义ns
begin
	case(cs)
		s0:ns=s1;
		s1:ns=s2;
		s2:ns=s3;
		s3:ns=s4;
		s4:ns=s5;
		s5:ns=s6;
		s6:ns=s7;
		s7:ns=s0;
		default	ns=s0;
	endcase
end


always@(cs)
begin			
	case(cs)
		s0:
			begin
				hex7=7'b1001111;//1
				hex6=7'b1111111;
				hex5=7'b1111111;
				hex4=7'b1111111;
				hex3=7'b1111111;
				hex2=7'b1111111;
				hex1=7'b1111111;
				hex0=7'b1111111;
			end
		s1:
			begin
				hex7=7'b1111111;
				hex6=7'b0010010;//2
				hex5=7'b1111111;
				hex4=7'b1111111;
				hex3=7'b1111111;
				hex2=7'b1111111;
				hex1=7'b1111111;
				hex0=7'b1111111;
			end
		s2:
			begin
				hex7=7'b1111111;
				hex6=7'b1111111;
				hex5=7'b0000110;//3
				hex4=7'b1111111;
				hex3=7'b1111111;
				hex2=7'b1111111;
				hex1=7'b1111111;
				hex0=7'b1111111;
			end
		s3://3
			begin
				hex7=7'b1111111;
				hex6=7'b1111111;
				hex5=7'b1111111;
				hex4=7'b1001100;//4
				hex3=7'b1111111;
				hex2=7'b1111111;
				hex1=7'b1111111;
				hex0=7'b1111111;
			end
		s4:
			begin
				hex7=7'b1111111;
				hex6=7'b1111111;
				hex5=7'b1111111;
				hex4=7'b1111111;
				hex3=7'b0100100;//5
				hex2=7'b1111111;
				hex1=7'b1111111;
				hex0=7'b1111111;
			end
		s5:
			begin
				hex7=7'b1111111;
				hex6=7'b1111111;
				hex5=7'b1111111;
				hex4=7'b1111111;
				hex3=7'b1111111;
				hex2=7'b0100000;//6
				hex1=7'b1111111;
				hex0=7'b1111111;
			end		
		s6:
			begin
				hex7=7'b1111111;
				hex6=7'b1111111;
				hex5=7'b1111111;
				hex4=7'b1111111;
				hex3=7'b1111111;
				hex2=7'b1111111;
				hex1=7'b0001111;//7
				hex0=7'b1111111;
			end
		s7:
			begin
				hex7=7'b1111111;
				hex6=7'b1111111;
				hex5=7'b1111111;
				hex4=7'b1111111;
				hex3=7'b1111111;
				hex2=7'b1111111;
				hex1=7'b1111111;
				hex0=7'b0000000;//8
			end			
		default						//全不亮
			begin
				hex7=7'b1111111;
				hex6=7'b1111111;
				hex5=7'b1111111;
				hex4=7'b1111111;
				hex3=7'b1111111;
				hex2=7'b1111111;
				hex1=7'b1111111;
				hex0=7'b1111111;
			end	
	endcase
end
endmodule

三、效果

视频链接:【EDA】循环扫描显示的七段数码管译码控制电路的设计

【EDA】循环扫描显示的七段数码管译码控制电路的设计

❤️❤️❤️忙碌的敲代码也不要忘了浪漫鸭!

🌞好久不见

请添加图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

怪&

感谢您的支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值