西电EDA满分大作业_第1页
西电EDA满分大作业_第2页
西电EDA满分大作业_第3页
西电EDA满分大作业_第4页
西电EDA满分大作业_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

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

文档简介

1、精选优质文档-倾情为你奉上 EDA报告 题 目 VHDL设计初步 学 院 电子工程学院 专 业 学 号 导师姓名 朱燕 目录 引言 随着大规模集成电路技术和计算机技术的不断发展,在涉及通信、国防、航天、医学、工业自动化、计算机应用、仪器仪表等领域的电子系统设计工作中,EDA技术的含量正以惊人的速度上升;电子类的高新技术项目的开发也逾益依赖于EDA技术的应用。即使是普通的电子产品的开发,EDA技术常常使一些原来的技术瓶颈得以轻松突破,从而使产品的开发周期大为缩短、性能价格比大幅提高。不言而喻,EDA技术将迅速成为电子设计领域中的极其重要的组成部分。第一章 实验部分(流水灯)开始1、程序设计流程图

2、: 开始模8的计数器输出计数电平4M的分频器输出1HZ38译码器依次输出低电平8个二极管灯依次点亮结束2、模块说明第一部分:分频器 因为主板是cyclong-EP16C6Q240C8的主频是4M赫兹,如果直接当做CLK信号,根本无法看清流水灯的变化,所以需要做分频操作。仿照数电课本的例题中的分频器。分频器的实体:entity devide isport( clk :in std_logic; clk_out:out std_logic );end devide;我们可以从程序中看到,输入时clk(外部主频时钟),输出是clk_out(分频后的时钟)。(这是实体的器件图)分频器的结构体: pro

3、cess;用进程语言描述 begin wait until clk'event and clk='1' if(count<)then count<=count+1; clk_out<='0' else count<=(others=>'0'); clk_out<='1' 我们可以从程序中看到wait until clk'event and clk='1'这句是时钟来到意思,当count计数小于时,count自加1,且输出为零,只有当大于时,产生一个高电平脉冲。接下

4、来是对分频器的波形仿真:从波形中我们可以看到分频器的工作.第二部分:模8计数器 我们需要一个计数器来输出计数电频,作为下一步38译码器的输入信号,首先我们来看这个器件的实体:port(clk:in std_logic; dout:out std_logic_vector(2 downto 0) );(这是器件的实体图)输入端口是clk,是接入分频器的时钟信号,输出就是计数电平了。计数器的结构体:architecture arc_m of m issignal count:std_logic_vector(2 downto 0);begin process(clk) beginif rising

5、_edge(clk) then if count<7 then count<=count+1;elsif count=7 then count<="000" end if; end if;a<=count(0);b<=count(1);c<=count(2);end process; 以上是模8计数器的结构体,我们可以看到,但时钟来到时,在count小于7时count加一,当count=7时,count清零。接下来是对计数器波形的仿真: dout输出000,001,010,011,100,101,110,111,000,001这符合我们的

6、要求。第三部分:38译码器因为我们使用是共阴极二极管,38译码器每接受一个来自计数器的点平时,对应的Yn就输出低电平,点亮此二极管。我们就可以看到二极管依次点亮好似流水一般。译码器的实体:port(a,b,c:in std_logic; y:out std_logic_vector(7downto 0); 输入是a,b,c从低到高的三个,输出是y对应的译码电平。(这是译码器的原件图)译码器的结构体:architecture arc_yima38 of yima38 issignal comb:std_logic_vector(2 downto 0); begin comb<=x; pro

7、cess(comb) begin case comb is when "000" =>y<= "" when "001" =>y<= "" when "010" =>y<= "" when "011" =>y<= "" when "100" =>y<= "" when "101" =>y<= "&

8、quot; when "110" =>y<= "" when "111" =>y<= "" when others =>y<=null; end case; end process;我们可以看到如下的波形:在y的输出波形中,“0”循环右移,这是我们想要的结果。第四部分:总体效果3、遇到的问题和解决方法 我使用的是原理图连接,在下到片子后我编译失败,经过同学和我的检查,终于发现我的原理图连接有问题,如上图所示,我将y2.0连接到译码器的输入端(a,b,c),这是不正确的,因为y2.

9、0是(vector)矢量,而(a,b,c)是位,我错误的以为用线连起来就可以使用,但事实是矢量必须配对矢量,位配对位。第二章 习题部分(Ex-1)画出下例实体描述对应的原理图符号元件: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; ou

10、tput : OUT STD_LOGIC); END ENTITY mux21;(Ex-2)图中所示的是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。) 答:首先为用IF

11、 THEN 语句实现程序如下:library IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL;entity mux41 isport(a,b,c,d:in std_logic; s1,s0:in std_logic_vector(1 downto 0); y:out std_logic );end entity mux41;architecture one of mux41 isbegin process(a,b,c,d,s1,s0) begin if s1='0'and s0='0&

12、#39; then y<=a; else if s1='0'and s0='1' then y<=b; else if s1='1'and s0='0' then y<=c; else if s1='1'and s0='1' then y<=d; end if;end process;end architecture one;用 case 语句程序如下:library IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_

13、UNSIGNED.ALL;entity mux41 isport(a,b,c,d:in std_logic; s1,s0:in std_logic; -这里s1 s0没有定义成2位矢量 y:out std_logic );end entity mux41;architecture one of mux41 issignal l1:std_logic_vector(1 downto 0); -中间信号为两位矢量,为了使用&begin process(a,b,c,d,s1,s0) begin l1<=s1&s0; case l1 is when "00"=

14、>y<=a; when "01"=>y<=b; when "10"=>y<=c; when "11"=>y<=d; end case;end process;end architecture one;(Ex-3)图中所示的是双2选1多路选择器构成的电路MUXK,对于其中MUX21A,当s='0'和'1'时,分别有y<='a'和y<='b'。试在一个结构体中用两个进程来表达此电路,每个进程中用CASE语句描述一个2

15、选1多路选择器MUX21A。 library ieee;use ieee.std_logic_1164.all;entity muxk is port ( a1,a2,a3:in std_logic; -待选择变量 temp:buffer std_logic; -中间信号 s1,s0:in std_logic; -控制端 output:out std_logic); -输出结果end muxk;architecture pr1 of muxk is beginprocess(a2,a3,s0) -process1 begincase s0 is -使用case语句when '0'

16、;=> temp<=a2;when '1'=> temp<=a3;end case;end process;process(a1,temp,s1) -process2begincase s1 iswhen '0'=> output<=a1;when '1'=> output<=temp;end case;end process;end pr1; (Ex-4)图中是一个含有上升沿触发的D触发器的时序电路,试写出此电路的VHDL设计文件。 library IEEE; USE IEEE.STD_LOGIC

17、_1164.ALL; entity dff is port(cl,clk0:in std_logic; out1:out std_logic);end entity dff;architecture one of dff issignal q1,q2:std_logicbegin process(clk) begin if rising edge(clk) then q2=not q1; q1=not(cl and q2); end if; end process; out<=q2;end one;(Ex-5)给出1位全减器的VHDL描述。要求:(1)首先设计1位半减器,然后用例化语句将

18、它们连接起来,图中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 h1 of

19、 h_suber is begin diff<=x xor y; -根据真值表写出差和借位 s_out<=(not x)and y; -得到的逻辑关系end h1;library ieee;use ieee.std_logic_1164.all;entity or2 is - 或门port (a,b:in std_logic; c:out std_logic); end or2;architecture one of or2 is begin c<=a or b;end one;library ieee;use ieee.std_logic_1164.all;entity f

20、_suber is -定义全减器port(x1,y1,sub_in:in std_logic; -x1,y1 为减数和被减数,subin为借位输入 sub_out,diffr:out std_logic); -diffr为输出差,sub_out为借位输出end f_suber;architecture one of f_suber is component h_suber -引用半减器例化声明 port(x,y:in std_logic; diff,s_out:out std_logic);end component;component or2 -引用或门例化声明 port(a,b:in st

21、d_logic; c:out std_logic);end component;signal d,e,f:std_logic; -敏感信号列表例化声明beginu1:h_suber port map(x=>x0,y=>y0,diff=>d,s_out=>e); -引用半减器u2:h_suber port map(x=>d,y=>sub_in,diff=>diffr,s_out=>f); -引用半减器u3:or2 port map(a=>f,b=>e,c=>sub_out); -引用或门end one; (2)8位减法器libra

22、ry IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL;entity f8_suber is  port(a:in std_logic_vector(8 downto 1);      -定义输入为8位数,输   b:in std_logic_vector(8 downto 1);     &#

23、160;  -出为8位,s_in为借位输s_in:in std_logic;       -入,s_out为借位输出 c:out std_logic_vector(8 downto 1);        s_out:out std_logic); end entity f8_suber; architecture behave of f8_sube

24、r is component f_suber  -全减器的例化 port(x,y,sub_in:in std_logic;      diffr,sub_out:out std_logic); end component; signal stmp:std_logic_vector(8 downto 1); - 定义中间信号begin  stmp(0)<=s_in;s_out<

25、=stmp(8); gensub:for i in 1 to 8 generate  -generate为生成相同元件多次例化 u1:f_suber port map(x=>a(i),y=>b(i), sub_in=>stmp(i), diffr=>c(i),sub_out=>stmp(i+1);end generate; end architecture behave; (Ex-6)根

26、据下图,写出顶层文件MX3256.VHD的VHDL设计文件。 答: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 one of diff is begin process (clear,d,clk) begin if (clk'event and clk='1') then -上升沿有效 if (clear=&

27、#39;0') then q<='0' -异步清零 else q<=d; end if; end if; end process;end one;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 one1 of jk issignal o1_s,o2_s:std_logic; begin process(a1,a2,clk,o1_s,o2_s

28、) begin if(clk'event 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 o

29、2; end if; end if; o1<=o1_s; o2<=o2_s; end process; end one1;library ieee;use ieee.std_logic_1164.all;entity mux21 is port (a,b,s:in std_logic; c:out std_logic);end entity;architecture bhv of mux21 isbegin process (a,b,s) -敏感信号列表 begin if s='0' then c<=a; else c<=b; end if; end p

30、rocess; end bhv; library ieee;use ieee.std_logic_1164.all;entity max3256 is -定义顶层文件 port (ina,inb,inck,inc:in std_logic; -采用例化语句实现 e,out1:out std_logic);end max3256;architecture bhv1 of max3256 is component jk -jk触发器port(a1,a2,clk: in std_logic; o1,o2: buffer std_logic);end component;component max3256 - max3256例化port (a,b,s:in std_logic; c:out std_logic);end component;component diff -D触发器port(d,clk:in std_logic; clear:in std_logic; q:out std_logic);end component;signal m1

温馨提示

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

评论

0/150

提交评论