资源描述:
《ERP.概念原理启动大会》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、15.5VDHL程序设计实例5.5.1常用组合电路的设计组合逻辑是电路设计的基础,组合逻辑的描述可通过并行信号赋值语句或纯组合逻辑行为的进程语句来实现。并行赋值语句:1、简单信号赋值语句2、条件信号赋值语句3、选择信号赋值语句进程语句:为了保证一个进程语句能生成组合逻辑,在进程语句里所有被读入的信号都必须包含在该进程语句的敏感表中。25.5.1.1门电路1、与门方法1:直接信号赋值libraryieee;useieee.std_logic_1164.all;entityand_2isport(a:ins
2、td_logic;b:instd_logic;y:outstd_logic);endand_2;architecturebehaveofand_2isbeginy<=aandb;endbehave;3方法2:进程内信号赋值注意要将a和b都加入敏感信号表。architecturebehavofand_2isbeginprocess(a,b)beginy<=aandb;endprocess;endbehav;4方法3:进程if条件赋值经过分析发现,只有a和b都为1的时候y才会输出1。所以描述如下:archi
3、tecturebehavofand_2isbeginprocess(a,b)beginif(a=‘1’andb=‘1’)theny<=‘1’;elsey<=‘0’;endif;endprocess;endbehav;5方法4:进程if条件赋值经过分析发现,a=‘1’时,y会跟踪b的变化,即y<=b。architecturebehavofand_2isbeginprocess(a,b)beginifa=‘1’theny<=b;elsey<=‘0’;endif;endprocess;endbehav;62.
4、与非门libraryieee;useieee.std_logic_1164.all;entitynand_2isport(a:instd_logic;b:instd_logic;y:outstd_logic);endnand_2;architecturebehaveofnand_2isbeginy<=anandb;endbehave;75.5.1.2编码器与译码器8线-3线编码器8-3编码器d0d1d2d3d4d5d6d7q0q1q2图5.4.18-3线编码器用case语句libraryieee;use
5、ieee.std_logic_1164.all;entitycoderisport(d:instd_logic_vector(7downto0);q:outstd_logic_vector(2downto0));endcoder;architecturertlofcoderisbeginp1:process(d)begincasediswhen"01111111"=>q<="111";when"10111111"=>q<="110";when"11011111"=>q<="101";when"11101
6、111"=>q<="100";when"11110111"=>q<="011";when"11111011"=>q<="010";when"11111101"=>q<="001";when"11111110"=>q<="000";whenothers=>q<="000";endcase;endprocessp1;endrtl;8architecturertlofcoderisbeginwithdselectq<="111"when"01111111","110"when"10111111","101"w
7、hen"11011111","100"when"11101111","011"when"11110111","010"when"11111011","001"when"11111101","000"when"11111110","000"whenothers;endrtl;用with_select语句:优先编码器可用when_else或if_then_else实现93-8译码器:libraryieee;useieee.std_logic_1164.all;entitydecoderisport(data
8、_in:instd_logic_vector(2downto0);g1,g2a,g2b:instd_logic;d:outstd_logic_vector(7downto0));enddecoder;architecturebehaveofdecoderisbegin用case语句:10process(data_in,g1,g2a,g2b)beginif(g1='1'andg2a='0'andg2b='0')thencasedata_ini