EDA流水灯的设计.doc_第1页
EDA流水灯的设计.doc_第2页
EDA流水灯的设计.doc_第3页
EDA流水灯的设计.doc_第4页
EDA流水灯的设计.doc_第5页
免费预览已结束,剩余13页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

一流水灯控制的设计1.题目1).设计要求设计能让一排灯(8只)自动改变显示花样的控制系统。可将实验板上的一排发光二极管作为彩灯用。控制器应有两种控制方式:规则变化。变化节拍有0.5秒和0.25秒两种,交替出现,每种节拍可有8种花样,各执行一或二个周期后轮换。彩灯变化方向有单向移动,双向移动,跳跃移动等。 随机变化。变化花样相同,但节拍及花样的转换都随机出现。 2)设计提示灯光移动用移位寄存器实现。各种花样,有的可以存于寄存器中,使用时并行置人移位寄存器,有的可以利用环形计数器或扭环计数器实现。节拍信号可选用实验板上的振荡器,花样控制信号可用计数器控制。随机信号可以用长度大于是15的伪随机序列信号发生器或用高速时钟驱动上述4位计数器得到。 2引言EDA技术就是以计算机为工具,设计者在EDA软件平台上,用硬件描述语言VHDL完成设计文件,然后由计算机自动地完成逻辑编译、化简、分割、综合、优化、布局、布线和仿真,直至对于特定目标芯片的适配编译、逻辑映射和编程下载等工作。随着EDA技术发展和应用领域的扩大与深入,EDA技术在电子信息、通讯、自动控制及计算机应用等领域的重要性突出。随着技术市场与人才市场对EDA的需求不断提高,产品的市场需求和技术市场的要求也必然会反映到教学领域和科研领域中来。因此学好EDA技术对我们有很大的益处。EDA是指以计算机为工具,在EDA软件平台上,根据设计社描述的源文件(原理图文件、硬件描述语言文件或波形图文件),自动完成系统的设计,包括编译、仿真、优化、综合、适配(或布局布线)以及下载。3.设计思路1)灯光移动用移位寄存器实现,各种花样,有的可以存于寄存器中,使用时并行置入移位寄存器,有的可以利用环形计数器或扭环计数器实现。 2)节拍信号可选用实验板上的振荡器,花样控制信号可用4位计数器实现控制,1为节拍变化,另三位控制花样。 3)随机信号可以用长度大于15的伪随机序列信号发生器或用高速时钟驱动计数器得到4.代码library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity KKJ isport( clk: in std_logic; clr: in std_logic; choose: in std_logic_vector(2 downto 0); led: out std_logic_vector(7 downto 0) );end KKJ;architecture control of KKJ issignal cnt1:std_logic_vector(1 downto 0);signal cnt2:std_logic_vector(1 downto 0);signal cnt3:std_logic_vector(1 downto 0);signal cnt4:std_logic_vector(1 downto 0);signal cnt5:std_logic_vector(1 downto 0);signal cnt6:std_logic_vector(1 downto 0);signal cnt7:std_logic_vector(1 downto 0);signal cnt8:std_logic_vector(1 downto 0);begin process(clk,clr) begin if clr=0then led=00000000; else if choose=000 then if clkevent and clk=0 then cnt1ledledledled=00010000; end case; elsif choose=001 then if clkevent and clk=1 then cnt2ledledledled=00001000; end case; elsif choose=010 then if clkevent and clk=1 then cnt3ledledledled=00000010; end case; elsif choose=011 then if clkevent and clk=1 then cnt4ledledledled=01000000; end case; elsif choose=100 then if clkevent and clk=0 then cnt5ledledledled=11111111; end case; elsif choose=101 then if clkevent and clk=1 then cnt6ledledledled=00000000; end case; elsif choose=110 then if clkevent and clk=1 then cnt7ledledledled=00000011; end case; elsif choose=111 then if clkevent and clk=1 then cnt8ledledledled=00011000; end case; end if; end if; end process;end architecture control;5.运行结果:1)运行代码运行成功2)波形图上可清楚的看出彩灯的移向。2. 画出下例实体描述对应的原理图符号元件ENTITY buf3s IS - 实体1: 三态缓冲器 PORT (input : IN STD_LOGIC ; - 输入端 enable : IN STD_LOGIC ; - 使能端 output : OUT STD_LOGIC ) ; - 输出端END buf3x ;ENTITY mux21 IS -实体2: 2选1多路选择器 PORT (in0, in1, sel : IN STD_LOGIC; output : OUT STD_LOGIC); END ENTITY mux21;1.三态缓冲器1)代码library ieee;use ieee.std_logic_1164.all;entity ex1 is port (input: in std_logic; -输入端 enable: in std_logic ; -使能端 output : out std_logic ) ; -输出端end ex1;architecture behav of ex1 isbegin process(enable,input) begin if(enable=1) then output=input ; else output=Z; -输出为高阻态Z end if; end process;end behav;2)仿真电路图如下所示: 3) 三态缓冲器的仿真波形图如下:2. 2选1多路选择器1) 代码library ieee;use ieee.std_logic_1164.all;entity ex2 is port ( in0,in1,sel : in std_logic; output : out std_logic); end entity ex2;architecture behav of ex2 is begin with sel select output=in0 when 0, in1 when 1;end behav;2)仿真电路图如下所示:3)选一多路选择器的仿真波形如下:3 图中所示的是4选1多路选择器,试分别用IF_THEN语句和CASE语句的表达方式写出此电路的VHDL程序。选择控制的信号s1和s0为STD_LOGIC_VECTOR类型;当s1=0,s0=0;s1=0,s0=1;s1=1,s0=0和s1=1,s0=1分别执行y=a、y=b、y=c、y=d。 1.代码library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;entity mux41a isport(a,b,c,d:in std_logic; -4个数据输入端 s0,s1:in std_logic; -2个信号控制输入端 y:out std_logic); -数据输出端口end mux41a;architecture behavior of mux41a issignal abc : std_logic_vector(1 downto 0) ; -定义内部信号abcbeginabc y y y yy =null ; end case; end process; end architecture behavior ; 2.四选一数选器仿真电路图如下所示:3.四选一数选器仿真波形如下:4 图中所示的是双2选1多路选择器构成的电路MUXK,对于其中MUX21A,当s=0和1时,分别有y=a和y temp temp output output=temp;end case;end process;end behav; 2.电路MUXK仿真电路图如下所示: 3.电路MUXK仿真波形如下:5 图中是一个含有上升沿触发的D触发器的时序电路,试写出此电路的VHDL设计文件。 1代码.library ieee;use ieee.std_logic_1164.all;entity EX5 is port ( cl:in std_logic; clk:in std_logic; output:buffer std_logic);end EX5;architecture behav of EX5 is begin process (clk)beginif (clkevent and clk=1) then output=not(cl or output);end if;end process;end behav;2.D触发器仿真结果如图所示: 3.D触发器的仿真波形如下: 六给出1位全减器的VHDL描述。要求: (1)首先设计1位半减器,然后用例化语句将它们连接起来,图中h_suber是半减器,diff是输出差,s_out是借位输出,sub_in是借位输入。 (2)以1位全减器为基本硬件,构成串行借位的8位减法器,要求用例化语句来完成此项设计(减法运算是 x y - sun_in = diffr)。 1代码.library ieee;use ieee.std_logic_1164.all;entity h_suber is -定义实体半减器port(x,y:in std_logic; -减数与被减数 diff,s_out:out std_logic); -分别为本位输出和借位输出end h_suber;architecture fd1 of h_suber is begin diff=x xor y; s_out=(not x)and y; end fd1;library ieee;use ieee.std_logic_1164.all;entity or_2 is -定义实体2输入或门port (a,b:in std_logic; c:out std_logic); end or_2;architecture one of or_2 is begin cx0,y=y0,diff=d,s_out=e); -引用半减器u2:h_suber port map(x=d,y=sub_in,diff=diffr,s_out=f); -引用半减器u3:or_2 port map(a=f,b=e,c=sub_out); -引用或门end fs1; 2.1为全加器仿真电路图如下所示: 3.1为全加器的仿真波形为: 七根据下图,写出顶层文件MX3256.VHD的VHDL设计文件。 1代码.library ieee;use ieee.std_logic_1164.all;entity diff is -定义实体D触发器 port(d,clk:in std_logic; clear:in std_logic; q:out std_logic);end entity diff;architecture behav of diff is begin process (clear,d,clk) begin if (clkevent and clk=1) then -时钟信号到来 if (clear=0) then q=0; -异步清零 else q=d; end if; end if; end process;end behav;library ieee;use ieee.std_logic_1164.all;entity jk is -定义实体JK触发器port(a1,a2,clk: in std_logic; o1,o2: buffer std_logic); end; architecture behav1 of jk is signal o1_s,o2_s:std_logic; -定义内部信号o1_s,o2_s begin process(a1,a2,clk,o1_s,o2_s) begin if(clkevent and clk=1)then if(a1=0)and(a2=1)then o1_ s=0, o2_s=1; elsif (a1=1)and(a2=0)then o1_s=1,o2_s=0; elsif(a1=1)and(a2=1)then o1_s=not o1; o2_s=not o2; end if; end if; o1=o1_s; o2=o2_s; end process end behav1library ieee;use ieee.std_logic_1164.all;entity mux21 is -定义实体mux21port (a,b,s:in std_logic; c:out std_logic); end entity; architecture behav2 of mux21 is begin process (a,b,s) begin if s=0 then c=a; else cina,a2=inb,clk=inclk,o1=aa,o2=bb); -引用JK触发器 u2: diff port map (d=bb,clk=inclk,clear=inc,q=cc); -引用D触发器 u3: jk port map (a1=bb,a2=cc,clk=inclk,o1=dd,o2=output); -引用JK触发器 u4: mux21 port map (a=dd,b=aa,s=bb,c=e); -引用mux21end behav3;2.顶层文件MX3256仿真电路图如下所示:3.顶层文件MX3256的仿真波形为: 八设计含有异步清零和计数使能的16位二进制加减可控计数器。 1.代码library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity cnt_16 isport(rst: in std_l

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论