1.用VHDL写出在DISP7-DISP3数码管上显示班级和班内序号 2. 设计并生成一个随机数生成电路,每两秒生成一个0~999之间的随机数,并且在数码管DISP2-DISP0上显示生成的随机数。 3. 为系统设置一个复位键,复位后数码管DISP2~DISP0上显示”000”,2秒后生成并且显示随机数,并且使用复位键进行复位,

时间: 2024-02-03 18:12:35 浏览: 34
1. VHDL 代码如下: ``` library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity Display is port ( class : in std_logic_vector(3 downto 0); number : in std_logic_vector(3 downto 0); clk : in std_logic; reset : in std_logic; disp : out std_logic_vector(6 downto 0) ); end entity; architecture Behavior of Display is signal cnt : integer range 0 to 100000000 := 0; signal class_num : integer range 0 to 99 := 0; signal number_num : integer range 0 to 99 := 0; signal disp_num : integer range 0 to 999 := 0; begin process (clk, reset) begin if reset = '1' then cnt <= 0; class_num <= 0; number_num <= 0; disp_num <= 0; disp <= "0000000"; elsif rising_edge(clk) then cnt <= cnt + 1; if cnt = 10000000 then -- 每10秒更新一次显示 cnt <= 0; class_num <= to_integer(unsigned(class)); number_num <= to_integer(unsigned(number)); disp_num <= class_num * 100 + number_num; end if; end if; end process; process (disp_num) begin case disp_num is when 0 => disp <= "1000000"; -- 0 when 1 => disp <= "1111001"; -- 1 when 2 => disp <= "0100100"; -- 2 when 3 => disp <= "0110000"; -- 3 when 4 => disp <= "0011001"; -- 4 when 5 => disp <= "0010010"; -- 5 when 6 => disp <= "0000010"; -- 6 when 7 => disp <= "1111000"; -- 7 when 8 => disp <= "0000000"; -- 8 when 9 => disp <= "0010000"; -- 9 when 10 => disp <= "0001000"; -- A when 11 => disp <= "0000011"; -- b when 12 => disp <= "0100111"; -- C when 13 => disp <= "0100010"; -- d when 14 => disp <= "0000110"; -- E when 15 => disp <= "0001110"; -- F when others => disp <= "1111111"; -- 空白 end case; end process; end architecture; ``` 2. VHDL 代码如下: ``` library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity RandomGenerator is port ( clk : in std_logic; reset : in std_logic; random_num : out std_logic_vector(9 downto 0); disp : out std_logic_vector(6 downto 0) ); end entity; architecture Behavior of RandomGenerator is signal cnt : integer range 0 to 100000000 := 0; signal rand : integer range 0 to 999 := 0; begin process (clk, reset) begin if reset = '1' then cnt <= 0; rand <= 0; random_num <= "0000000000"; disp <= "0000000"; elsif rising_edge(clk) then cnt <= cnt + 1; if cnt = 20000000 then -- 每2秒更新一次随机数 cnt <= 0; rand <= integer(unsigned(to_unsigned(rand, 10))) + 1; if rand >= 1000 then rand <= 0; end if; random_num <= std_logic_vector(to_unsigned(rand, 10)); end if; end if; end process; process (random_num) begin case random_num is when "0000" => disp <= "1000000"; -- 0 when "0001" => disp <= "1111001"; -- 1 when "0010" => disp <= "0100100"; -- 2 when "0011" => disp <= "0110000"; -- 3 when "0100" => disp <= "0011001"; -- 4 when "0101" => disp <= "0010010"; -- 5 when "0110" => disp <= "0000010"; -- 6 when "0111" => disp <= "1111000"; -- 7 when "1000" => disp <= "0000000"; -- 8 when "1001" => disp <= "0010000"; -- 9 when others => disp <= "1111111"; -- 空白 end case; end process; end architecture; ``` 3. VHDL 代码如下: ``` library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity DisplayAndGenerator is port ( class : in std_logic_vector(3 downto 0); number : in std_logic_vector(3 downto 0); clk : in std_logic; reset : in std_logic; random_num : out std_logic_vector(9 downto 0); disp : out std_logic_vector(6 downto 0) ); end entity; architecture Behavior of DisplayAndGenerator is signal cnt : integer range 0 to 100000000 := 0; signal class_num : integer range 0 to 99 := 0; signal number_num : integer range 0 to 99 := 0; signal disp_num : integer range 0 to 999 := 0; signal rand : integer range 0 to 999 := 0; begin process (clk, reset) begin if reset = '1' then cnt <= 0; class_num <= 0; number_num <= 0; disp_num <= 0; rand <= 0; random_num <= "0000000000"; disp <= "0000000"; elsif rising_edge(clk) then cnt <= cnt + 1; if cnt = 20000000 then -- 每2秒更新一次随机数 cnt <= 0; rand <= integer(unsigned(to_unsigned(rand, 10))) + 1; if rand >= 1000 then rand <= 0; end if; random_num <= std_logic_vector(to_unsigned(rand, 10)); end if; if cnt = 10000000 then -- 每10秒更新一次显示 class_num <= to_integer(unsigned(class)); number_num <= to_integer(unsigned(number)); disp_num <= class_num * 100 + number_num; end if; end if; end process; process (disp_num) begin case disp_num is when 0 => disp <= "1000000"; -- 0 when 1 => disp <= "1111001"; -- 1 when 2 => disp <= "0100100"; -- 2 when 3 => disp <= "0110000"; -- 3 when 4 => disp <= "0011001"; -- 4 when 5 => disp <= "0010010"; -- 5 when 6 => disp <= "0000010"; -- 6 when 7 => disp <= "1111000"; -- 7 when 8 => disp <= "0000000"; -- 8 when 9 => disp <= "0010000"; -- 9 when 10 => disp <= "0001000"; -- A when 11 => disp <= "0000011"; -- b when 12 => disp <= "0100111"; -- C when 13 => disp <= "0100010"; -- d when 14 => disp <= "0000110"; -- E when 15 => disp <= "0001110"; -- F when others => disp <= "1111111"; -- 空白 end case; end process; end architecture; ```

相关推荐

最新推荐

recommend-type

VHDL课程设计--万年历,课程设计报告。包括各个模块的代码及仿真图

设计一个万年历系统,通过数码管显示。 1) 显示分钟、小时,秒通过一个LED来进行闪烁显示。 2) 可设置时间,通过按键进行设置,设置方式可采用增加或者减小来进行显示; 3) 显示年、月、日等,通过按键进行显示...
recommend-type

FPGA课程设计任务书-数字电子钟设计 .doc

EDA技术在电子系统设计领域越来越普及,本设计主要利用VHDL和C语言在FPGA实验板上设计一个电子数字钟,它的计时周期为24小时,显示满刻度为23时59分59秒、。总的程序由几个各具不同功能的单元模块程序拼接而成,其中...
recommend-type

基于VHDL语言的8位RISC-CPU设计

基于VHDL的RISC设计 在现代电路设计中,经常需要嵌入特定功能的CPU。在FPGA中实现这样的CPU,具有高速、灵活等优点。RISC是最通用的处理器结构,...本论文拟利用VHDL语言,完成一种简易的RISC的设计,并利用FPGA实现。
recommend-type

EDA/PLD中的基于VHDL三层电梯控制器的设计

本文采用VHDL语言来设计实用三层电梯控制器,其代码具有良好的可读性和易理解性,源程序经A1tera公司的MAX+plus II软件仿真,目标器件选用CPLD器件。通过对三层电梯控制器的设计,可以发现本设计有一定的扩展性,...
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

MATLAB柱状图在信号处理中的应用:可视化信号特征和频谱分析

![matlab画柱状图](https://img-blog.csdnimg.cn/3f32348f1c9c4481a6f5931993732f97.png) # 1. MATLAB柱状图概述** MATLAB柱状图是一种图形化工具,用于可视化数据中不同类别或组的分布情况。它通过绘制垂直条形来表示每个类别或组中的数据值。柱状图在信号处理中广泛用于可视化信号特征和进行频谱分析。 柱状图的优点在于其简单易懂,能够直观地展示数据分布。在信号处理中,柱状图可以帮助工程师识别信号中的模式、趋势和异常情况,从而为信号分析和处理提供有价值的见解。 # 2. 柱状图在信号处理中的应用 柱状图在信号处理
recommend-type

用Spring boot和vue写一个登录注册界面

好的,这是一个比较常见的技术问题,我可以为您提供一些参考资料和思路。首先,您可以使用Spring Boot作为后端框架来处理用户认证和注册的逻辑,比如使用Spring Security实现用户登录认证。同时,您还需要设计相应的数据模型和数据库表结构来存储用户信息。在前端方面,您可以使用Vue.js作为框架来构建登录注册页面,使用Axios来发起API请求并和后端进行交互。当然,在实现过程中,还需要考虑一些具体细节,比如数据校验、安全性和用户体验等方面。希望这些信息能够帮助到您。
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。
recommend-type

"互动学习:行动中的多样性与论文攻读经历"

多样性她- 事实上SCI NCES你的时间表ECOLEDO C Tora SC和NCESPOUR l’Ingén学习互动,互动学习以行动为中心的强化学习学会互动,互动学习,以行动为中心的强化学习计算机科学博士论文于2021年9月28日在Villeneuve d'Asq公开支持马修·瑟林评审团主席法布里斯·勒菲弗尔阿维尼翁大学教授论文指导奥利维尔·皮耶昆谷歌研究教授:智囊团论文联合主任菲利普·普雷教授,大学。里尔/CRISTAL/因里亚报告员奥利维耶·西格德索邦大学报告员卢多维奇·德诺耶教授,Facebook /索邦大学审查员越南圣迈IMT Atlantic高级讲师邀请弗洛里安·斯特鲁布博士,Deepmind对于那些及时看到自己错误的人...3谢谢你首先,我要感谢我的两位博士生导师Olivier和Philippe。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依