2016年北航FPGA实验报告.doc_第1页
2016年北航FPGA实验报告.doc_第2页
2016年北航FPGA实验报告.doc_第3页
2016年北航FPGA实验报告.doc_第4页
2016年北航FPGA实验报告.doc_第5页
已阅读5页,还剩19页未读 继续免费阅读

下载本文档

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

文档简介

电气技术实践 可编程逻辑器件FPGA应用开发实验报告姓 名 班 级 学 号 2016年12月电气技术实践报告目 录一、实验目的1二、实验要求1三、实验内容1四、实验代码及实验结果11、4位二进制加法计数器12、半加器33、RS触发器34、数码管十六进制计数器55、跑马灯76、键盘电路97、LED点阵显示128、多人抢答器18五、实验感想18i电气技术实践FPGA报告一、实验目的1、熟悉使用可编程逻辑器件(Altera公司FPGA Cyclone系列EP1C6Q)。2、熟悉使用硬件描述语言VHDL。3、掌握FPGA集成环境(Altera公司FPGA QuartusII 9.0)开发流程。4、熟悉使用核心目标系统板与接口电路等工作原理及其功能模块绑定信息。5、熟悉并掌握下载线方式和下载文件的选择。二、实验要求1、学习并掌握文本、图形等输入和时序、功能仿真方法。2、学习并熟悉门电路、组合电路、时序电路等单一模块功能。3、学习并设计各种不同状态机逻辑功能。4、学习并设计由单一模块较多功能模块集成系统集成方法。5、学习并选择多种模式显示(发光二极管显示、米字型数码管显示、七段数码管动态扫描或静态扫描显示、LED点阵显示各种字符和图形或静止或移动等方式、LCD液晶显示各种字符和图形或静止或移动等方式)。6、根据自已的兴趣和愿望,可从以下给定的实验目录中选取或自已设定功能题目。7、实验数目没有要求,关键是看质量,是否是自已编写、调试、实现。三、实验内容1、按指导书集成开发环境章节操作实现文本编程实例1和图形编程实例2全过程。2、任选门电路、组合电路、时序电路实验各完成一个其逻辑功能,其实现方案自已规定。在进行FPGA目标器件输入和输出引脚绑定时,输入引脚绑定高/低电平、单脉冲、各种分频连续脉冲等多种信号,输出引脚可绑定发光二极管、七段数码管、LED点阵等显示模式。3、在完成1位十进制计数器的基础上,可增加完成2或3等多位十进制计数器逻辑功能并用多位七段数码管来显示。4、用LED点阵显示任意字符、图形等信息。四、实验代码及实验结果1、4位二进制加法计数器(1)实验代码library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity erjinzhi isport(clk,rst:in std_logic;q:out std_logic_vector(3 downto 0);end entity erjinzhi;architecture bhv of erjinzhi issignal q1:std_logic_vector(3 downto 0);beginprocess(rst,clk)beginif(rst=0)thenq1=0000;elsif(clkevent and clk = 1)thenq1=q1+1;end if;end process;q=q1;end architecture bhv;(2)管脚分配(3)实验操作 输入信号clk时钟把FPGA_EA2_P6(Pin_P20)用导线与(FRQ_Q21 1Hz)连接、rst清零N18(SW-1)、输出信号q3U12(LED1)、q2V12(LED2);q1V15(LED3);q0W13(LED4)。 把输入信号rst设为“1”、clk时钟(FRQ_Q21 1Hz) 用导线与(FRQ_Q21 1Hz)连接。(4)实验现象输出结果信息为第一、二、三、四个发光二极管按照000000011111循环显示,符合实验要求。(该实验板上低电平为“1”)2、半加器(1)实验原理图(2)管脚分配(3)实验操作逻辑分析:输入信号a、b;输出信号分别为sum(和)、carry(进位)。逻辑方程:sum=ab;carry=a * b。输入信号aN18(SW-1)、bM20(SW-2)、输出信号sum(和)U12(LED1)、carry(进位)V12(LED2)(4)实验现象输入信号a、b都为“0”,输出结果信息为两个发光二极管均为“灭”,说明和和进位都为0;输入信号a为“1”,b为“0”,输出结果信息为第一个发光二极管“灭”,第二个发光二极管“亮”,说明和为“1”,进位为0;输入信号a为“0”,b为“1”,输出结果信息为第一个发光二极管“灭”,第二个发光二极管“亮” 。说明和为“1”,进位为“0”;输入信号a、b都为“1”,输出结果信息为第一个发光二极管“亮” 第二个发光二极管“灭”,说明和为“0”,进位为“1”.均符合设计要求3、RS触发器(1)实验代码library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity rs_clk isport( s,r,res :in std_logic;q,not_q:out std_logic);end rs_clk;architecture behav of rs_clk issignal sel1,sel2: std_logic;beginprocess(res,sel1,sel2)beginif res=0 then sel1=0;sel2=1;elsif (S=1 and R=0) then sel1=1;sel2=0;elsif (S=0 and R=1) then sel1=0;sel2=1;elsif (S=0 and R=0) then sel1=sel1; sel2=sel2;end if;Q=sel1;not_q=sel2;end process;end behav;(2)管脚分配(3)实验操作(3)实验现象将实验现象总结为RS触发器特性表,其中X指0或1均可;输入为”1”指SW输入为高,输入为”0”指SW输入为低;输出为”1”指对应LED灯灭(实验台的LED灯为高电平灭),输出为”0”指对应LED灯亮。CLK触发输入S输入R原来的Q新的输出Q*100X保持原状11011110011011010100111X不定状态0XXX保持原状4、数码管十六进制计数器(1)实验代码library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity motor isport(clk:in std_logic;rst:in std_logic;sel:out std_logic;q:out std_logic_vector(3 downto 0); d: out std_logic_vector(7 downto 0);end entity;architecture b1 of motor is signal q1,q2:std_logic_vector(3 downto 0);beginprocess(clk,rst)beginif clkevent and clk=1 thenq1=q1+1;q2=0010;end if ;end process;q=q2;process(q1)beginif(rst=1) then seldddddddddddddddd=10001110;end case;end if;end process;end;(2)管脚分配(3)实验现象将CLK接入较低频率,这样可以清晰地观察数码管从0F(16进制数)的转变,完成一个循环之后,自动重新从0开始显示,进入下一个循环5、跑马灯(1)实验代码library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity led isport(clk:in std_logic;rst:in std_logic;q :out std_logic_vector(7 downto 0);end;architecture led of led isconstant s0:std_logic_vector(1 downto 0):=00; constant s1:std_logic_vector(1 downto 0):=01;constant s2:std_logic_vector(1 downto 0):=10;constant s3:std_logic_vector(1 downto 0):=11;signal present:std_logic_vector(1 downto 0); signal q1:std_logic_vector(7 downto 0);signal count:std_logic_vector(3 downto 0);beginprocess(rst,clk)beginif(rst=0)then present=s0;q10);elsif(clkevent and clk=1)thencase present iswhen s0 = if(q1=00000000)then q1=10000000;else if(count=0111)thencount0);q1=00000001;present=s1;else q1=q1(0) & q1(7 downto 1);count=count+1;present if(count=0111)then count0);q1=10000001;present=s2;else q1=q1(6 downto 0) & q1(7);count=count+1;present if(count=0011)thencount0);q1=00011000;present=s3;else q1(7 downto 4)=q1(4) & q1(7 downto 5);q1(3 downto 0)=q1(2 downto 0) & q1(3);count=count+1;present if(count=0011)then count0);q1=10000000;present=s0;else q1(7 downto 4)=q1(6 downto 4) & q1(7);q1(3 downto 0)=q1(0) & q1(3 downto 1);count=count+1;present=s3;end if;end case;end if;end process;q=q1;end;(2)管脚分配(3)实验现象实验开始,除了最左边的LED灯,其余实验箱上一排LED显示器全都点亮;然后随着接入CLK触发信号的频率,每一个触发脉冲,灭的灯往右移动一位(原来灭的灯的右边一位灯灭),而原来灭的灯重新点亮;当最右边一个灯灭了之后,下一个触发脉冲会重置循环,即又开始最左边的灯灭,其余的灯亮。这样从视觉上就是一个黑点从左侧往右侧不断平移,一次移动一位,到达右侧终端后,黑点再次回到左侧,进入下一个周期。6、键盘电路(1)实验代码library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity keyboard isport(clk: in std_logic; start:in std_logic; KBCol: in std_logic_vector(3 downto 0); KBRow: out std_logic_vector(3 downto 0); seg7: out std_logic_vector(6 downto 0); scan: out std_logic_vector(7 downto 0) );end keyboard;architecture bev of keyboard issignal count: std_logic_vector(1 downto 0);signal sta: std_logic_vector(1 downto 0);beginscan= 00000001; a:process(clk)beginif(clk event and clk=1) thencount KBRow=0111;sta KBRow=1011;sta KBRow=1101;staKBRow=1110; staKBRow=1111;end case;end if; end process b;process(clk,start) beginif start=0 thenseg7 case KBCol is when 1110=seg7seg7seg7seg7seg7case KBCol iswhen 1110= seg7 seg7 seg7 seg7 seg7case KBCol iswhen 1110= seg7 seg7 seg7 seg7 seg7case KBCol iswhen 1110= seg7 seg7 seg7 seg7 seg7 seg7=0000000;end case;end if; end if; end process c;end bev;(2)管脚分配(3)实验操作将SW1拨到1,按下键盘上相应的按键,如按下5(4)实验现象LED显示按下键位对应的数字7、LED点阵显示(1)实验代码library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_Unsigned.all; use ieee.std_logic_ARITH.all; ENTITY dianzhen is port(clk:in std_logic; en:in std_logic; hang:out std_logic_vector(15 downto 0);count: out std_logic_vector(3 downto 0);End dianzhen; Architecture dianzhen of dianzhen is signal osc:std_logic; signal x:std_logic_vector(0 downto 0);signal y:std_logic_vector(1 downto 0);signal count1:std_logic_vector(3 downto 0);signal count2:std_logic_vector(25 downto 0);signal data:std_logic_vector(15 downto 0); signal d0,d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15:std_logic_vector(15 downto 0); signal a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15:std_logic_vector(15 downto 0);signal c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15:std_logic_vector(15 downto 0); signal b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15:std_logic_vector(15 downto 0);Begin hang=data; a0=0000000000000000; a1=0000000000000000; a2=0000011111110000; a3=0000010000010000; a4=0000010000010000; a5=0000010000010000; a6=0000010000010000; a7=0111111111111110; a8=0000010000010000; a9=0000010000010000;a10=0000010000010000;a11=0000010000010000;a12=0000011111110000;a13=0000000000000000;a14=0000000000000000;a15=0000000000000000; c0=0000000000000000; c1=0000000000000000; c2=0111111111111110; c3=0100000000000010; c4=0101000000000010; c5=0101000000001010; c6=0101000010001010; c7=0101000010001010; c8=0101111111111010; c9=0101000010001010;c10=0101001010001010;c11=0101010000001010;c12=0101000000000010;c13=0100000000000010;c14=0111111111111110;c15=0000000000000000;b0=0000000000000000; b1=0010000000000000; b2=0001000000000000; b3=0000100000000000; b4=0000010000000000; b5=0000001000000000; b6=0000000110000000; b7=0000000011111110;b8=0000000110000000;b9=0000001000000000;b10=0000010000000000;b11=0000100000000000;b12=0001000000000000;b13=0010000000000000;b14=0000000000000000;a15=0000000000000000;process(osc,en,clk,x,y,count2) begin osc=not clk;x=1; if(osc=1 and oscevent) then count2=count2+1;if (count2=100000) theny=y+1;count20);IF(y=10)theny=00;end if;end if;if(x=0)then if(en=1)then if count1=0000 then data=d0; count1=0001; elsif count1=0001then data=d1; count1=0010; elsif count1=0010then data=d2; count1=0011; elsif count1=0011then data=d3; count1=0100; elsif count1=0100then data=d4; count1=0101; elsif count1=0101then data=d5; count1=0110; elsif count1=0110then data=d6; count1=0111; elsif count1=0111then data=d7; count1=1000;elsif count1=1000then data=d8; count1=1001;elsif count1=1001then data=d9; count1=1010;elsif count1=1010then data=d10; count1=1011;elsif count1=1011then data=d11; count1=1100;elsif count1=1100then data=d12; count1=1101;elsif count1=1101then data=d13; count1=1110;elsif count1=1110then data=d14; count1=1111;elsif count1=1111then data=d15; count1=0000; end if; end if; elsif (x=1)then if(en=1)then if (y=01) then if count1=0000 then data=c0; count1=0001; elsif count1=0001then data=c1; count1=0010; elsif count1=0010then data=c2; count1=0011; elsif count1=0011then data=c3; count1=0100; elsif count1=0100then data=c4; count1=0101; elsif count1=0101then data=c5; count1=0110; elsif count1=0110then data=c6; count1=0111; elsif count1=0111then data=c7; count1=1000;elsif count1=1000then data=c8; count1=1001;elsif count1=1001then data=c9; count1=1010;elsif count1=1010then data=c10; count1=1011;elsif count1=1011then data=c11; count1=1100;elsif count1=1100then data=c12; count1=1101;elsif count1=1101then data=c13; count1=1110;elsif count1=1110then data=c14; count1=1111;elsif count1=1111then data=c15; count1=0000;end if;elsif (y=00) then if count1=0000 then data=b0; count1=0001; elsif count1=0001then data=b1; count1=0010; elsif count1=0010then data=b2; count1=0011; elsif count1=0011then data=b3; count1=0100; elsif count1=0100then data=b4; count1=0101; elsif count1=0101then data=b5; count1=0110; elsif count1=0110then data=b6; count1=0111; elsif count1=0111then data=b7; count1=1000;elsif count1=1000then data=b8; count1=1001;elsif count1=1001then data=b9; count1=1010;elsif count1=1010then data=b10; count1=1011;elsif count1=1011then data=b11; count1=1100;elsif count1=1100then data=b12; count1=1101;elsif count1=1101then data=b13; count1=1110;elsif count1=1110then data=b14; count1=1111;elsif count1=1111then data=b15; count1=0000; end if;elsif (y=10) then if count1=0000 then data=a0; count1=0001; elsif count1=0001then data=a1; count1=0010; elsif count1=0010then data=a2; count1=0011; elsif count1=0011then data=a3; count1=0100; elsif count1=0100then data=a4; count1=0101; elsif count1=0101then data=a5; count1=0110; elsif count1=0110then data=a6; count1=0111; elsif count1=0111then data=a7; count1=1000;elsif count1=1000then data=a8; count1=1001;elsif count1=1001then data=a9; count1=1010;elsif count1=1010then data=a10; count1=1011;elsif count1=1011then data=a11; count1=1100;elsif count1=1100then data=a12; count1=1101;elsif count1=1101then data=a13; count1=1110;elsif count1=1110then data=a14; count1=1111;elsif count1=1111then data=a15; count1=0000; end if; end if; end if; end if;end if;end process;count=count1; end;(2)管脚分配(3)实验操作把FPGA_EA2_P6(Pin_P20)用导线与(FRQ_Q6 32768Hz)连接(4)实验现象可看到点阵依次清晰显示 “中国人”三个汉字8、多人抢答器(1)实验代码抢答模块:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity xuanshou is port(rst,clk2:in std_logic; s0,s1,s2,s3:in std_logic; states:buffer std_logic_vector(3 downto 0); light:buffer std_logic_vector(3 downto 0);warm:out std_logic);end xuanshou ;architecture one of xuanshou issignal st:std_logic_vector(3 downto 0);beginp1:process(s0,rst,s1,s2,s3,clk2) begin if rst=0 then warm=0;st=0000; elsif clk2event and clk2=1 then if (s0=1 or st(0)=1)and not( st(1)=1 or st(2)=1 or st(3)=1 ) then st(0)=1; end if ; if (s1=1 or st(1)=1)and not( st(0)=1 or st(2)=1 or st(3)=1 ) then st(1)=1; end if ; if (s2=1 or st(2)=1)and not( st(0)=1 or st(1)=1 or st(3)=1 ) then st(2)=1; end if ; if (s3=1 or st(3)=1)and not( st(0)=1 or st(1)=1 or st(2)=1 ) then st(3)=1; end if ;warm=st(0) or st(1) or st(2) or st(3);end if ;end process p1;p2:process(states(0),states(1),states(2),states(3),light) begin if (st=0000) then states=0000; elsif (st=0001) then states=0001;elsif (st=0010) then states=0010; elsif (st=0100) then states=0011;elsif (st=1000) then states=0100; end if; light=st;end process p2;end one;倒计时模块:library ieee;use ieee

温馨提示

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

评论

0/150

提交评论