门电路VHDL语言
- 格式:doc
- 大小:86.00 KB
- 文档页数:4
“非”门library ieee;use ieee.std_logic_1164.all; entity not1 isport(a:in std_logic;b:out std_logic); end entity not1; architecture behav of not1 is beginb<=not a;end architecture behav;“与”门library ieee;use ieee.std_logic_1164.all; entity and2 isport(a,b:in std_logic;c:out std_logic); end entity and2; architecture behav of and2 is beginc<=a and b;end architecture behav;“与非”门library ieee;use ieee.std_logic_1164.all; entity nand2 isport(a,b:in std_logic;c:out std_logic); end entity nand2; architecture behav of nand2 is beginc<=not(a and b);end architecture behav; “或非”门library ieee;use ieee.std_logic_1164.all;entity nor2 isport(a,b:in std_logic;c:out std_logic);end entity nor2;architecture one of nor2 isbeginc<=not(a or b);end architecture one;“异或非”门library ieee;use ieee.std_logic_1164.all;entity xor2 isport(a,b:in std_logic;c:out std_logic);end entity xor2;architecture one of xor2 isBeginc<=not( ( (not a)and b)or(aand(not b) ) );end architecture one;D触发器library ieee;use ieee.std_logic_1164.all;entity dffa isport(D,clk,clr:in std_logic;Q:out std_logic);end entity dffa;architecture behave of dffa isbeginprocess(clk,D,clr)beginif clr='1' then Q<='0';Elsif clk'event and clk='1'then Q<=D;end if;end process;end architecture behave;T触发器library ieee;use ieee.std_logic_1164.all;entity tffa isport(T,clk,clr: in std_logic;Q: buffer std_logic);end entity tffa;architecture behave of tffa isbeginprocess(clk,T,clr)beginif clk'event and clk='1'thenif clr='1' then Q<='0';Elsif t='1'then Q<=not Q;else Q<=Q;End if;end if;end process;end architecture behave;JK触发器library ieee;use ieee.std_logic_1164.all;entity jk isport(J,K,clk, in std_logic;Q: buffer std_logic);end entity tffa;architecture behave of jk isbeginprocess(clk,J,K)beginif clk'event and clk='1'thenQ<=( (J and(not Q) )or( (notK)and Q) );end if;end process;end architecture behave;移位寄存器library ieee;use ieee.std_logic_1164.all; useieee.std_logic_unsigned.all; entity reg isport(clk,din, dir: in std_logic;op: out std_logic);end entity reg;architecture a of reg issignal q:std_logic_vector(7 downto 0);beginprocess(clk)beginif clk'event and clk='1'thenif dir='0' then q(0)<=din;for i in 1 to 7 loopq(i)<=q(i-1);end loop;else q(7)<=din;for i in 1 to 7 loopq(i-1)<=q(i);end loop;end if;end if;end process;op<=q(7)when dir='0'elseq(0);end architecture a; 分频电路library ieee;use ieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entity divf isport(clk: in std_logic;q: out std_logic);end entity divf;architecture a of divf issignal rst:std_logic;signal qn:std_logic_vector(2downto 0);beginprocess(clk,rst)beginif rst='1'then qn<="000";elsifclk'event and clk='1'thenqn<=qn+1;end if;end process;rst<='1'when qn=6 else'0';q<= qn(2);end architecture a;74LS160计数器library ieee;use ieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entity ls74160 isport(clk,rst,ena,pe:instd_logic;d:in std_logic_vector(3 downto0);count:out std_logic_vector(3downto 0);co:out std_logic);end;architecture behave of ls74160issignal temp:std_logic_vector(3 downto 0);beginprocess(clk,rst,ena,pe)beginif (rst='1')thentemp<="0000";elsif(clk'eventandclk='1')thenif ena='1'thenif pe='1'then temp<=d;elsif temp="1001"thentemp<="0000";co<='1';else temp<=temp+1;co<='0';end if;end if;end if;end process;count<=temp;end behave;10进制计数器library ieee;use ieee.std_logic_1164.all; useieee.std_logic_unsigned.all; entity count10 isport(clk,rst,ena:in std_logi c; count:out std_logic_vector(3 downto 0);co:out std_logic);end count10;architecture behave of count10 issignal temp:std_logic_vector (3 downto 0);beginprocess(clk,rst,ena)beginif (rst='1')thentemp<="0000";elsif(clk'event and clk='1')then if ena='1'thenif(temp="1001")thentemp<="0000";co<='1';else temp<=temp+1;co<='0';end if;end if;end if;end process;count<=temp;end behave;输出逻辑宏单元(OLMC):输出引脚为12~19共8个。
vhdl课程设计三态门一、教学目标通过本节课的学习,学生应掌握三态门的基本原理和VHDL语言的编程方法,能够独立完成三态门电路的设计和验证。
具体目标如下:1.了解三态门的基本原理和功能;2.掌握VHDL语言的基本语法和编程方法;3.熟悉三态门电路的设计流程和验证方法。
4.能够运用VHDL语言编写三态门电路的代码;5.能够使用相关工具对三态门电路进行仿真和验证;6.能够分析并解决三态门电路设计中遇到的问题。
情感态度价值观目标:1.培养学生的创新意识和团队协作精神;2.增强学生对电子工程领域的兴趣和热情;3.培养学生严谨的科学态度和良好的沟通能力。
二、教学内容本节课的教学内容主要包括以下几个部分:1.三态门的基本原理和功能;2.VHDL语言的基本语法和编程方法;3.三态门电路的设计流程和验证方法;4.实际案例分析和相关练习。
具体的教学大纲如下:1.引言:介绍三态门的概念和应用场景;2.三态门的基本原理:讲解三态门的工作原理和电路结构;3.VHDL语言基础:介绍VHDL语言的基本语法和编程方法;4.三态门电路设计:讲解三态门电路的设计流程和注意事项;5.电路验证与仿真:介绍如何使用相关工具对三态门电路进行仿真和验证;6.案例分析与练习:分析实际案例,并进行相关练习。
三、教学方法为了提高学生的学习兴趣和主动性,本节课将采用以下教学方法:1.讲授法:讲解三态门的基本原理和VHDL语言的基本语法;2.讨论法:引导学生进行小组讨论,共同解决问题;3.案例分析法:分析实际案例,让学生更好地理解三态门电路的设计和验证;4.实验法:引导学生动手实践,完成三态门电路的设计和验证。
四、教学资源为了支持教学内容和教学方法的实施,丰富学生的学习体验,我们将准备以下教学资源:1.教材:提供相关教材,为学生提供理论知识的学习参考;2.参考书:提供相关参考书,帮助学生深入了解三态门电路的设计和验证;3.多媒体资料:制作课件和教学视频,为学生提供直观的学习资源;4.实验设备:准备实验设备,让学生能够动手实践,提高实际操作能力。
VHDL语言简介VHDL(VHSIC Hardware Description Language)即可高速集成电路硬件描述语言,是一种用于描述数字系统和电路的硬件描述语言。
它在1981年由美国国防部的高速集成电路联合委员会(VHSIC)开发,用于设计大规模集成电路。
VHDL是一种面向对象的语言,可以用于描述各种数字系统,从简单的逻辑门到复杂的处理器。
它提供了丰富的语法和语义,使得设计人员可以准确地描述他们的电路和系统。
VHDL的优势VHDL作为一种硬件描述语言,在数字系统设计中具有许多优势。
1.可重用性:VHDL允许设计人员创建可重用的模块和子系统,这些模块和子系统可以在不同的项目中重复使用,提高了设计效率和可维护性。
2.仿真和验证:VHDL具有强大的仿真和验证能力,可以在设计之前对系统进行全面的仿真和验证。
这有助于检测和纠正潜在的问题,并确保系统在硬件实现之前达到预期的功能。
3.抽象级别:VHDL允许设计人员在不同的抽象级别上描述系统,从高级的行为级别到底层的结构级别。
这使得设计人员可以根据需要在不同的级别上工作,并且可以更容易地进行系统级别的优化。
4.灵活性和可扩展性:VHDL支持灵活的设计方法和工作流程,并允许设计人员在设计过程中进行迭代和修改。
它还可以与其他常用的设计工具和方法集成,以满足特定的需求。
VHDL语言的基本结构VHDL语言由模块、实体、架构以及信号和过程等基本元素组成。
模块(Module)模块是VHDL中描述数字系统的最基本单位。
一个模块可以包含多个实体和架构,并通过连接信号进行通信。
每个模块都有一个顶层实体和一个或多个架构。
实体(Entity)实体是描述模块的接口和行为的抽象。
它定义了输入输出端口,以及模块对外部环境的接口。
一个实体可以有一个或多个架构。
架构(Architecture)架构描述模块的具体行为和内部结构。
它定义了模块的内部信号和过程,以及对外部信号和过程的接口。
“非”门library ieee;use ieee.std_logic_1164.all; entity not1 isport(a:in std_logic;b:out std_logic); end entity not1; architecture behav of not1 is beginb<=not a;end architecture behav;“与”门library ieee;use ieee.std_logic_1164.all; entity and2 isport(a,b:in std_logic;c:out std_logic); end entity and2; architecture behav of and2 is beginc<=a and b;end architecture behav;“与非”门library ieee;use ieee.std_logic_1164.all; entity nand2 isport(a,b:in std_logic;c:out std_logic); end entity nand2; architecture behav of nand2 is beginc<=not(a and b);end architecture behav; “或非”门library ieee;use ieee.std_logic_1164.all;entity nor2 isport(a,b:in std_logic;c:out std_logic);end entity nor2;architecture one of nor2 isbeginc<=not(a or b);end architecture one;“异或非”门library ieee;use ieee.std_logic_1164.all;entity xor2 isport(a,b:in std_logic;c:out std_logic);end entity xor2;architecture one of xor2 isBeginc<=not( ( (not a)and b)or(aand(not b) ) );end architecture one;D触发器library ieee;use ieee.std_logic_1164.all;entity dffa isport(D,clk,clr:in std_logic;Q:out std_logic);end entity dffa;architecture behave of dffa isbeginprocess(clk,D,clr)beginif clr='1' then Q<='0';Elsif clk'event and clk='1'then Q<=D;end if;end process;end architecture behave;T触发器library ieee;use ieee.std_logic_1164.all;entity tffa isport(T,clk,clr: in std_logic;Q: buffer std_logic);end entity tffa;architecture behave of tffa isbeginprocess(clk,T,clr)beginif clk'event and clk='1'thenif clr='1' then Q<='0';Elsif t='1'then Q<=not Q;else Q<=Q;End if;end if;end process;end architecture behave;JK触发器library ieee;use ieee.std_logic_1164.all;entity jk isport(J,K,clk, in std_logic;Q: buffer std_logic);end entity tffa;architecture behave of jk isbeginprocess(clk,J,K)beginif clk'event and clk='1'thenQ<=( (J and(not Q) )or( (notK)and Q) );end if;end process;end architecture behave;移位寄存器library ieee;use ieee.std_logic_1164.all; useieee.std_logic_unsigned.all; entity reg isport(clk,din, dir: in std_logic;op: out std_logic);end entity reg;architecture a of reg issignal q:std_logic_vector(7 downto 0);beginprocess(clk)beginif clk'event and clk='1'thenif dir='0' then q(0)<=din;for i in 1 to 7 loopq(i)<=q(i-1);end loop;else q(7)<=din;for i in 1 to 7 loopq(i-1)<=q(i);end loop;end if;end if;end process;op<=q(7)when dir='0'elseq(0);end architecture a; 分频电路library ieee;use ieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entity divf isport(clk: in std_logic;q: out std_logic);end entity divf;architecture a of divf issignal rst:std_logic;signal qn:std_logic_vector(2downto 0);beginprocess(clk,rst)beginif rst='1'then qn<="000";elsifclk'event and clk='1'thenqn<=qn+1;end if;end process;rst<='1'when qn=6 else'0';q<= qn(2);end architecture a;74LS160计数器library ieee;use ieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entity ls74160 isport(clk,rst,ena,pe:instd_logic;d:in std_logic_vector(3 downto0);count:out std_logic_vector(3downto 0);co:out std_logic);end;architecture behave of ls74160issignal temp:std_logic_vector(3 downto 0);beginprocess(clk,rst,ena,pe)beginif (rst='1')thentemp<="0000";elsif(clk'eventandclk='1')thenif ena='1'thenif pe='1'then temp<=d;elsif temp="1001"thentemp<="0000";co<='1';else temp<=temp+1;co<='0';end if;end if;end if;end process;count<=temp;end behave;10进制计数器library ieee;use ieee.std_logic_1164.all; useieee.std_logic_unsigned.all; entity count10 isport(clk,rst,ena:in std_logi c; count:out std_logic_vector(3 downto 0);co:out std_logic);end count10;architecture behave of count10 issignal temp:std_logic_vector (3 downto 0);beginprocess(clk,rst,ena)beginif (rst='1')thentemp<="0000";elsif(clk'event and clk='1')then if ena='1'thenif(temp="1001")thentemp<="0000";co<='1';else temp<=temp+1;co<='0';end if;end if;end if;end process;count<=temp;end behave;输出逻辑宏单元(OLMC):输出引脚为12~19共8个。
输出逻辑宏单元包括或门、异或门、D触发器、4个4选1多路选择器、输出缓冲器等。
BCD—7段译码library ieee;use ieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entity decord7 isport(a:in std_logic_vector(3downto 0);q:out std_logic_vector(6downto 0);en:out std_logic);end decord7;architecture behave of decord7isbeginprocess(a)begincase a(3 downto 0) iswhen"0000"=>q<="0111111";when"0001"=>q<="0000110";when"0010"=>q<="1011011";when"0011"=>q<="1001111";when"0100"=>q<="1100110";when"0101"=>q<="1101101";when"0110"=>q<="1111101";when"0111"=>q<="0000111";when"1000"=>q<="1111111";when"1001"=>q<="1101111";when others=>q<="0000000";end case;end process;en<='0';end behave;输入缓冲器:输入端为引脚2~9,共有8个输入。