资源描述:
《EDA技术及应用教程 教学课件 作者 赵全利EDA 部分习题参考答案.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、部分习题参考答案3.6习题33.合法标识符:my_counter、Decoder_1、data__BUS、Sig_N非法标识符:2FFT、Sig_#N、Not-Ack、ALL_RST_、return、entity7.参考程序为:entityNOR2aisPort(A,B:instd_logic;C:outstd_logic);endNOR2a;15.Q=”00100100”4.4习题41.用PROCESS语句和CASE-WHEN语句,参考程序如下:libraryieee;useieee.std_logic_1164.
2、all;entitydecoder3_8isport(a,b,c,g1,g2a,g2b:instd_logic;y:outstd_logic_vector(7downto0));enddecoder3_8;architectureaofdecoder3_8issignaldz:std_logic_vector(2downto0);begindz<=c&b&a;process(dz,g1,g2a,g2b)beginif(g1='1'andg2a='0'andg2b='0')thencasedziswhen"000"=>
3、y<="11111110";when"001"=>y<="11111101";when"010"=>y<="11111011";when"011"=>y<="11110111";when"100"=>y<="11101111";when"101"=>y<="11011111";when"110"=>y<="10111111";when"111"=>y<="01111111";whenothers=>y<="XXXXXXXX";endcase;else127y<="11111111";endif;endprocess;
4、end;用WHEN-ELSE语句,参考程序如下:……architecturea1ofdecoder3_8issignaldz:std_logic_vector(2downto0);begindz<=c&b&a;withdzselectdout<="11111110"when"000","11111101"when"001","11111011"when"010","11110111"when"011","11101111"when"100","11011111"when"101","10111111"when"110
5、","01111111"when"111","XXXXXXXX"whenothers;enda1;2.参考程序如下:entityv74x148isport(s:instd_logic;i:instd_logic_vector(7downto0);y:outstd_logic_vector(2downto0);yex,ys:outstd_logic);endv74x148;architecturebehaveofv74x148isbeginprocess(s,i)variablej,k:integerrange7dow
6、nto0;variabledone:bit;begindone:=‘0’;ys<=’0’;ifs=‘1’thenyex<=’1’;ys<=‘1’;y<=“111”;elseforjin7downto0loopifdone=‘1’thennull;elsifi(j)=‘0’thendone:=’1’;yex<=’0’;ys<=’1’;k<=7-j;y<=conv_std_logic_vector(k,2downto0);endif;endloop;endif;endprocess;endbehave;1273.参考程序
7、如下:add4的vhdl代码:LIBRARYieee;USEieee.std_logic_1164.ALL;useieee.std_logic_arith.all;useieee.std_logic_unsigned.all;ENTITYadd4ISPORT( a :INstd_logic_vector(3DOWNTO0); b :INstd_logic_vector(3DOWNTO0); cin:INstd_logic; sum:OUTstd_logic_vector(3DOWNTO0); g,p
8、:OUTstd_logic);ENDadd4;ARCHITECTUREbehaveOFadd4ISsignalc1,c2,c3,temp0,temp1,temp2,temp3,temp4,temp5:STD_LOGIC;BEGINsum(0)<=a(0)xorb(0)xorcin;sum(1)<=a(1)xorb(1)xorc1;sum(2)<