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

时间: 2024-02-03 11:12:49 浏览: 34
以下是基于VHDL的代码实现: 1. 在DISP7-DISP3数码管上显示20413 ``` library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; entity display is port ( clk: in std_logic; reset: in std_logic; disp7_disp3: out std_logic_vector(7 downto 3); num: in unsigned(15 downto 0) ); end entity display; architecture Behavioral of display is signal counter: integer range 0 to 3; signal num_copy: unsigned(15 downto 0); begin process (clk, reset) begin if reset = '1' then counter <= 0; num_copy <= (others => '0'); disp7_disp3 <= "0000000"; elsif rising_edge(clk) then counter <= counter + 1; if counter = 3 then counter <= 0; end if; if counter = 0 then num_copy <= num(15 downto 12); disp7_disp3 <= "1111110"; elsif counter = 1 then num_copy <= num(11 downto 8); disp7_disp3 <= "0110000"; elsif counter = 2 then num_copy <= num(7 downto 4); disp7_disp3 <= "1101101"; end if; end if; end process; end architecture Behavioral; entity testbench_display is end entity; architecture test of testbench_display is signal clk: std_logic := '0'; signal reset: std_logic := '1'; signal num: unsigned(15 downto 0) := x"4f75"; signal disp7_disp3: std_logic_vector(7 downto 3); component display is port ( clk: in std_logic; reset: in std_logic; disp7_disp3: out std_logic_vector(7 downto 3); num: in unsigned(15 downto 0) ); end component; begin uut: display port map ( clk => clk, reset => reset, disp7_disp3 => disp7_disp3, num => num ); process begin reset <= '1'; wait for 10 ns; reset <= '0'; wait for 100 ns; reset <= '1'; wait for 100 ns; reset <= '0'; while true loop wait for 10 ns; clk <= not clk; end loop; end process; end architecture test; ``` 2. 设计并生成一个随机数生成电路 ``` library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; entity random_generator is port ( clk: in std_logic; reset: in std_logic; random_num: out unsigned(9 downto 0) ); end entity random_generator; architecture Behavioral of random_generator is signal counter: integer range 0 to 49999999; signal lfsr: unsigned(9 downto 0) := (others => '0'); begin process (clk, reset) begin if reset = '1' then counter <= 0; lfsr <= (others => '0'); random_num <= (others => '0'); elsif rising_edge(clk) then counter <= counter + 1; if counter = 50000000 then counter <= 0; lfsr(9 downto 1) <= lfsr(8 downto 0); lfsr(0) <= lfsr(9) xor lfsr(5) xor lfsr(2) xor lfsr(1); random_num <= lfsr; end if; end if; end process; end architecture Behavioral; entity testbench_random_generator is end entity; architecture test of testbench_random_generator is signal clk: std_logic := '0'; signal reset: std_logic := '1'; signal random_num: unsigned(9 downto 0); component random_generator is port ( clk: in std_logic; reset: in std_logic; random_num: out unsigned(9 downto 0) ); end component; begin uut: random_generator port map ( clk => clk, reset => reset, random_num => random_num ); process begin reset <= '1'; wait for 10 ns; reset <= '0'; wait for 100 ns; reset <= '1'; wait for 100 ns; reset <= '0'; while true loop wait for 1 us; clk <= not clk; end loop; end process; end architecture test; ``` 3. 为系统设置一个复位键 ``` library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; entity system is port ( clk: in std_logic; reset: in std_logic; disp2_disp0: out std_logic_vector(2 downto 0); random_num: out unsigned(9 downto 0) ); end entity system; architecture Behavioral of system is signal counter: integer range 0 to 999999; signal disp7_disp3: std_logic_vector(7 downto 3); signal num: unsigned(15 downto 0) := x"4f75"; component display is port ( clk: in std_logic; reset: in std_logic; disp7_disp3: out std_logic_vector(7 downto 3); num: in unsigned(15 downto 0) ); end component; component random_generator is port ( clk: in std_logic; reset: in std_logic; random_num: out unsigned(9 downto 0) ); end component; begin uut_display: display port map ( clk => clk, reset => reset, disp7_disp3 => disp7_disp3, num => num ); uut_random_generator: random_generator port map ( clk => clk, reset => reset, random_num => random_num ); process (clk, reset) begin if reset = '1' then counter <= 0; num <= x"4f75"; disp7_disp3 <= "0000000"; elsif rising_edge(clk) then if counter = 2000000 then counter <= 0; num <= (others => '0'); disp7_disp3 <= "0000000"; end if; if counter = 4000000 then counter <= 0; num <= x"4f75"; end if; if counter = 6000000 then counter <= 0; disp7_disp3 <= "000" & std_logic_vector(random_num); end if; counter <= counter + 1; end if; end process; end architecture Behavioral; entity testbench_system is end entity; architecture test of testbench_system is signal clk: std_logic := '0'; signal reset: std_logic := '1'; signal disp2_disp0: std_logic_vector(2 downto 0); signal random_num: unsigned(9 downto 0); component system is port ( clk: in std_logic; reset: in std_logic; disp2_disp0: out std_logic_vector(2 downto 0); random_num: out unsigned(9 downto 0) ); end component; begin uut: system port map ( clk => clk, reset => reset, disp2_disp0 => disp2_disp0, random_num => random_num ); process begin reset <= '1'; wait for 10 ns; reset <= '0'; wait for 100 ns; reset <= '1'; wait for 100 ns; reset <= '0'; while true loop wait for 1 us; clk <= not clk; end loop; end process; end architecture test; ```

相关推荐

最新推荐

recommend-type

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

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

基于VHDL语言的按键消抖电路设计及仿真

用VHDL语言编程的有限状态机的设计方法来实现按键的消抖,经仿真分析和下载实现,这种方法设计的消抖电路能够很好地实现电路功能,进行快速按键时都能保证每按一次做一次的响应,且性能稳定。
recommend-type

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

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

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

0 引言  电梯控制器是控制电梯按顾客要求自动上下的装置。本文采用VHDL语言来设计实用三层电梯控制器,其代码具有良好的可读性和易理解性,源程序经A1... (3)电梯每秒升(降)一层楼。  (4)电梯到达有停站请求的楼层
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

帮我设计一个基于Android平台的便签APP的代码

很抱歉,我是一个语言模型AI,无法提供完整的Android APP代码。但是,我可以给您一些设计便签APP的建议和思路。 1. 界面设计 首先考虑APP的界面设计,便签APP通常需要一个主界面用于显示所有的便签,以及一个编辑界面用于编辑单个便签。主界面可以采用列表的形式,列出所有的便签,每个便签可以显示标题和摘要内容。在编辑界面中,用户可以输入标题和正文内容,并且可以设置提醒时间、标签、优先级等。 2. 数据存储 便签APP需要一个数据存储的方案,可以考虑使用SQLite数据库来存储便签数据。每个便签可以存储标题、正文内容、提醒时间、标签、优先级等信息。 3. 便签操作 便签APP
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。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依