PLD实验报告.doc_第1页
PLD实验报告.doc_第2页
PLD实验报告.doc_第3页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

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

文档简介

pld实验报告 实验内容:用4*3键盘作为输入,在8*8的led显示屏上采用动画过度的效果显示相应的字符,并以两个按键作为复位和字符循环播放模式。电路结构:1.4*3数字键盘键盘的按键识别方式采用行扫描,实际电路中由于列输入端在悬空时被内部电路拉高而呈逻辑1,所以需要使用低电平作为行扫描标志,相应的,列接收端以低电平作为有效信号。由于按键存在一定的抖动,所以在扫描时可以采用较低的扫描频率,也可以通过计数器保证一次按键的有效识别。2.8*8的led显示屏:8*8led显示屏可采用行扫描来进行显示,行以高电平作为扫描标志连接某一行的二极管的阳极,而列以低电平作为二极管的阴极输出。但由于fpga驱动能力有限,不可能同时驱动一整排的led灯管,所以实验板上采用反向器提高其驱动能力,相应的在fpga端,应使用以低电平作为标志的行扫描信号。3. 普通按键电路板上有四个被电路拉高为逻辑1的按键,在按键时呈现低电平,作为复位信号以及字符循环显示的模式选择。程序结构:1. 字符矩阵采用常量的方式存储大量的字符显示所需的矩阵信息:type romtable is array (0 to 7) of std_logic_vector(7 downto 0);constant zero:romtable:=romtable(11000011, 10111101, 10111101, 10111101, 10111101,10111101, 10111101, 11000011);constant one:romtable:=romtable(11100111, 11000111, 11100111, 11100111, 11100111,11100111, 11100111, 11000011);constant two:romtable:=romtable(11000011, 10011001, 10111001, 11111011, 11110111,11101111, 11011111, 10000001);constant three:romtable:=romtable(11000011, 11111001, 11111101, 11100011, 11111101,11111101, 11111001, 11000011);constant four:romtable:=romtable(11110111, 11101111, 11011111, 10110111, 10110111,10000001, 11110111, 11110111);constant five:romtable:=romtable(11000001, 11011111, 11000011, 11111001, 11111101,11111101, 10111001, 11000011);constant six:romtable:=romtable(11110111, 11101111, 11011111, 10100011, 10111101,10111101, 10111101, 11000011);constant seven:romtable:=romtable(10000001, 11111101, 11111011, 11110111, 11101111,11011111, 11011111, 11011111);constant eight:romtable:=romtable(11000011, 10111101, 10111101, 11000011, 10111101,10111101, 10111101, 11000011);constant nine:romtable:=romtable(11000011, 10111101, 10111101, 10111101, 11000001,11111101, 11111101, 11000011);constant star:romtable:=romtable(11111111, 11101111, 10101101, 11000011, 11101111,11010111, 10111011, 11111111);constant sharp:romtable:=romtable(11111111, 11011011, 10000001, 11011011, 11011011,10000001, 11011011, 11111111);constant act1:romtable:=romtable(00000000, 00000000, 00000000, 00011000, 00011000,00000000, 00000000, 00000000);constant act2:romtable:=romtable(00000000, 00000000, 00111100, 00111100, 00111100,00111100, 00000000, 00000000);constant act3:romtable:=romtable(00000000, 01111110, 01111110, 01111110, 01111110,01111110, 01111110, 00000000);constant act4:romtable:=romtable(11111111, 11111111, 11111111, 11111111, 11111111,11111111, 11111111, 11111111);constant window1:romtable:=romtable(00000000, 00000000, 00111100, 00100100, 00100100,00111100, 00000000, 00000000);constant window2:romtable:=romtable(00000000, 01111110, 01000010, 01000010, 01000010,01000010, 01111110, 00000000);constant window3:romtable:=romtable(11111111, 10000001, 10000001, 10000001, 10000001,10000001, 10000001, 11111111);constant window4:romtable:=romtable(00000000, 00000000, 00000000, 00000000, 00000000,00000000, 00000000, 00000000);对应的图像如下:其中前12个对应键盘上的字符,而最后8个用作动画的窗。2.分频器整个程序使用一个process作为分频模块,采用多次渐进分频的方法,提供多种频率信号的输出,程序如下:signal clk4:std_logic:=0;signal clk5:std_logic:=0;signal clk6:std_logic:=0;clocks:process(clk,reset)variable clk1:std_logic_vector(7 downto 0):=00000000;variable clk2:std_logic_vector(7 downto 0):=00000000;variable clk3:std_logic_vector(7 downto 0):=00000000;beginif reset=0 then-在需要的时候重置分频器参数。clk1:=00000000;clk2:=00000000;clk3:=00000000;elsif rising_edge(clk) then-计数器工作,采用系统时钟50mhz,端口“y11”clk1:=clk1+1;if clk1=11111010 then-250clk1:=00000000;clk2:=clk2+1;end if;if clk2=11111010 then-clk2每计数到250时跳变为0clk2:=00000000;clk3:=clk3+1;clk5=not clk5;-clk5产生400hz的信号,作为8*8led显示屏的扫描频率的8倍end if;if clk3=00100000 then-clk3每计数到32时跳变为0clk3:=00000000;clk4=not clk4;-clk4产生12hz的信号,作为数字键盘的扫描频率的4倍end if;clk6=clk3(5);end if;end process;3. 数字键盘扫描:采用clk4信号作为扫描时钟,同时使用复位信号reset进行复位,程序如下:signal rowtemp:std_logic_vector(3 downto 0):=0000;scan:process(clk4,reset)-update rowvariable rowtemp00:std_logic_vector(3 downto 0):=0000;-采用内部信号进行计数。beginif reset=0 then rowtemp00:=0000;rowtemp=0000;row rowtemp00:=0011;when0011= rowtemp00:=0110;when0110= rowtemp00:=1001;when1001= rowtemp00:=0000;when others= rowtemp00:=0000;end case;case rowtemp00 iswhen0000= row row row row row=0111;end case;rowtemp lastcount=count00;-有新的有效按键输入,存储上一次按键count00:=rowtemp+0001;-由行地址和列地址生成字符地址dcount lastcount=count00;count00:=rowtemp+0010;dcount lastcount=count00;count00:=rowtemp+0011;dcount lastcount=count00;count00:=count00;if dcount/=11 then dcount=dcount+1; end if;end case;elsif style=0 then-字符循环显示功能lastcount count00:=0010;when0010= count00:=0011;when0011= count00:=0100;when0100= count00:=0101;when0101= count00:=0110;when0110= count00:=0111;when0111= count00:=1000;when1000= count00:=1001;when1001= count00:=1010;when1010= count00:=1011;when1011= count00:=1100;when1100= count00:=0001;when others= count00:=0001;end case;end if;count=count00;colout=col;count2=count00;end if;end process;按键(字符地址)第1列第2列第3列第1行1(0001)2(0010)3(0011)第2行4(0100)5(0101)6(0110)第3行7(0111)8(1000)9(1001)第4行*(1010)0(1011)#(1100)5.字符显示使用50hz的刷屏速度,将上一个按键所对应的矩阵与本次按键所对应多的矩阵分别与act和lastact相乘后相加,再与边框矩阵window相加得到需要显示的矩阵,示例如下:若上一个字符为0,本次字符为4:若上一个字符为2,本次字符为#:程序如下:showkey:process(clk5,reset)variable rowtemp2:std_logic_vector(7 downto 0):=00000000;variable ncol2:integer range 0 to 7:=0;variable act:romtable;variable window:romtable;variable lastact:romtable;variable col2temp:std_logic_vector(7 downto 0):=00000000;variable col2temp2:std_logic_vector(7 downto 0):=00000000;beginif reset=0 then-清除存储的案件所对应的字符信息rowtemp2:=11111111;ncol2:=0;row2=11111111;col2 rowtemp2:=11111101;ncol2:=1;-ncol2便于提取显示字符的每一行信息when11111101= rowtemp2:=11111011;ncol2:=2;when11111011= rowtemp2:=11110111;ncol2:=3;when11110111= rowtemp2:=11101111;ncol2:=4;when11101111= rowtemp2:=11011111;ncol2:=5;when11011111= rowtemp2:=10111111;ncol2:=6;when10111111= rowtemp2:=01111111;ncol2:=7;when01111111= rowtemp2:=11111110;ncol2:=0;when others= rowtemp2:=11111110;ncol2:=0;end case;row2 act:=act1;window:=window1;when01= act:=act2;window:=window2;when10= act:=act3;window:=window3;when11= act:=act4;window:=window4;when others= act:=act4;window:=window4;end case;for i in 0 to 7 loop-lastact = not actlastact(i):=not act(i);-上一次按键对应的动作矩阵lastact-与本次按键所对应的动作矩阵act相反end loop;case count is-形成本次按键所对应字符矩阵的显示范围when0001= col2temp:=one(ncol2) and act(ncol2);when0010= col2temp:=two(ncol2) and act(ncol2);when0011= col2temp:=three(ncol2) and act(ncol2);when0100= col2temp:=four(ncol2) and act(ncol2);when0101= col2temp:=five(ncol2) and act(ncol2);when0110= col2temp:=six(ncol2) and act(ncol2);when0111= col2temp:=seven(ncol2) and act(ncol2);when1000= col2temp:=eight(ncol2) and act(ncol2);when1001= col2temp:=nine(ncol2) and act(ncol2);when1010= col2temp:=star(ncol2) and act(ncol2);when1011= col2temp:=zero(ncol2) and act(ncol2);when1100= col2temp:=sharp(ncol2) and act(ncol2);when others= col2temp:=11111111 and act(ncol2);end case;case lastcount is-形成上一次按键所对应字符矩阵的显示范围when0001= col2temp2:=(one(ncol2) and lastact(ncol2);when0010= col2temp2:=(two(ncol2) and lastact(ncol2);when0011= col2temp2:=(three(ncol2) and lastact(ncol2);when0100= col2temp2:=(four(ncol2) and lastact(ncol2);when0101= col2temp2:=(five(ncol2) and lastact(ncol2);when0110= col2temp2:=(six(ncol2) and lastact(ncol2);when0111= col2temp2:=(seven(ncol2) and lastact(ncol2);when1000= col2temp2:=(eight(ncol2) and lastact(ncol2);when1001= col2temp2:=(nine(ncol2) and lastact(ncol2);when1010= col2temp2:=(star(ncol2) and lastact(ncol2);when1011= col2temp2:=(zero(ncol2) and lastact(ncol2);when1100= col2temp2:=(sharp(ncol2)

温馨提示

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

评论

0/150

提交评论