手机版

EDA与VHDL知识点总结与期末考试试卷及答案 (8)(3)

发布时间:2021-06-08   来源:未知    
字号:

EDA与VHDL知识点总结与期末考试试卷及答案

四、VHDL程序改错:(10分)

01 LIBRARY IEEE ;

02 USE IEEE.STD_LOGIC_1164.ALL ;

03 USE IEEE.STD_LOGIC_UNSIGNED.ALL;

04 ENTITY LED7CNT IS

05 PORT ( CLR : IN STD_LOGIC;

06 CLK : IN STD_LOGIC;

07 LED7S : OUT STD_LOGIC_VECTOR(6 DOWNTO 0) ) ; 08 END LED7CNT;

09 ARCHITECTURE one OF LED7CNT IS

10 SIGNAL TMP : STD_LOGIC_VECTOR(3 DOWNTO 0);

11 BEGIN

12 CNT:PROCESS(CLR,CLK)

13 BEGIN

14 IF CLR = '1' THEN

15 TMP <= 0;

16 ELSE IF CLK'EVENT AND CLK = '1' THEN 17 TMP <= TMP + 1;

18 END IF;

19 END PROCESS;

20 OUTLED:PROCESS(TMP)

21 BEGIN

22 CASE TMP IS

23 WHEN "0000" => LED7S <= "0111111" ; 24 WHEN "0001" => LED7S <= "0000110" ; 25 WHEN "0010" => LED7S <= "1011011" ; 26 WHEN "0011" => LED7S <= "1001111" ; 27 WHEN "0100" => LED7S <= "1100110" ; 28 WHEN "0101" => LED7S <= "1101101" ; 29 WHEN "0110" => LED7S <= "1111101" ; 30 WHEN "0111" => LED7S <= "0000111" ; 31 WHEN "1000" => LED7S <= "1111111" ; 32 WHEN "1001" => LED7S <= "1101111" ; 33 WHEN OTHERS => LED7S <= (OTHERS => '0'); 34 END CASE;

35 END PROCESS;

36 END one;

在程序中存在两处错误,试指出,并说明理由:

提示:在MAX+PlusII 10.2上编译时报出的第一条错误为:

Error:Line 15: File ***/led7cnt.vhd: Type error: type in waveform element must be “std_logic_vector”

第 15 行, 错误:整数0不能直接赋值给TMP矢量

改正:TMP <= (OTHERS => ‘0’);

EDA与VHDL知识点总结与期末考试试卷及答案 (8)(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)