




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、1-1代码 非门 LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; ENTITY NOT IS PORT(A:IN STD_LOGIC; Y:OUT STD_LOGIC); END ENTITY NOT; ARCHITECTURE ART OF NOT IS BEGIN Y= NOT A; END ARCHITECTURE ART;1-1代码 异或门 LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; ENTITY XOR2 IS PORT(A,B:IN STD_LOGIC; Y:OUT STD_LOGIC); END EN
2、TITY XOR2; ARCHITECTURE ART OF XOR2 IS BEGIN Y=A XOR B; END ARCHITECTURE ART;1-2代码 D触发器的设计 library ieee; use ieee.std_logic_1164.all; entity d_chufa is port ( clk,d:in std_logic; q:out std_logic); end d_chufa; architecture behav of d_chufa is begin process(clk)is begin if(clk event and clk=1)then q=
3、d; end if; end process; end behav;1-3代码异步清零、异步置位功能的边沿JKJK触发器library ieee;use ieee.std_logic_1164.all;entity jk isport( pset,clr,clk,j,k:in std_logic; q,qb:out std_logic);end entity;architecture behav of jk issignal q_s,qb_s:std_logic;beginprocess(pset,clr,clk,j,k)beginif(pset=0)and(clr=1)thenq_s=1;q
4、b_s=0;elsif(pset=1)and(clr=0)thenq_s=0;qb_s=1;elsif(clk event and clk=1)thenif(j=0)and(k=1)thenq_s=0;qb_s=1;elsif(j=1)and(k=0)thenq_s=1;qb_s=0;elsif(j=1)and(k=1)thenq_s=not q_s;qb_s=not qb_s;end if;end if;q=q_s;qb=qb_s;end process;end behav;实验实验2 21 1实验内容:完成下述模块的设计,实现真值表中的半加与半减的功能。提示信息:将加法与减法区分成两个功能
5、模块,使用BLOCK语句将构造体分为两大部分。输 入 值半 加 法 器(A+B)半 减 法 器(A-B)ABSumCarDifferenceBorrow0001101100101001011001002-1代码library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity half is port ( a,b:in std_logic; sum,car,dif,bor:out std_logic);end half;architecture behav of half isbeging1:block
6、beginsum=a xor b;car=a xor b;end block g1;g2:blockbegindif=a xor b;bor=(not a) and b;end block g2;end behav;实验实验2 22 2实验内容:设计一个4位加减法器.要求:a,b:数据输入; sub: 控制端,高电平实现加法功能, 低电平实现减法功能; s:和与差的输出; co:进位与借位的输出。2-2代码library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity subadd isport(s
7、ub:in std_logic; a,b:in std_logic_vector(3 downto 0); s:out std_logic_vector(3 downto 0); co:out std_logic);end entity subadd;architecture behav of subadd issignal temp:std_logic_vector(4 downto 0);beginprocess(sub,a,b) begin if sub=1 then temp=a+b; else temp=a-b; end if;end process;s=temp(3 downto
8、0);co=temp(4);end behav;实验实验3 31 1实验内容:如下表所示为4位双向通用移位寄存器74LS194的真值表,编写程序描述该逻辑,仿真其功能。3-1代码library ieee;use ieee.std_logic_1164.all;entity ls194 is port ( clr,s0,s1,clk,l,r:in std_logic; p:in std_logic_vector(3 downto 0); q:out std_logic_vector(3 downto 0);end ls194;architecture behav of ls194 issigna
9、l qs:std_logic_vector(3 downto 0);beginprocess(clr,s0,s1,clk,l,r)isbeginif(clr=0)then qs=0000;elsif(clk event and clk=1)then if(s1=1)and(s0=1)then qs=p;elsif(s1=0)and(s0=1)thenif(r=1)then qs(3)=1; qs(2 downto 0)=qs(3 downto 1);elsif(r=0)then qs(3)=0;qs(2 downto 0)=qs(3 downto 1);end if;elsif(s1=1)an
10、d(s0=0)thenif(l=1)then qs(0)=1;qs(3 downto 1)=qs(2 downto 0);elsif(l=0)then qs(0)=0;qs(3 downto 1)=qs(2 downto 0);end if; end if;end if;q=qs;end process;end behav;实验实验3 32 2实验内容:38译码器的设计(要求用WITHSELECT语句完成)(图形见下页)。提示信息:常见的38译码器的真值表如右:A0 A1 A20 0 00 0 10 1 00 1 11 0 01 0 11 1 01 1 1Y0 Y1 Y2 Y3 Y4 Y5 Y
11、6 Y71 0 0 0 0 0 0 00 1 0 0 0 0 0 00 0 1 0 0 0 0 00 0 0 1 0 0 0 00 0 0 0 1 0 0 00 0 0 0 0 1 0 0 0 0 0 0 0 0 1 00 0 0 0 0 0 0 1当EN1时,译码器正常工作;当EN=0时,译码器不动作。A0A1A2ENY0Y73-2代码library ieee;use ieee.std_logic_1164.all;entity decode3to8 isport(a:in std_logic_vector(2 downto 0); en:in std_logic; y:out std_lo
12、gic_vector(7 downto 0);end decode3to8;architecture behav of decode3to8 is signal sel:std_logic_vector(3 downto 0);begin sel=a&en; with sel select Ydoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdout=0000000;end case;end process;end behav;实验实验4 42 2实验内容:设计完成一个7位的偶同位产生器。提示信息:同位共分为
13、两种形式:奇同位:数据位与奇同位的1的个数为奇数。偶同位:数据位与偶同位的1的个数为偶数。n位的偶同位产生器的输入信号为n位,输出信号为n+1位,其中前n位为输入信号,最后一位为偶同位位,且保证输出的n+1位信息中1的个数为偶数个。(奇同位产生器工作原理类似)4-2代码 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity tongwei is port ( a:in std_logic_vector(6 downto 0)
14、; c:out std_logic_vector(7 downto 0); end entity; architecture behav of tongwei is signal temp:std_logic; begin temp=a(0)xor a(1)xor a(2)xor a(3)xor a(4)xor a(5)xor a(6); c=a & temp; end behav;实验实验5 51 1实验内容:完成1位全加器的设计。提示信息:输入为A,B,C,其中A、B为输入数据,C为输入的进位标志位;输出为Sum和Car,其中Sum为本次运算结果位,Car为本次进位标志位。cbas
15、umcbcabacar5-1代码_ library ieee; use ieee.std_logic_1164.all; entity fulladd is port ( a,b,c:in std_logic; car,s:out std_logic); end entity fulladd; architecture behav of fulladd is begin s=a xor b xor c ; car=(a and b)or(b and c)or(c and a); end behav;实验实验5 52 2实验内容:完成4位全加法器的设计。提示信息:一个4位的全加法器可以由4个1位
16、的全加法器级联而成。A(0) B(0)S(0)C(1)C(2)C(3)CoA(1) B(1)S(1)S(2)S(3)A(2)B(2)A(3)B(3)5-2代码_library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity fulladd4 isport( a,b:in std_logic_vector(3 downto 0); c0:out std_logic; s:out std_logic_vector(3 downto 0);end
17、fulladd4;architecture str of fulladd4 issignal c1,c2,c3:std_logic;signal t:std_logic;component fulladdport(a,b,c:in std_logic; car,sum:out std_logic);end component;begint=0;u1:fulladd port map(a(0),b(0),t,c1,s(0);u2:fulladd port map(a(1),b(1),c1,c2,s(1);u3:fulladd port map(a(2),b(2),c2,c3,s(2);u4:fu
18、lladd port map(a(3),b(3),c3,c0,s(3);end architecture str;实验实验6 61 1实验内容:设计一个3bits的可逆计数器。提示信息:由名称可以知道,它的计数方式可以加(检测到CLK时钟的上升沿,计数器加1),也可以减(检测到CLK时钟的上升沿,计数器减1)。使用一个控制信号DIR决定计数器是作加法或减法的动作。6-1代码_updncount_3 is port(clk,clr,updn:in std_logic; qa,qb,qc:out std_logic); end library ieee; use ieee.std_logic_11
19、64.all; use ieee.std_logic_unsigned.all; entity updncount_3; architecture rtl of updncount_3 is signal count_3:std_logic_vector(2 downto 0); begin qa=count_3(0); qb=count_3(1); qc=count_3(2); process (clr,clk)begin if (clr=1)then count_30); elsif (clkevent and clk=1)then if (updn=1)then count_3=coun
20、t_3+1; else count_3=count_3-1; end if; end if; end process; end rtl实验实验6 62 2实验内容:分频器设计。要求:(1)设计一个占空比为50%的6分频器;(2)设计一个占空比为1:2的6分频器。提示信息:占空比为时钟周期中高电平与低电平之比。6-2代码(_)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity fdiv isgeneric(N:integer:=6)
21、;port(clkin:in std_logic;clkout:out std_logic);end fdiv;architecture a of fdiv issignal cnt:integer range 0 to n/2-1;n=6signal temp:std_logic;begin process(clkin)beginif(clkinevent and clkin=1)thenif(cnt=n/2-1)thencnt=0;temp=not temp;elsecnt=cnt+1;end if;end if;end process;clkout=temp;end a;6-2代码,占空
22、比1:2 (_)LIBRARY IEEE;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity shiyan62 is port ( clkin:in std_logic; rest:in std_logic; clk6fen:out std_logic);end; architecture rtl of shiyan62 is signal counter:std_logic_vector(0 to 2); begin process(clkin,coun
23、ter,rest) begin if rest=0 then counter=000; elsif clkinevent and clkin=1then if counter5 then counter=counter+1; if counter3 then clk6fen=1; else clk6fen=0; end if; else counter=000; end if; end if ; end process; end architecture rtl;实验实验7 71 1实验内容:设计完成一10进制加法计数器。该计数器具有同步置数、同步清零的功能。输入信号为:clk,clr,en,
24、datain输出信号为:dataout,co当输入信号clr1时,计数器清零;当置数信号en=1时,计数器装入输入datain为计数初值重新计数;其它情况下,计数器进行10进制加法计数,每计数到9时,输出co1,表示进位。7-1代码(_)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity count10 isport ( clr,clk,en:in std_logic; datain:in std_logic_vector(3 downto 0); co:out std_logic;da
25、taout:out std_logic_vector(3 downto 0);end count10;architecture behav of count10 issignal tmp:std_logic_vector(3 downto 0);beginprocess(clk)beginif(clk event and clk=1)thenif(clr=1)then tmp=0000;elsif(en=1)thentmp=datain;elsif(tmp=1001)then tmp=0000;co=1;else tmp=tmp+1;co=0;end if;end if;end process
26、;dataout=tmp; end behav;实验实验7 72 2实验内容:设计完成100进制加法计数器。要求:采用构造体结构化描述方式由2个10进制计数器级联而成7-2代码_顶层文件:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity count100 isport(clk:in std_logic; co:out std_logic; dout1,dout2:out std_logic_vector(3 downto 0);end count100;architecture beh
27、ave of count100 iscomponent count10 isport(clk:in std_logic; co:out std_logic; dataout:out std_logic_vector(3 downto 0);end component;signal temp:std_logic;beginu1:count10 port map(clk,temp,dout1);u2:count10 port map(temp,co,dout2);end behave;底层文件:library ieee;use ieee.std_logic_1164.all;use ieee.st
28、d_logic_unsigned.all;entity count10 isport(clk:in std_logic; co:out std_logic; dataout:out std_logic_vector(3 downto 0);end count10;architecture behave of count10 issignal temp:std_logic_vector(3 downto 0);begindataout=temp;process(clk)beginif(clkevent and clk=1)then if(temp=1001)then temp=0000; co=
29、1; else temp=temp+1; co=0; end if;end if;end process;end behave;实验实验8-18-1实验内容:LPM兆功能块的使用。 对LPM兆功能单元的lpm_fifo模块进行合理的参数设置,借助仿真手段分析输入、输出端口的功能,并进行简单的说明。实验实验8-28-2实验内容: 利用LPM兆功能单元的lpm_fifo模块实现对连续输入的数据的延时。要求:输入数据宽度为8位,延时时间为5个时钟周期。1-2代码 D触发器的设计 library ieee; use ieee.std_logic_1164.all; entity d_chufa is
30、port ( clk,d:in std_logic; q:out std_logic); end d_chufa; architecture behav of d_chufa is begin process(clk)is begin if(clk event and clk=1)then q=d; end if; end process; end behav;1-3代码异步清零、异步置位功能的边沿JKJK触发器library ieee;use ieee.std_logic_1164.all;entity jk isport( pset,clr,clk,j,k:in std_logic; q,
31、qb:out std_logic);end entity;architecture behav of jk issignal q_s,qb_s:std_logic;beginprocess(pset,clr,clk,j,k)beginif(pset=0)and(clr=1)thenq_s=1;qb_s=0;elsif(pset=1)and(clr=0)thenq_s=0;qb_s=1;elsif(clk event and clk=1)thenif(j=0)and(k=1)thenq_s=0;qb_s=1;elsif(j=1)and(k=0)thenq_s=1;qb_s=0;elsif(j=1
32、)and(k=1)thenq_s=not q_s;qb_s=not qb_s;end if;end if;q=q_s;qb=qb_s;end process;end behav;3-1代码library ieee;use ieee.std_logic_1164.all;entity ls194 is port ( clr,s0,s1,clk,l,r:in std_logic; p:in std_logic_vector(3 downto 0); q:out std_logic_vector(3 downto 0);end ls194;architecture behav of ls194 issignal qs:std_logic_vector(3 downto 0);beginprocess(clr,s0,s1,clk,l,r)isbeginif(clr=0)then qs=0000;elsif(clk event and clk=1)then if(s1=1)and(s0=1)then qs=p;elsif(s1=0)and(s0=1)thenif(r=1)then qs(3)=1; qs(2 downto 0)=qs(3 downto 1);elsif
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 工程技术服务劳动协议年
- 项目管理中的能力提升试题及答案
- 工程项目管理人才发展试题及答案
- 网络游戏开发测试与上线合同
- 工程项目风险控制的方法试题及答案
- 小学生生命安全教育
- 提升企业核心竞争力的总结计划
- 通过社交反馈增强品牌价值计划
- 2025年工程项目管理核心能力试题及答案
- 工程经济学的应用实例分析试题与答案
- UL300标准中文版-2019用于保护商用烹饪设备的灭火系统的耐火测试第四版
- 【MOOC】中西文化鉴赏-郑州大学 中国大学慕课MOOC答案
- 事业单位考试职业能力倾向测验(综合管理类A类)试题与参考答案(2024年)
- 2015-2024年十年高考数学真题分类汇编专题23 导数及其应用大题综合(学生版)
- 水土保持方案投标文件技术部分
- 《新能源汽车》课件 课题四 纯电动汽车
- GB/T 15934-2024电器附件电线组件和互连电线组件
- CQI-23模塑系统评估审核表-中英文
- 2023年重庆市中考化学试卷(B卷)及答案解析
- 湖北省2024年中考生物试卷
- 基于机器学习的腐蚀监测
评论
0/150
提交评论