




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、第三章3-5设计一个4选1多路选择器,当选择输入信号分别取“00”、“01”、 “10”和“11”时,输出信号分别与一路输入信号相连。library ieee;use ieee.std_logic_1164.all;entity max4_1 isport(a,b,c,d,s1,s2 : in std_logic;y : out std_logic);end entity max4_1;architecture hf1 of max4_1 issignal ss : std_logic_vector (0 to 1);beginss y y y y null;end case;end proc
2、ess;end hf1;3-6设计一个7人表决电路,参加表决者7人,同意为1,不同意为 0,同意者过半则表决通过,绿指示灯亮;表决不通过则红指示灯亮。设计思路:根据7人表决电路设计要求,7人中至少有4个通过才可以表决通过, 故可以在程序中设置一个变量 temp使其在表决电路中遇1则加1,遇0则加0(设计中1表示通过,0表示不通过)。当temp=4寸,表示表决通过,当tempoutputoutput=1;end case ;end process;end behave;第四章4-6试写出4选1多路选择器vhdl苗述。选择制信号为s1和s0, 输入信号为a, b, c, d,输出彳言号为yolib
3、rary ieee;use ieee.std_logic_1164.all;entity mux41a isport (a,b,c,d,s0,s1:in std_logic;-输入信号y:out std_logic);输出信号end entity mux41a;architecture one of mux41a issignal s:std_logic_vector(1 downto 0);begins y y y ynull;其它情况为空值end case;-case 语句结束end process;-process 进程语句结束end architecture one;4-7使给出1位全
4、减器的vhd描述,要求:首先设计1位半减器,然后 用例化语句将它们连接起来。设x为被减数,y为减数,sub_ina借 位输入,diff是输出差,sub_ou也借位输出。(1.(1) 现 1 位半减器 h_suber(diff=x-y ; s_out=1,xy)library ieee;-半减器描述(1):布尔方程描述方法use ieee.std_logic_1164.all;entity h_suber isport( x,y: in std_logic;diff,s_out: out std_logic);end entity h_suber;architecture hs1 of h_su
5、ber isbegindiff = x xor (not y);s_out xin,y=yin, diff=a,s_out=b);u2:h_suber port map(x=a, y=sub_in, diff=diff_out,s_out=c);sub_out = c or b;end architecture fs1;二进制全加器,元件声明与元件例化(component,port) map/ 或门library ieee; ;use ieee.std_logic_1164.all;entity or2a isport(a,b : in std_logic;c : out std_logic)
6、;end or2a;architecture art1 of or2a isbeginc=a or b;end art1;/半加器;library ieee;use ieee.std_logic_1164.all;entity h_adder isport(a,b : in std_logic;co,so: out std_logic);end h_adder;architecture art2 of h_adder isbeginso = a xor b;co e,b=cin,co=f,so=sum);u3:or2a port map(d,f,cout);end art3;第五章5-1.试说
7、明实体端口模式buffer inout勺不同之处?答:buffers:缓冲模式,具有读功能的输出模式,即信号输出 到实体外部,但同时也在内部反馈使用,不允许作为双向端口使用。 而inout端口:双向模式,即信号的流通是双向的,既可以对此端口 赋值,也可以通过此端口读入数据。5-2.vhdl的数据对象有哪几种?它们之间有什么不同?答:vhdl的数据对象有三种:信号、变量、常量。 它们之间的的区别如下:信号赋值至少有延时,而变量和常量没有;信号除当前值外,有许 多相关信息,变量只有当前值,常量的值在设计实体中始终不变;进程对信号敏感而对变量及常量不敏感;信号可以是多个进程的全局信号, 变量只在定义
8、它们的顺序域可见, 而常量的使用范围取决于它被定义的位置; 信号是硬件连线的抽象描述信号赋值, 赋值符号 = 而变量和常量的赋值符号:= 。5-3. 说明下列各定义的意义:signala , b , c : bit : = 0 ;constant time1 , time2 : time : 20ns ;variablex , y , z : std_logic : = x ;答:c1定义3个位数据类型白力言号 a b、c,它们取值为0;定义2个时间数据类型的常量time! time2,它们值为20ns;定义3个标准逻辑位std_logic数据类型的变量x、y、乙它们 的值是强未知的。5-4.
9、 什么是重载函数?重载运算符有何用处?如何调用重载运算符函数?答:为了方便各种不同数据类型间的运算,vhdl允许用户对原有的基本操作符重新定义, 赋予新的含义和功能, 从而建立一种新的操作符,这就是重载操作符,定义这种操作符的函数成为重载函数。重载运算符的作用是为了方便各种不同的数据类型间的运算。 要调用重载运算符函数, 先要在程序包中进行函数体的定义, 调用的格式如下 :x =函数名(参数1,参数2, )参数个数和类型与所定义的函 数要保持一致。5-5.数据类型bit integer boolean分别定义在哪个库中?哪 些库和程序包总是可见的?答:数据类型 bit integer bool
10、ean均定义在 std库中。ieee 库 和 程 序 包 std_logic.1164 、 std_logic_unsigne、d std_logic_signedstd_logic_arith 总是可见的。5-6. 函数和过程有什么区别?答:子程序有两种类型,即过程(procedure两数(function)它们的区别在于: 过程的调用可以通过其界面获得多个返回值, 而函数只能返回一个值;在函数入口中,所有参数都是输入参数,而过程有输入参数、输出参数和双向参数;过程一般被看作一种语句结构,而函数通常是表达式的一部分; 过程可以单独存在, 而函数通常作为语句的一部分调用。5-7.若在进程中加入
11、wait吾句,应注意哪几个方面的问题?答:应注意以下问题:已列出敏感信号的进程中不能使用任何形式的wait语句;(2一般情况下,只有 waituntil格式的等待语句可以 被综合器所接受,其余语句格式只能在 vhd助真器中使用;c3在使 用waitons句的进程中,敏感信号量应写在进程中的 waiton语句 后面;且在不使用waiton语句的进程中,敏感信号量应在开头的关 键词process面的敏感信号表中列出。5-8.哪些情况下需用到程序包std_logic_unsigned?-例。答:调用数据类型变换函数或重载运算符函薮时;定义unsigned类型的数据时。举例如下:library iee
12、e;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;if temp=11111111then temp:= 00000000;else temp尸temp+16;end if; 一 5-9. 为什么说一条并行赋值语句可以等效为一个进程?如果是这样的话,怎样实现敏感信号的检测?答: 因为信号赋值语句的共同点是赋值目标必须都是信号, 所有赋值语句与其它并行语句一样, 在结构体内的执行是同时发生的, 与它们的书写顺序没有关系, 所以每一信号赋值语句都相当于一条缩写的进程语句。 由于这条语句的所有输入信号都被隐性地列入此缩写进程的
13、敏感信号表中, 故任何信号的变化都将相关并行语句的赋值操作, 这样就实现了敏感信号的检测。5-10.比较caseg句和 with_select句,叙述它们的异同点?答:相同点:case语句中各子句的条件不能有重叠,必须包容所有的条件;with_seclec语句也不允许选择值有重叠现象,也不允许选择值涵盖不全的情况。 另外, 两者对子句各选择值的测试都具有同步性,都依赖于敏感信号的变化。不同点:case语句只能在进程中使用,至少包含一个条件语句,可以有多个赋值目标; with_seclect语句根据满足的条件,对信号进行赋值,其赋值目标只有一个,且必须是信号。5-11.将以下程序段转换为 whe
14、n_elsej:process (a , b ,c ,d)beginif a= 0 and b= 1 then next1 1=101 ;elseif a=0 then next1 =d;elseif b= 1 then next1 =c;else next11=011 ;end if;end process;原程序转换如下 :architecture one of mux isbeginprocess (a , b ,c ,d)begin0 else1 elsenext1 =1101when a= 0 and b= 1 elsed when a= c when b= 1011;end one
15、;end process;5-12 使给出一位全减器的算法描述、数据流描述、结构描述和混合描述。数据流描述:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity f_sub1 isport(a,b :in std_logic;cin :in std_logic;diff,cout : out std_logic);end;architecture a of f_sub1 issignal s :std_logic_vector(2 downto 0);begins=cin&a&b;proc
16、ess(a,b,cin)begincase s iscout=0cout=1cout diff diff diff=1cout=0cout=1cout=1cout=0cout diff diff diff diff diff diff=x;cout=x; end case;end process;end a;行为描述:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity f_sub4 isport(a,b,cin : in std_logic;diff,cout : out std_log
17、ic);end;architecture a of f_sub4 isbegindiff=a xor b xor cin;cout=(not a and b) or (not a and cin) or (b and cin);end a;5-13用vhdi尸懦件的功能:(1)十进制一一bc网编码器,输出使能为低电平有效。library ieee;use ieee.std_logic_1164.all;entity bin_bcd isport(bin : in integer range 0 to 20;-ena: in std_logic;bcd_out : out std_logic_v
18、ector(7 downto 0);end;architecture a of bin_bcd isbeginbinary_bcd : blockbeginbcd_out = 00000000 when bin = 0 else 00000001 when bin = 1 else 00000010 when bin = 2 else 00000011 when bin = 3 else 00000100 when bin = 4 else 00000101 when bin = 5 else00000110 when bin = 6 else00000111 when bin = 7 els
19、e00001000 when bin = 8 else00001001 when bin = 9 else00010000 when bin = 10 else00010001 when bin = 11 else00010010 when bin = 12 else00010011 when bin = 13 else00010100 when bin = 14 else00010101 when bin = 15 else00010110 when bin = 16 else00010111 when bin = 17 else00011000 when bin = 18 else0001
20、1001 when bin = 19 else00100000 when bin = 20 else00000000;end block;end a;(2)时钟(可控)rs蛾器。library ieee;use ieee.std_logic_1164.all;entity ffrs isport(s,r: in std_logic;q,qb: out std_logic);end ffrs;architecture rtl of ffrs issignal qn,nqn: std_logic;beginqn= r nor nqn;nqn= s nor qn;q=qn;qb=nqn;end rt
21、l;(3)带复位端、置位端、延迟为15ns的响应cp下降沿触发的jk触发器。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity jkff isport(j,k,rst,clr : in bit;clk : in bit;q,nq : out bit);end;architecture a of jkff issignal q_s,nq_s : bit;beginprocess(j,k,rst,clr,clk)beginif rst=1 thenq_s=1;nq_s=0;elsif clk
22、event and clk=0 thenif clr=1 thenq_s=0;nq_s=1;elsif j=0 and k=1 thenq_s=0;nq_s=1;elsif j=1 and k=0 thenq_s=1;nq_s=0;elsif j=1 and k=1 thenq_s=not q_s;nq_s=not nq_s;end if;elsenull;end if;q=q_s;nq=nq_s;end process;end a;( 4)集成计数器74161library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigne
23、d.all;entity cnt4 isport(clk,ldn,clrn : in std_logic;d,c,b,a : in std_logic;carry: out std_logic;qd,qc,qb,qa : out std_logic);end;architecture a of cnt4 issignal data_in: std_logic_vector(3 downto 0);begindata_in0);elsif clkevent and clk=1 thenif ldn=0 thencnt:=data_in;elsecnt:=cnt+1;end if;end if;c
24、ase cnt iswhen 1111= carry carry=0;end case;qa=cnt(0);qb=cnt(1);qc=cnt(2);qd=cnt(3);end process;end a;5-14用vhd描述一个三态输出的双4选一的数据选择器,其地址信 号共用,且各有一个低电平有效的使能端。library ieee;use ieee.std_logic_1164.all;entity dual_mux_41 isport(a,b,c,d : in std_logic;ena_n,enb_n : in std_logic;s : in std_logic_vector(1 dow
25、nto 0);outa,outb : out std_logic);end;architecture a of dual_mux_41 issignal p,q : std_logic_vector(2 downto 0);beginp=ena_n & s;q=enb_n & s;with p selectouta=a when 000,b when 001,c when 010,d when 011,z when others;with q selectoutb=a when 000,b when 001,c when 010,d when 011,z when others;end a;5
26、-15 试用并行信号赋值语句分别描述下列器件的功能:(1) 3-8译码器(2) 8 选 1 数据选择器1)功能描述如下:library ieee;use ieee.std_logic_1164.all;entity decoder38 isport(a,b,c,g1,g1a,a2b:in std_logic;q:out std_logic_vector(7 downto 0);end decoder38;architecture behave38 of decoder38 issignal inda: std_logic_vector(2 downto 0);beginindaqqqqqqqq
27、q=xxxxxxxx;end case;elseq=11111111;end if;end process;end behave38;( 2)功能描述如下:library ieee;use ieee.std_logic_1164.all;entity mux8 isport(d0,d1,d2,d3,d4,d5,d6,d7:in std_logic_vector(7 downto 0);s0,s1,s2:in std_logic;q:out std_logic_vector(7 downto 0);end mux8;architecture behave of mux8 issignal s: std_logic_vector(2 downto 0);begins =s2&s1&s0;with s seclectd =d0 when 000,d1 when 001,d2 when 010,d3 when 011,d4 when 100,d5 when 101,d6 when 110,d7 when 111, x when others;end behave;5-16 利用生产语句描述一个由 n 个一位全减器构成的 n 位减法器, n的默认
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年医院感染标准预防考试题及答案
- 九年级化学下册 第10单元 化学与健康 第2节 化学元素与人体健康说课稿 (新版)鲁教版
- 2024-2025学年第一学期期中考试-初一语文-试卷
- 蒸汽热网基础知识培训课件
- 2025年企业、公司薪酬管理技能资格知识试题与答案
- 2025年上海市中考生物试卷+答案解析
- 人工智能应用基础 课件 项目1 人工智能工具操作基础
- 2025年解除合同关系的申请书范本
- 消防中控题目技巧及答案
- 葡萄酒盲品知识培训总结
- 智能采矿导论完整整套教学课件
- 初中信息技术奥赛基础知识
- 工业设计方法学
- 非计划再次手术管理制度与流程
- 销售公司和生产公司的合作协议
- 新生儿气管导管滑脱的应急预案及处理流程
- 建筑模型设计与制作(第三版)
- 部编版一年级语文上册全册教案(表格)
- 商品精修教案项目5服装精修
- 小升初简历模板2020免费
- 《社会主义核心价值观》优秀课件
评论
0/150
提交评论