欢迎来到天天文库
浏览记录
ID:58819611
大小:298.00 KB
页数:62页
时间:2020-10-25
《EDA-常见实例源程序代码vhdl.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第4章用VHDL程序实现常用逻辑电路4.1组合逻辑电路设计4.1.1基本逻辑门libraryieee;useiee.std_logic_1164.all;entityjbmisport(a,b:inbit;f1,f2,f3,f4,f5,f:outbit);endjbm;architectureaofjbmisbeginf1<=aandb;--构成与门f2<=aorb;--构成或门f<=nota;--构成非门f3<=anandb;--构成与非门f4<=anorb;--构成异或门f5<=not(axorb);--构成异
2、或非门即同门end;4.1.2三态门libraryieee;useieee.std_logic_1164.all;entitytri_sisport(enable:instd_logic;datain:instd_logic_vector(7downto0);dataout:outstd_logic_vector(7downto0));endtri_s;architecturebhvoftri_sisbeginprocess(enable,datain)beginifenable='1'thendataout<=d
3、atain;elsedataout<="ZZZZZZZZ";endif;endprocess;endbhv;4.1.33-8译码器libraryieee;useieee.std_logic_1164.all;entitydecoder3_8isport(a,b,c,g1,g2a,g2b:instd_logic;y:outstd_logic_vector(7downto0));enddecoder3_8;architectureaofdecoder3_8issignaldz:std_logic_vector(2dow
4、nto0);begindz<=c&b&a;process(dz,g1,g2a,g2b)beginif(g1='1'andg2a='0'andg2b='0')thencasedziswhen"000"=>y<="";when"001"=>y<="";when"010"=>y<="";when"011"=>y<="";when"100"=>y<="";when"101"=>y<="";when"110"=>y<="";when"111"=>y<="";whenothers=>y<="XXXXXXXX";endcase;
5、elsey<="";endif;endprocess;4.1.4优先编码器libraryieee;useieee.std_logic_1164.allentitycoderisport(din:instd_logic_vector(0to7);output:outstd_logic_vector(0to2));endcoder;architecturebehaveofcoderissignalsint:std_logic_vevtor(4downto0);beginprocess(din)beginif(din(7
6、)='0')thenoutput<="000";elsif(din(6)='0')thenoutput<="100";elsif(din(5)='0')thenoutput<="010";elsif(din(4)='0')thenoutput<="110";elsif(din(3)='0')thenoutput<="001";elsif(din(2)='0')thenoutput<="101";elsif(din(1)='0')thenoutput<="011";elseoutput<="111";endif;en
7、dprocess;endbehav;4.1.57段码译码器libraryieee;useieee.std_logic_1164.allentitydecl7sisport(a:instd_logic_vector(3downto0);led7s:outstd_logic_vector(6downto0));enddecl7s;architecturebehaveofdecl7sisbeginprocess(a)begincaseaiswhen"0000"=>led7s<="";when"0001"=>led7s<=
8、"";when"0010"=>led7s<="";when"0011"=>led7s<="";when"0100"=>led7s<="";when"0101"=>led7s<="";when"0110"=>led7s<="";when"0111"=>led7s<="";when"1000"=>led7s<="";when"1001"=>led7s<="";w
此文档下载收益归作者所有