计数器及时序电路fpga

  • 格式:doc
  • 大小:1.67 MB
  • 文档页数:12

实验一MAX+PLUSⅡ软件的使用一、实验目的:1、掌握用VHDL 语言进行简单组合逻辑电路的设计方法。

2、了解并掌握M A X P L U S2软件的使用。

3、掌握组合逻辑电路的仿真方法。

二、实验设备:1、PC 机2、M A X P L U SⅡ软件。

三、实验内容:1、用VHDL 语言输入法设计一个二选一,并进行仿真测试。

2、用VHDL 语言输入法设计一个四舍五入判别电路,要求当输入大于或等于5时,判别电路输出为1;反之为0。

四、实验步骤:1、采用文本编辑器输入VHDL 语言源程序,建立工程。

2、编译。

3、导入波形文件,保存后,设置数据后进行仿真,验证结果。

五、程序清单及仿真结果:(一)、二选一library ieee;use ieee.std_logic_1164.all;entity mux21 isport(a,b:in std_logic;s:in std_logic;y:out std_logic);end mux21;architecture mux_artch of mux21 isbeginy<=a when s='0' elseb when s='1' ;end mux_arch;Maxplus2环境下操作过程:仿真结果:(二)、四舍五入判别电路:方法一:其输入为十进制数library ieee;use ieee.std_logic_1164.all;entity mu45 isport(din:in std_logic_vector(3 downto 0);q:out std_logic);end mu45;architecture mu45_arch of mu45 isbeginq<='1' when din>=5 else'0';end mu45_arch;仿真结果:说明:输入为0~4时,输出y为低电平,输入为 5时输出为高电平,实现了四舍五入的功能。

方法二:其输入为8421BCD 码,library i eee;use ieee.std_logic_1164.all;entity sswr isport(input:in std_logic_vector(3 downto 0);y:out bit);end sswr;architecture art of sswr isbeginprocess(input)begincase input iswhen "0000"=>y<='0';when "0001"=>y<='0';when "0010"=>y<='0';when "0011"=>y<='0';when "0100"=>y<='0';when "0101"=>y<='1';when "0110"=>y<='1';when "0111"=>y<='1';when "1000"=>y<='1';when "1001"=>y<='1';when others=>null;end case;end process;end art;仿真结果:说明:输入为0~4时,输出y为低电平,输入为5~F时输出为高电平,实现了四舍五入的功能。

实验二组合逻辑电路的设计一、实验目的:1、掌握用VHDL 语言进行简单组合逻辑电路的设计方法。

2、了解并掌握M A X P L U S2软件的使用。

3、掌握组合逻辑电路的仿真方法。

二、实验设备:1、PC 机2、M A X P L U S2软件。

三、实验内容:1、用VHDL 语言输入法设计三人表决器,并进行仿真测试。

2、用VHDL 语言输入法设计一个8—3编码器,并进行仿真测试。

四、实验步骤:1、采用文本编辑器输入VHDL 语言源程序,建立工程。

2、编译。

3、导入波形文件,保存后,设置数据后进行仿真。

五、VHDL源程序及仿真结果:(一)、三人表决器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity elc31 isport (m:in std_logic_vector(2 downto 0);y:out std_logic);end;architecture beha of elc31 isbeginprocess (m)beginif m="000" then y<='0';elsif m="001"then y<='0';elsif m="010"then y<='0';elsif m="011"then y<='1';elsif m="100"then y<='0';elsif m="101"then y<='1';elsif m="110"then y<='1';elsif m="111"then y<='1';end if;end process;end beha;Maxplus2环境下操作过程:○1采用文本编辑器输入VHDL 语言源程序,建立工程○2导入波形文件,保存后,设置数据后进行仿真。

○3仿真结果:说明:用3位二进制数分别表示三人表决情况,“0”表示反对,“1”表示赞同。

当三人中有两人以上(包括两人)赞同时表示结果通过。

(二)8—3优先编码器的VHDL源程序library ieee;use ieee.std_logic_1164.all;entity encoder83 isport(d:in std_logic_vector(7 DOWNTO 0);y:out std_logic_vector(2 downto 0));end encoder83;architecture arc of encoder83 isbeginprocess(d)beginif d(7)='0' then y<="111";elsif d(6)='0' then y<="110";elsif d(5)='0' then y<="101";elsif d(4)='0' then y<="100";elsif d(3)='0' then y<="011";elsif d(2)='0' then y<="010";elsif d(1)='0' then y<="001";else y<="000";end if;end process;end arc;仿真结果:实验三计数器及时序电路一、实验目的:1、了解时序电路的VHDL 语言设计方法。

2、了解异步计数器的使用方法。

3、理解时序电路和异步计数器加译码电路的联系,设计任意编码计数器。

二、实验设备:1、PC 机2、MAX+PLUSⅡ软件三、实验内容:1、用VHDL语言输入法设计一个六进制异步计数器。

2、用VHDL语言输入法设计一个十进制同步(或异步)计数器。

3、将六进制异步计数器和十进制同步(或异步)计数器进制计数器通过元件例化语句搭建一个六十进制计数器。

四、实验步骤:1、采用文本编辑器输入VHDL 语言源程序,之后建立工程。

2、编译。

3、仿真。

五、VHDL源程序及仿真结果:1、用VHDL 语言输入法设计六进制异步计数器。

port(clk,clr, en:in std_logic;carry:out std_logic;q:out std_logic_vector(2 downto 0));end count6;architecture beha of count6 issignal cntout:std_logic_vector(2 downto 0);beginq<=cntout;process(clk,clr,en)beginif clr='1' thencntout<="000";carry<='0';elsif clk'event and clk='1' thenif en='1' thenif cntout="101" thencntout<="000";carry<='1';elsecntout<=cntout+'1';carry<='0';end if;end if;end if;end process;end beha;输出仿真波形图:说明:当使能信号en=1,清零信号clr=0时,在时钟信号的控制下计数输出0-5六个数,实现了六进制异步计数器功能。

2、用VHDL语言输入法设计一个十进制异步计数器。

library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity count10 isport(clk,clr,en:in std_logic;q:out std_logic_vector(3 downto 0);carry: out std_logic );end count10 ;architecture beha of count10 issignal m:std_logic_vector(3 downto 0);beginprocess(clk,clr,en)beginif clr='1' thenm<="0000";elsif clk'event and clk='1' thenif en='1' thenif m="1001" thenm<="0000";carry<='1';elsem<=m+1;carry<='0';end if;end if;end if;end process;q<=m;end;输出仿真波形图:说明:当使能信号en=1,clr=0时,在时钟信号的控制下输出0-9十个数,实现了十进制异步计数器功能3、将六进制异步计数器和十进制异步计数器进制计数器通过元件例化语句搭建一个六十进制计数器。