• 【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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158

    三、效果

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

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

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

    🌞好久不见

    请添加图片描述

  • 相关阅读:
    多线程---synchronized特性+原理
    能把SAP系统玩成鸡肋的公司,太有才了!
    微服务和 C++ 如何有效结合?
    关于安卓SVGA浅尝(一)svgaplayer库的使用
    【nodejs】如何从Windows中完全删除node.js
    JSR303和拦截器
    算法入门——树(基础篇)(tree)
    【Java】学生管理系统-登录、注册、CRUD(附完整代码)
    Linux 基础 + Web 部署
    TCP沾包问题
  • 原文地址:https://blog.csdn.net/qq_21471309/article/details/124983034