VHDL点阵显示
- 格式:doc
- 大小:521.50 KB
- 文档页数:12
第20、21讲 VHDL的实践(3)—点阵显示系统的设计【课前思考】数字逻辑中关于音乐芯片的设计的过程是怎样的?【学习目标】理解点阵显示系统的设计原理并分析清楚用VHDL实现一个点阵显示系统乐芯片的全部代码描述。
【重 难 点】重点:分析实现一个点阵显示系统的全部VHDL代码描述难点:点阵显示系统的设计原理【教学安排】学时:2 学时【知 识 点】8.3点阵显示系统的设计 (1)8.3点阵显示系统的设计1 系统结构与原理图1是系统的结构框图。
本系统选用的FPGA芯片是美国Altera公司的FLEX10K系列的EPF10K10LC84-4。
该芯片具有576个逻辑单元、84个引脚、72个逻辑阵列块、3个嵌入式阵列块,是一个高集成度的FPGA芯片。
系统由FPGA中的扫描控制模块、只读存储器ROM和FPGA外面的LED点阵显示模块、一个反相器和两个4-16译码器构成。
其中,DZ1、DZ2、DZ3、和DZ4是4个8×8的LED点阵显示模块,由这四个模块组合起来构成了本系统16×16的LED点阵显示模块。
两个4-16译码器(74LS154)和一个反相器配合FPGA中的行扫描控制模块共同完成了16×16点阵显示模块的32行的扫描控制。
FPGA中的只读存储器ROM中保存了要显示的多幅图像的数据,并以8位的数据宽度输出到LED阵显示模块的列端,配合行扫描控制共同完成多幅图像的显示。
图1 系统的结构框图2 扫描控制模块本系统的LED点阵模块如图2所示,共由16×16=256个LED发光二极管组成。
如何在该点阵模块上显示一幅图像是本设计的关键技术。
本设计是采用的一种32路动态分时扫描技术来实现的。
具体方法是,将如图1所示4个8×8阵列的显示模块DZ1、DZ2、DZ3、DZ4采用串行级联的方式构成为一个32行8列的扫描结构。
其列输入端与FPGA内的只读存储器ROM的8位数据输出端口相连;32个行控制端与两个4-16译码器A、B的输出相连;而译码器A、B的输入端和片选信号又与FPGA内的行扫描控制模块的输出端口scan4-scan0相连。
院系:物理与电子工程学院专业:电子信息工程班级: 2008级3班指导老师:谢小维姓名:刘进学号: 200807014321 实验时间: 2010年12月12日基于VHDL的汉字点阵动态显示系统的设计一、实验目的(1)在MAX+plus II软件平台上,熟练运用VHDL语言,完成16*16点阵的显示设计的软件编辑、编译、综合、仿真。
(2)使用EDA实验箱,实现16*16点阵显示的硬件功能。
(3)学习设计仿真工具的使用方法。
(4)学习层次化设计方法。
二、实验仪器16*16点阵(如图一)、EDA实验箱、MAX+plus II,导线若干图一、16*16点阵三、实验原理3.1 主要原理用动态时钟扫描技术使LED点阵模块显示出我们需要的汉字的列扫描的代码数据。
在有笔划下落处的小方格里填上“1”,无笔划处填上“0”,这样就形成了与这个汉字所对应的二进制数据在该矩形框上的分布。
最后用一个时钟扫描来控制让其输出。
3 .2汉字的显示第二步工作的步骤是:先在扫描模块的控制下,由地址线确定每次由ROM 送出某一列的16个LED所要显示的汉字的控制字节数据,同时由扫描模块输出的5位扫描码经两个4-16译码器解码后决定相应的某一列可以被点亮,而另外31列都不能被点亮。
该状态持续约0.4毫秒后,就接着进行下一行的扫描。
当完成了一次32行的扫描后,也就完成了一帧画面的显示。
重复上述过程不断修改ROM的地址区间的起始地址,转向下一幅画面的数据传送和显示。
如此进行,就可以在LED点阵模块上滚动显示ROM中存储的汉字。
四、VHDL语言程序设计4.1扫描频率控制的部分关键程序process(clk) --显示时序控制beginif clk'event and clk='1' then --上升沿dount<=dount+1;--计数累加if dount=255 thenif S=15 thenS<="0000";--S控制单个汉字扫描周期 elseS<=S+1;end if;S<=S+1;elseS<=S;end if;if cdount<15 then --控制列扫描频率cdount<=cdount+1;elsecdount<="0000";end if;end if;end process;4.2单个汉字扫描的部分关键程序process(cdount,s)begincase cdount iswhen "0000" => lie<="0000";when "0001" => lie<="0001";when "0010" => lie<="0010";when "0011" => lie<="0011";when "0100" => lie<="0100";when "0101" => lie<="0101";when "0110" => lie<="0110";when "0111" => lie<="0111";when "1000" => lie<="1000";when "1001" => lie<="1001";when "1010" => lie<="1010";when "1011" => lie<="1011";when "1100" => lie<="1100";when "1101" => lie<="1101";when "1110" => lie<="1110";when "1111" => lie<="1111";when others=>null;end case;if s="0000" thencase cdount isw h e n"0000"=>h a n g<="0100000000001000"; w h e n"0001"=>h a n g<="0010000000101000"; w h e n"0010"=>h a n g<="0001000001001001"; w h e n"0011"=>h a n g<="0000100110001010"; w h e n"0100"=>h a n g<="0000011010001110"; w h e n"0101"=>h a n g<="0000100001001000"; w h e n"0110"=>h a n g<="0011000000111000"; w h e n"0111"=>h a n g<="0110000000001100"; w h e n"1000"=>h a n g<="0000000000001000";w h e n"1001"=>h a n g<="0000000000000000"; w h e n"1010"=>h a n g<="0000111111111100"; w h e n"1011"=>h a n g<="0100000000000000"; w h e n"1100"=>h a n g<="1000000000000000"; w h e n"1101"=>h a n g<="0111111111111111"; w h e n"1110"=>h a n g<="0000000000000000"; w h e n"1111"=>h a n g<="0000000000000000"; when others =>null;end case;end if;if s="0001" thencase cdount isw h e n"0000"=>h a n g<="0000000000000000"; w h e n"0001"=>h a n g<="0100000001000000"; w h e n"0010"=>h a n g<="0010000001000010"; w h e n"0011"=>h a n g<="0001111111001100"; w h e n"0100"=>h a n g<="0010000000000000"; w h e n"0101"=>h a n g<="0100000100001000"; w h e n"0110"=>h a n g<="0100111111111111"; w h e n"0111"=>h a n g<="0100000100001000"; w h e n"1000"=>h a n g<="0100000100001000"; w h e n"1001"=>h a n g<="0100000100001000"; w h e n"1010"=>h a n g<="0111111111111111"; w h e n"1011"=>h a n g<="0100000100001000"; w h e n"1100"=>h a n g<="0100000110001100"; w h e n"1101"=>h a n g<="0110000100001000"; w h e n"1110"=>h a n g<="0010000000000000"; w h e n"1111"=>h a n g<="0000000000000000";when others => null;end case;end if;end process;--结束进程,各个进程之间是并发执行的4.3 整个程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity lcd1 isport (clk:in std_logic;hang:out std_logic_vector(15 downto 0);lie:out std_logic_vector(3 downto 0));end entity;architecture one of lcd1 issignal dount:std_logic_vector(7 downto 0);signal s,cdount:std_logic_vector(3 downto 0); beginprocess(clk)beginif clk'event and clk='1' thendount<=dount+1;if dount=255 thenif s=1 thens<="0000";elses<=s+1;end if;--s<=s+1;elses<=s;end if;if cdount<15 thencdount<=cdount+1;elsecdount<="0000";end if;end if;end process;process(cdount,s)begincase cdount iswhen "0000" => lie<="0000";when "0001" => lie<="0001";when "0010" => lie<="0010";when "0011" => lie<="0011";when "0100" => lie<="0100";when "0101" => lie<="0101";when "0110" => lie<="0110";when "0111" => lie<="0111";when "1000" => lie<="1000";when "1001" => lie<="1001";when "1010" => lie<="1010";when "1011" => lie<="1011";when "1100" => lie<="1100";when "1101" => lie<="1101";when "1110" => lie<="1110";when "1111" => lie<="1111";when others=>null;end case;if s="0000" thencase cdount isw h e n"0000"=>h a n g<="0100000000001000"; w h e n"0001"=>h a n g<="0010000000101000"; w h e n"0010"=>h a n g<="0001000001001001"; w h e n"0011"=>h a n g<="0000100110001010"; w h e n"0100"=>h a n g<="0000011010001110"; w h e n"0101"=>h a n g<="0000100001001000"; w h e n"0110"=>h a n g<="0011000000111000"; w h e n"0111"=>h a n g<="0110000000001100"; w h e n"1000"=>h a n g<="0000000000001000"; w h e n"1001"=>h a n g<="0000000000000000"; w h e n"1010"=>h a n g<="0000111111111100"; w h e n"1011"=>h a n g<="0100000000000000"; w h e n"1100"=>h a n g<="1000000000000000"; w h e n"1101"=>h a n g<="0111111111111111"; w h e n"1110"=>h a n g<="0000000000000000"; w h e n"1111"=>h a n g<="0000000000000000"; when others =>null;end case;end if;if s="0001" thencase cdount isw h e n"0000"=>h a n g<="0000000000000000"; w h e n"0001"=>h a n g<="0100000001000000"; w h e n"0010"=>h a n g<="0010000001000010"; w h e n"0011"=>h a n g<="0001111111001100"; w h e n"0100"=>h a n g<="0010000000000000"; w h e n"0101"=>h a n g<="0100000100001000"; w h e n"0110"=>h a n g<="0100111111111111"; w h e n"0111"=>h a n g<="0100000100001000"; w h e n"1000"=>h a n g<="0100000100001000"; w h e n"1001"=>h a n g<="0100000100001000"; w h e n"1010"=>h a n g<="0111111111111111"; w h e n"1011"=>h a n g<="0100000100001000"; w h e n"1100"=>h a n g<="0100000110001100"; w h e n"1101"=>h a n g<="0110000100001000"; w h e n"1110"=>h a n g<="0010000000000000"; w h e n"1111"=>h a n g<="0000000000000000";when others => null;end case;end if;end process;end architecture;五、系统调试与仿真5.1、输入完文本之后,对该文本进行功能仿真,然后在没有出现错误的情况下,对文本进行时序仿真,观察其波形如下:5.2、在对该文本进行编辑下载,在这之前,先要设置其器件,选择目标芯片。
EDA技术实用教程实验报告实验名称:点阵汉字显示设计系别:XXX专业:电子信息工程姓名:X X X学号:XXXXXXXXX2010.12.216*16的点阵显示设计1、实验目的熟悉MAX+plu sⅡ的VHDL文本设计流程的全过程,学会用可编程逻辑器件设计制作一个16*16的点阵的显示设计。
16*16点阵显示是传统的点阵显示基本应用,它是很多复杂的显示的基础。
这种点阵的显示可以使用多种方法来实现,其中所用到的器件也不尽相同,但是很多基本算法和思想都是相同的,只是根据不同的硬件,具体的方法有所区别。
在此设计中,我所使用的点阵的列式有16个行信号组成的,每一行是由一个单独的位来控制,高电平有效,而列式由四个位矢量来控制的。
例如:“0000”表示第0行,“0000000000000001”表示第1行的点亮。
由于列式由一个矢量决定的,而每一时刻列只能有一个固定的值,因而只能是某一列的如干点亮,因此就决定了只能用逐列扫描的方法。
2、各模块及功能模块CHW控制每个字母显示时间Library ieee;Use ieee.std_logic_1164.all;Use ieee.std_logic_unsigned.all;Entity chw isPort (clk:in std_logic;Q:out std_logic_vector(1 downto 0));End chw;Architecture chw_arc of chw isBeginProcess(clk)Variable cnt:integer;Variable tmp:std_logic_vector(1 downto 0);beginIf clk'event and clk='1'thenif cnt<10000 thenCnt:=cnt+1;ElseCnt:=0;If tmp="11"thenTmp:="00";ElseTmp:=tmp+1;End if;End if;end if;Q<=tmp;End process;End chw_arc;模块CNTA产生列选择信号。
数字电路综合实验报告题目:双色点阵设计实验班级:2011211208姓名:苗壮学号:2011210889一实验要求1.固定红色显示一个汉子或图形,显示亮度4级可调,用一个btn按钮实现亮度调节,亮度变化视觉效果要尽量明显。
2.用从红到绿8级渐变色显示一个固定汉字或图形。
3.分别用单字循环显示,左右滚动显示,上下滚动显示三种显示方式单色显示四个汉字或图形,显示过程中,显示方式用一个btn按钮进行切换。
4.显示的图形或汉字要饱满美观。
提高要求:1.滚动显示过程中实现四种显示颜色的自动变换,颜色变化效果要尽量明显。
2.自拟其它功能。
二系统设计1.设计思路a.因为双色点阵要求几种状态同时发生,因此设置一个传输文字信息的形参sh1~sh8,和颜色控制的参量g1~g8,r1~r8,使文字能同时的发生所需状态,b.同时因亮度需要调节占空比,8种颜色也需要调节占空比。
因此亮度调节和8种颜色模块单独整合入显示模块中,用于最后刷新输入row变量和red,green变量。
c.文字滚动模块因为实验板的逻辑单元限制,每个动画改为10帧左右,包括跳动,左右滚动,上下滚动,和静态四种模块,需要设置一个count计数器,来实现帧的跳转。
d.最后,把按键防抖程序集合进程序内容里,进行仿真,下载测试。
2.总体框图输入button按键防抖btn1~btn4 按键模块(控制器)Clk_1(100hz) c_mode,b_mode,m_mode 输入clk 显示模块case 1:choose color分频模块clkout(5000hz) case 2:choose moveCase 3:choose bright3.模块设计A).Process clk:产生所需的时钟模块。
输出Clk_1,clkout;B).Process bu1~4:防止按键抖动模块。
输出bu1~bu4;C).Process c_mode,b_mode,m_mode:对应改变颜色,改变亮度和改变滚动方式的模块,输出g1~g8,r1~r8,sh1~sh8;D).Process show:刷新双色点阵模块,根据不同的mode输出不同的点阵信息以做到同时三模块完全独立,可以同时发生改变。
基于FPGA及VHDL的LED点阵汉字滚动显示设计方案发布: 2011-8-31 | 作者: —— | 来源:wangliuguo| 查看: 555次| 用户关注:汉字滚动显示器的传统设计方法是用单片机来控制的,虽然单片机方案具有价格低廉,程序编程灵活等特点,但由于单片机硬件资源的限制,未来对设计的变更和升级,总是要付出较多研发经费和较长投放市场周期的代价,甚至有可能需要重新设计。
况且,在以显示为主的系统中,单片机的运算和控制等主要功能的利用率很低,单片机的优势得不到发挥,相当于很大的资源浪费。
采用EDA技术的自顶向下的模块化设计方法,借助相关开发软件,例如Qua汉字滚动显示器的传统设计方法是用单片机来控制的,虽然单片机方案具有价格低廉,程序编程灵活等特点,但由于单片机硬件资源的限制,未来对设计的变更和升级,总是要付出较多研发经费和较长投放市场周期的代价,甚至有可能需要重新设计。
况且,在以显示为主的系统中,单片机的运算和控制等主要功能的利用率很低,单片机的优势得不到发挥,相当于很大的资源浪费。
采用EDA技术的自顶向下的模块化设计方法,借助相关开发软件,例如QualtusⅡ软件,将硬件描述语言——VHDL程序固化于具有丰富I/O口、内部逻辑和连线资源的FPGA(现场可编程门阵列)中。
该技术具有系统设计效率高、集成度好、保密性强、易于修改、易于实现等优点,成为当今数字系统设计主流技术。
此方式所制作的LED点阵控制器,由于是纯硬件行为,具有速度快、可靠性高、抗干扰能力强、开发周期短等显著优点。
1 EDA点阵显示汉字原理以8×8的LED点阵为例,8×8的LED点阵是由64个发光二极管按矩阵形式排列而成,每一行上的发光管有一个公共的阳极(或阴极),每一列上的发光管有一个公共的阴极(或阳极),一般按动态扫描方式显示汉字或图形。
扫描分为点扫描、行扫描和列扫描三种方式。
行扫描需要按行抽取字型码,列扫描则需要按列抽取字型码。
综合实践总结报告综合实践名称: EDA技术与实践综合实践地点、时间一.题目功能分析和设计实验的要求有如下三点:1.用16*16点阵的发光二极管显示字符;2.可显示字符为0~9的数字字符与A~F英文字母的大写;3.输入为四位二进制矢量;按照要求可知,LED点阵模块,共由16×16=256个LED发光二极管组成,如何在该点阵模块上显示数字和字母是本实验的关键。
先将要显示的每一幅图像画在一个16×16共256个小方格的矩形框中,再在有笔划下落处的小方格里填上“1”,无笔划处填上“0”,这样就形成了与这个汉字所对应的二进制数据在该矩形框上的分布以数字8为例,点阵分布为:0000000000000000000000000000000000011111111110000001111111111000000110000001100000011000000110000001100000011000000111111111100000011111111110000001100000011000000110000001100000011000000110000001111111111000000111111111100000000000000000000000000000000000考虑到实际物理实验平台上点阵发光二极管的原理,以下为16×16点阵LED外观图,只要其对应的X、Y轴顺向偏压,即可使LED 发亮。
例如如果想使左上角LED点亮,则Y0=1,X0=0即可。
所以我采用行列扫描的方法,用四位二进制数做列选信号(总共16列),如选中第一列,则扫描第一列之中哪些行是高电平(1),哪些行是低电平(0);为高电平的则点亮,为低电平的不亮。
(列信号都接地)。
如此,列选信号由“0000”变到“1111”时,16列扫描完毕,一个字也就出来了,列选信号重新由“0000”开始扫描。
注意扫描频率必须要足够快,才能保证显示一个数字或字母时所有灯在肉眼看来是同时在闪烁的。
汉字点阵显示VHDL源程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity hzxs isport(clk1,clk2:in std_logic;rd:out std_logic;we: out std_logic;ledw:out std_logic_vector(2 downto 0); d:out std_logic_vector(0 downto 7));end hzxs;architecture hav of hzxs issignal count:std_logic_vector(0 to 2);signal a: std_logic_vector(3 downto 0);beginprocess(clk2)beginif clk2'event and clk2='1' thencount<=count+1;end if;ledw<=count;a(2 downto 0)<=count;end process;process(clk1)beginif clk1'event and clk1='1' thena(3)<=not a(3);end if;end process;process(a)begincase a iswhen"0000"=>d<="10110100";--数when"0001"=>d<="11111111"; when"0010"=>d<="01001010"; when"0011"=>d<="11011010"; when"0100"=>d<="11110110"; when"0101"=>d<="11100110"; when"0110"=>d<="01110110"; when"0111"=>d<="11011011"; when"1000"=>d<="00010000";--字when"1001"=>d<="11111111";when"1010"=>d<="11111101"; when"1011"=>d<="00001100"; when"1100"=>d<="11111111"; when"1101"=>d<="00010000"; when"1110"=>d<="00010000"; when"1111"=>d<="00001100";when others=>d<="00000000";end case;end process;rd<='1';we<='0';end hav;数字抢答器VHDL源程序1)抢答器QDQlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity qdq isport(clr:in std_logic;a,b,c,d:in std_logic;an,bn,cn,dn:out std_logic);end qdq;architecture hav of qdq issignal ss:std_logic_vector(0 to 3);beginss<=a&b&c&d;process(clr,a,b,c,d)beginif clr='1' thencase ss iswhen "1000"=>an<='1';bn<='0';cn<='0';dn<='0'; when "0100"=>an<='0';bn<='1';cn<='0';dn<='0'; when "0010"=>an<='0';bn<='0';cn<='1';dn<='0'; when "0001"=>an<='0';bn<='0';cn<='0';dn<='1'; when others=>an<='0';bn<='0';cn<='0';dn<='0'; end case;elsif clr='0' thenan<='0';bn<='0';cn<='0';dn<='0';end if;end process;end hav;2)计分器JFQlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity jfq isport(en1:in std_logic;clk3:in std_logic;bs:out std_logic_vector(3 downto 0);ss:out std_logic_vector(3 downto 0);gs:out std_logic_vector(3 downto 0);add:in std_logic;dec:in std_logic);end jfq;architecture hav of jfq isbeginprocess(clk3,en1,add,dec)variable ssw:std_logic_vector(3 downto 0); variable bsw:std_logic_vector(3 downto 0); beginbsw:="0001";if clk3='1' and clk3'event thenif en1='1' thenif add='1' thenif ssw="1001" thenbsw:=bsw+1;ssw:="0000";elsessw:=ssw+1;end if;elsif dec='1' thenif ssw="1111" thenbsw:=bsw-1;ssw:="1001";elsessw:=ssw-1;end if;end if;end if;end if;ss<=ssw;bs<=bsw;gs<="0000";end process;end hav;3) 选择器XZQlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity xzq isport( a1,b1:in std_logic;abw:in std_logic_vector(0 to 3);asw:in std_logic_vector(0 to 3);agw:in std_logic_vector(0 to 3);bbw:in std_logic_vector(0 to 3);bsw:in std_logic_vector(0 to 3);bgw:in std_logic_vector(0 to 3);obw:out std_logic_vector(0 to 3);osw:out std_logic_vector(0 to 3);ogw:out std_logic_vector(0 to 3)); end xzq;architecture hav of xzq isbeginprocess(a1,b1)beginif a1='1' and b1='0' thenobw<=abw;osw<=asw;ogw<=agw;elsif a1='0' and b1='1' thenobw<=bbw;osw<=bsw;ogw<=bgw;end if;end process;end hav;4)译码器YMQlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity ymq isport( clk2:in std_logic;bw:in std_logic_vector(3 downto 0);sw:in std_logic_vector(3 downto 0);gw:in std_logic_vector(3 downto 0);y:out std_logic_vector(7 downto 0);ledw:out std_logic_vector(2 downto 0)); end ymq;architecture hav of ymq issignal knum:std_logic_vector(3 downto 0); signal count:std_logic_vector(2 downto 0); beginprocess(clk2)beginif clk2'event and clk2='1' thenif count<2 thencount<=count+1;elsecount<="000";end if;end if;end process;ledw<=count;knum<=gw when count=0 elsesw when count=1 elsebw when count=2 ;y<="00111111" when knum="0000" else "00000110" when knum="0001" else"01011011" when knum="0010" else"01001111" when knum="0011" else"01100110" when knum="0100" else"01101101" when knum="0101" else"01111101" when knum="0110" else"00000111" when knum="0111" else"01111111" when knum="1000" else"01101111" when knum="1001" else"00000000" ;end hav;。
VHDL 16*16点阵本实验主要完成汉字字符在LED 上的显示,16*16 扫描LED 点阵的工作原理与8 位扫描数码管类似,只是显示的方式与结果不一样。
本实验的示例程序依次显示的是“湖南工程学院”,要求每隔一秒换下一个字显示。
源程序(带注释)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity dzh is --建立实体dzh port( clk:in std_logic;r,c:out std_logic_vector(15 downto 0)); --两个输出信号end;architecture two of dzh is --建立结构体two type states is(st0,st1,st2,st3,st4,st5); --定义六个状态signal cs,ns:states:=st0;signal count:integer range 0 to 999:=0;begina1:process(clk)variable s:std_logic_vector(3 downto 0):="0000";beginif clk'event and clk='1' thens:=s+1;if cs=st0 thencase s is --“湖”字的显示when "0000" =>r<=not"0000000000000001";c<=not"0111111111111111";when "0001" =>r<=not"0000000000000010";c<=not"1011111011100000";when "0010" =>r<=not"0000000000000100";c<=not"1100111011101110";when "0011" =>r<=not"0000000000001000";c<=not"1111100000101110";when "0100" =>r<=not"0000000000010000";c<=not"1111111011101110";when "0101" =>r<=not"0000000000100000";c<=not"1111111011100000";when "0110" =>r<=not"0000000001000000";c<=not"0011100000101110";when "0111" =>r<=not"0000000010000000";c<=not"1100101110101110";when "1000" =>r<=not"0000000100000000";c<=not"1111101110100000";when "1001" =>r<=not"0000001000000000";c<=not"1111101110101110";when "1010" =>r<=not"0000010000000000";c<=not"1111101110101110";when "1011" =>r<=not"0000100000000000";c<=not"1110101110101110";when "1100" =>r<=not"0001000000000000";c<=not"1101100000101110";when "1101" =>r<=not"0010000000000000";c<=not"1011111111101110";when "1110" =>r<=not"0100000000000000";c<=not"0111111111011100";when "1111" =>r<=not"1000000000000000";c<=not"1111111111111111";when others =>null;end case;elsif cs=st1 thencase s is --“南”字的显示when "0000" =>r<=not"0000000000000001";c<=not"1111111111111111";when "0001" =>r<=not"0000000000000010";c<=not"1111111110111111";when "0010" =>r<=not"0000000000000100";c<=not"1111111101111111";when "0011" =>r<=not"0000000000001000";c<=not"1100000000000111";when "0100" =>r<=not"0000000000010000";c<=not"1111111011111111";when "0101" =>r<=not"0000000000100000";c<=not"1111110111111111";when "0110" =>r<=not"0000000001000000";c<=not"1100000000000111";when "0111" =>r<=not"0000000010000000";c<=not"1101101110110111";when "1000" =>r<=not"0000000100000000";c<=not"1101110101110111";when "1001" =>r<=not"0000001000000000";c<=not"1101100000110111";when "1010" =>r<=not"0000010000000000";c<=not"1101111011110111";when "1011" =>r<=not"0000100000000000";c<=not"1101000000010111";when "1100" =>r<=not"0001000000000000";c<=not"1101111011110111";when "1101" =>r<=not"0010000000000000";c<=not"1101111011100111";when "1110" =>r<=not"0100000000000000";c<=not"1111111111111111";when "1111" =>r<=not"1000000000000000";c<=not"1111111111111111";when others =>null;end case;elsif cs=st2 thencase s is --“工”字的显示when "0000" =>r<=not"0000000000000001";c<=not"1111111111111111";when "0001" =>r<=not"0000000000000010";c<=not"1111111111111111";when "0010" =>r<=not"0000000000000100";c<=not"1111111111111111";when "0011" =>r<=not"0000000000001000";c<=not"1100000000000111";when "0100" =>r<=not"0000000000010000";c<=not"1111111011111111";when "0101" =>r<=not"0000000000100000";c<=not"1111111011111111";when "0110" =>r<=not"0000000001000000";c<=not"1111111011111111";when "0111" =>r<=not"0000000010000000";c<=not"1111111011111111";when "1000" =>r<=not"0000000100000000";c<=not"1111111011111111";when "1001" =>r<=not"0000001000000000";c<=not"1111111011111111";when "1010" =>r<=not"0000010000000000";c<=not"1111111011111111";when "1011" =>r<=not"0000100000000000";c<=not"1111111011111111";when "1100" =>r<=not"0001000000000000";c<=not"1100000000000111";when "1101" =>r<=not"0010000000000000";c<=not"1111111111111111";when "1110" =>r<=not"0100000000000000";c<=not"1111111111111111";when "1111" =>r<=not"1000000000000000";c<=not"1111111111111111";end case;elsif cs=st3 thencase s is --“程”字的显示when "0000" =>r<=not"0000000000000001";c<=not"1111111111111111";when "0001" =>r<=not"0000000000000010";c<=not"1111111111111111";when "0010" =>r<=not"0000000000000100";c<=not"1111110110000011";when "0011" =>r<=not"0000000000001000";c<=not"1100001110111011";when "0100" =>r<=not"0000000000010000";c<=not"1111011110000011";when "0101" =>r<=not"0000000000100000";c<=not"1111011111111111";when "0110" =>r<=not"0000000001000000";c<=not"1000000100000001";when "0111" =>r<=not"0000000010000000";c<=not"1110001111101111";when "1000" =>r<=not"0000000100000000";c<=not"1101010111101111";when "1001" =>r<=not"0000001000000000";c<=not"1101011010000011";when "1011" =>r<=not"0000100000000000";c<=not"1111011111101111";when "1100" =>r<=not"0001000000000000";c<=not"1111011111101111";when "1101" =>r<=not"0010000000000000";c<=not"1111011100000001";when "1110" =>r<=not"0100000000000000";c<=not"1111111111111111";when "1111" =>r<=not"1000000000000000";c<=not"1111111111111111";when others =>null;end case;elsif cs=st4 thencase s is --“学”字的显示when "0000" =>r<=not"0000000000000001";c<=not"1111111111111111";when "0001" =>r<=not"0000000000000010";c<=not"1111011011110111";when "0010" =>r<=not"0000000000000100";c<=not"1111101101101111";when "0011" =>r<=not"0000000000001000";c<=not"1111111111111111";when "0100" =>r<=not"0000000000010000";c<=not"1110000000000011";when "0101" =>r<=not"0000000000100000";c<=not"1110111111111011";when "0110" =>r<=not"0000000001000000";c<=not"1101110000010111";when "0111" =>r<=not"0000000010000000";c<=not"1111111111011111";when "1000" =>r<=not"0000000100000000";c<=not"1111111100111111";when "1001" =>r<=not"0000001000000000";c<=not"1111111101111111";when "1010" =>r<=not"0000010000000000";c<=not"1111100000001111";when "1011" =>r<=not"0000100000000000";c<=not"1111111101111111";when "1100" =>r<=not"0001000000000000";c<=not"1111111101111111";when "1101" =>r<=not"0010000000000000";c<=not"1111111001111111";when "1110" =>r<=not"0100000000000000";c<=not"1111111111111111";when "1111" =>r<=not"1000000000000000";c<=not"1111111111111111";when others =>null;end case;elsif cs=st5 thencase s is --“院”字的显示when "0000" =>r<=not"0000000000000001";c<=not"1111111110111111";when "0010" =>r<=not"0000000000000100";c<=not"1011010000000001";when "0011" =>r<=not"0000000000001000";c<=not"1011010111111101";when "0100" =>r<=not"0000000000010000";c<=not"1010101111111011";when "0101" =>r<=not"0000000000100000";c<=not"1001111100001111";when "0110" =>r<=not"0000000001000000";c<=not"1010011111111111";when "0111" =>r<=not"0000000010000000";c<=not"1011010000000011";when "1000" =>r<=not"0000000100000000";c<=not"1011011101101111";when "1001" =>r<=not"0000001000000000";c<=not"1000111101101111";when "1010" =>r<=not"0000010000000000";c<=not"1011111101101111";when "1011" =>r<=not"0000100000000000";c<=not"1011111011101101";when "1100" =>r<=not"0001000000000000";c<=not"1011110111100001";when "1101" =>r<=not"0010000000000000";c<=not"1011111111111111";when "1110" =>r<=not"0100000000000000";c<=not"1111111111111111";when "1111" =>r<=not"1000000000000000";c<=not"1111111111111111";when others =>null;end case;else null;end if;end if;end process a1;a2:process(clk) --下一状态的转换beginif clk'event and clk='1' thenif count<999 thencount<=count+1;else count<=0;case cs iswhen st0=>ns<=st1;when st1=>ns<=st2;when st2=>ns<=st3;when st3=>ns<=st4;when st4=>ns<=st5;when st5=>ns<=st0;when others=>ns<=st0;end case;end if;end if;end process a2;a3:process(clk) --当前状态的转换beginif clk'event and clk='1' thencs<=ns;end if;end process a3;end architecture;。
数字电路课程设计报告课程:基于FPGA的点阵显示控制器的设计学院:电气信息工程学院专业:测控技术与仪器班级:姓名:学号:合作者姓名:日期:一、引言随着我国经济的高速发展,对公共场合发布信息的需求日益增长,利用LED 点阵滚动显示汉字的出现正好适应了这一市场需求,已经成为信息传播的一种重要手段。
采用传统方法设计的汉字滚动显示器,通常需要使用单片机、存储器和制约逻辑电路来进行PCB板级的系统集成。
尽管这种方案有单片机软件的支持较为灵活,但是由于受硬件资源的限制,未来对设计的变更和升级,总是难以避免要付出较多研发经费和较长投放市场周期的代价。
随着电子设计自动化(EDA)技术的进展,基于可编程FPGA器件进行系统芯片集成的新设计方法,也正在快速地到代基于PCB板的传统设计方式。
因此,基于FPGA和VHDL语言实现在8*8点阵上的汉字静态或一屏显示问题。
二、课题要求(1)技术要求1根据电路特点,用层次设计概念。
将此设计任务分成若干模块,规定每一模块的功能和各模块之间的借口,透视加深层次化设计概念;2软件的原件管理深层含义,以及模块元件之间的连接概念,对于不同目录下的同一设计,如何熔合;3适配划分前后的仿真内容有何不同概念,仿真信号对象有何不同,有更深一步了解。
熟悉了FPGA设计的调试过程中手段的多样化;4按适配划分后的管脚定位,同相关功能块硬件电路接口连线;(2)功能要求1在8*8点阵上显示汉字2可以静态显示或一屏显示3利用拨码开关来实现静态显示与一屏显示切换(3)本人的工作三、设计方案(1)工作原理8*8点阵原理:按照要求可知,点阵模块,共由8*8=64个发光二极管组成,如何在该点阵模块上显示汉字是本实验的关键。
先将要显示的每幅图像画在8*8共64个小方格的矩形框中,再在有笔划下落处的小方格里填上“1”,五笔划处填上“0”,这样就形成了与这个汉字所对应的二进制数据在该矩形矿上的分布以“正”为例,点阵分布为:1000000010000001111100011000000111111111100010011000100110000000(2)原理框图四、单元电路设计,仿真结果与分析(1)静态显示“正”library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_Unsigned.all;use ieee.std_logic_ARITH.all;ENTITY peng isport(clk,en:in std_logic;lie:out std_logic_vector(7 downto 0); --列com:out std_logic_vector(7 downto 0));--行End peng;Architecture a of peng issignal st1:std_logic_vector(7 downto 0);signal osc:std_logic;signal osd:std_logic;signal d_ff:std_logic_vector(27 downto 0);signal data:std_logic_vector(7 downto 0);signal d0,d1,d2,d3,d4,d5,d6,d7:std_logic_vector(7 downto 0);signal lie0,lie1,lie2,lie3,lie4,lie5,lie6,lie7:std_logic_vector(7 downto 0);Begincom<=data;lie<=st1;d0<="10000000";d1<="10000001";d2<="11110001";d3<="10000001";d4<="11111111";d5<="10001001";d6<="10001001";d7<="10000000";--字库正First:processbeginwait until clk='1';if(d_ff(27 downto 0)>=2e8)thend_ff(27 downto 0)<="0000000000000000000000000000";elsed_ff(27 downto 0)<=d_ff+1;end if;osc<=not d_ff(10);end process first;second:process(osc)beginif(osc='1' and osc'event and en='0')thenif st1(7 downto 0)="00000000"or st1(7 downto 0)="01111111"then st1(7 downto 0)<="11111110";data<=d0;elsif st1(7 downto 0)="11111110"thenst1(7 downto 0)<="11111101";data<=d1;elsif st1(7 downto 0)="11111101"thenst1(7 downto 0)<="11111011";data<=d2;elsif st1(7 downto 0)="11111011"thenst1(7 downto 0)<="11110111";data<=d3;elsif st1(7 downto 0)="11110111"thenst1(7 downto 0)<="11101111";data<=d4;elsif st1(7 downto 0)="11101111"thenst1(7 downto 0)<="11011111";data<=d5;elsif st1(7 downto 0)="11011111"thenst1(7 downto 0)<="10111111";data<=d6;elsif st1(7 downto 0)="10111111"thenst1(7 downto 0)<="01111111";data<=d7;end if;end if;end process second;end a;(2)一屏显示“上下五千年”Library ieee;Use ieee.std_logic_1164.all;Use ieee.std_logic_unsigned.all;Use ieee.std_logic_arith.all;Entity weng isPort(Clk,en:in std_logic;lie:out std_logic_vector(7 downto 0);--列Com:out std_logic_vector(7 downto 0));--行End weng;Architecture a of weng issignal st1:std_logic_vector(7 downto 0);signal osc:std_logic;signal osd:std_logic;signal d_ff:std_logic_vector(27 downto 0);signal data:std_logic_vector(7 downto 0);signal d0,d1,d2,d3,d4,d5,d6,d7:std_logic_vector(7 downto 0);signal lie0,lie1,lie2,lie3,lie4,lie5,lie6,lie7:std_logic_vector(6 downto 0);begincom<=data;lie<=st1;D0<="10000000"when lie0(6 downto 0)="0000000"else"00000001"when lie0(6 downto 0)="0000001"else"10000000"when lie0(6 downto 0)="0000010"else"00010000"when lie0(6 downto 0)="0000011"else"00100100"when lie0(6 downto 0)="0000100"else"00000000";D1<="10000000"when lie0(6 downto 0)="0000000"else"00000001"when lie0(6 downto 0)="0000001"else"10001001"when lie0(6 downto 0)="0000010"else"00010100"when lie0(6 downto 0)="0000011"else"00111011"when lie0(6 downto 0)="0000100"else"00000000";D2<="10000000"when lie0(6 downto 0)="0000000"else"00000001"when lie0(6 downto 0)="0000001"else"10001001"when lie0(6 downto 0)="0000010"else"00010100"when lie0(6 downto 0)="0000011"else"00101010"when lie0(6 downto 0)="0000100"else"00000000";D3<="11111111"when lie0(6 downto 0)="0000000"else "11111111"when lie0(6 downto 0)="0000001"else "11111111"when lie0(6 downto 0)="0000010"else "11111100"when lie0(6 downto 0)="0000011"else "00101010"when lie0(6 downto 0)="0000100"else "00000000";D4<="10010000"when lie0(6 downto 0)="0000000"else "00001001"when lie0(6 downto 0)="0000001"else "10001001"when lie0(6 downto 0)="0000010"else "00010010"when lie0(6 downto 0)="0000011"else "11111110"when lie0(6 downto 0)="0000100"else "00000000";D5<="10010000"when lie0(6 downto 0)="0000000"else "00010001"when lie0(6 downto 0)="0000001"else "10001001"when lie0(6 downto 0)="0000010"else "00010001"when lie0(6 downto 0)="0000011"else "00101010"when lie0(6 downto 0)="0000100"else "00000000";D6<="10010000"when lie0(6 downto 0)="0000000"else "00100001"when lie0(6 downto 0)="0000001"else "11111000"when lie0(6 downto 0)="0000010"else "00010000"when lie0(6 downto 0)="0000011"else "00101010"when lie0(6 downto 0)="0000100"else "00000000";D7<="10000000"when lie0(6 downto 0)="0000000"else "00000001"when lie0(6 downto 0)="0000001"else "10000000"when lie0(6 downto 0)="0000010"else "00010000"when lie0(6 downto 0)="0000011"else "00100000"when lie0(6 downto 0)="0000100"else "00000000";first:processbeginwait until clk='1';if(d_ff(27 downto 0)>=2e8)thend_ff(27 downto 0)<="0000000000000000000000000000"; elsed_ff(27 downto 0)<=d_ff+1;end if;osc<=not d_ff(10);osd<=not d_ff(26);end process first;second:process(osc)beginif(osc='1' and osc'event and en='0')thenif st1(7 downto 0)="00000000"or st1(7 downto 0)="01111111"then st1(7 downto 0)<="11111110";data<=d0;elsif st1(7 downto 0)="11111110"thenst1(7 downto 0)<="11111101";data<=d1;elsif st1(7 downto 0)="11111101"thenst1(7 downto 0)<="11111011";data<=d2;elsif st1(7 downto 0)="11111011"thenst1(7 downto 0)<="11110111";data<=d3;elsif st1(7 downto 0)="11110111"thenst1(7 downto 0)<="11101111";data<=d4;elsif st1(7 downto 0)="11101111"thenst1(7 downto 0)<="11011111";data<=d5;elsif st1(7 downto 0)="11011111"thenst1(7 downto 0)<="10111111";data<=d6;elsif st1(7 downto 0)="10111111"thenst1(7 downto 0)<="01111111";data<=d7;end if;end if;end process second;third:process(osd)beginif(osd='1' and osd'event and en='0')thenif lie0(6 downto 0)="0000100"thenlie0(6 downto 0)<="0000000";else lie0(6 downto 0)<=lie0+1;end if;end if;end process third;end a;五.顶层文件电路设计,仿真结果与分析顶层文件library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_Unsigned.all;use ieee.std_logic_ARITH.all;entity zong isport( a:in std_logic_vector(1 downto 0);clk:in std_logic;hang:out std_logic_vector(7 downto 0);lie:out std_logic_vector(7 downto 0));end entity zong;architecture one of zong iscomponent peng isport(clk,en:in std_logic;lie:out std_logic_vector(7 downto 0); --列com:out std_logic_vector(7 downto 0));end component;component weng isPort(Clk,en:in std_logic;lie:out std_logic_vector(7 downto 0);--列Com:out std_logic_vector(7 downto 0));--行end component;signal h1,h2:std_logic_vector(7 downto 0);signal l1,l2:std_logic_vector(7 downto 0);beginu1:peng port map(clk=>clk,en=>a(1),com=>h1,lie=>l1); u2:weng port map(clk=>clk,en=>a(0),com=>h2,lie=>l2); hang<=h1 or h2;lie<=l1 or l2;end architecture one;六、调试结果创建工程在Quartus II 中新建一个VHDL File文件,将vhdl代码输入这个文件,并保存到工作目录,名为zong.vhd。