您的当前位置:首页正文

VHDL实习报告

来源:个人技术集锦
——————————————————————————

装 订 线————————————————————————————————

实验总成绩: 报告份数:

西安邮电大学

通信与信息工程学院 VHDL实习报告

专业班级: 对抗1101 学生姓名: 刘茜 学号(班内序号): 03116013(13)

2014 年 5 月 3 日

——————————————————————————

指导教师评语:

装 订 线————————————————————————————————

实 验 成 绩: 指导(辅导)教师 :

- 1 -

一.摘要

为什么做:洗衣机控制器的设计是把家电控制电路集成在一篇FPGA芯片内,这样就无需专门的和外部逻辑电路。从而减小了电路的体积,提高了系统的稳定性

做什么:洗衣机控制器主要是定时器的设计,由一片FPGA和外围电路控制部分。FPGA接受键盘的控制命令,控制洗衣机的排水,水位和洗衣机的工作状态。

怎么做:对FPGA芯片的编程采用模块化的VHDL (硬件描述语言)进行设计,设计分为三层实现,顶层实现整个芯片的功能。顶层和中间层多数是由VHDL的元件例化语句实现。中间层调用底层模块。

做的结果:使洗衣机作如下运转:定时启动—〉正转20秒—〉暂停10秒—〉反转20秒—〉暂停10秒—〉定时不到,重复上面过程。

二、英文摘要

Why:To design a washing machine controller,we integrate the Household appliances control circuit into a FPGA chip.Therefore we can do without an Single-Chip Microprocessor or the external logic circuit.So we can reduce the size of the circuit and reinforce the stability of the system.

Do what:The timer is play the most important part in the design. It is made up of a FPGA chip and the external circuit.FPGA answer the

- 2 -

command from the keyboard and then make the washing machine drainage,set the water lever and other state.

How to do:We use the VHDL modularized program to program the FPGA chip . The whole design is made up of three layers.The top layer realize the function of the whole chip.the top and the middle layer almost make use of components instantiated statements.And the top layer invokes the underlying modules.

Results: We can enable the washing machine doing following functions: Start working on the time setted -> Roll clockwise for 20s-> Stop for 10s->Roll anticlockwise for 20s->Stop for 20s->if setted time not come ,repeat the process.

三、引言

本实验包括六个小实验和一个大实验,整体基于VHDL语言和quartusⅡ应用程序.VHDL语言设计是一门艺术,也是一种技术.我们通过精湛的技术传达了我们的设计理念.

四、硬件设计

8-3编码器

- 3 -

3-8译码器

数据选择器

- 4 -

计数器

- 5 -

全加器

全减器

- 6 -

锁存器

偶数

- 7 -

寄存器

- 8 -

Jk触发器

半加器

- 9 -

半减器

五、软件设计

- 10 -

1:quartusⅡ的安装

2-1:3-8编码器

library ieee;

use ieee.std_logic_1164.all; entity trans38 is

- 11 -

port(

Y : in std_logic_vector(2 downto 0); EN : in std_logic;

A : out std_logic_vector(7 downto 0)); end trans38;

architecture m1 of trans38 is begin process(y) begin

if en='1' then case y is

when \"000\"=> A<=\"00000001\"; when \"001\"=>A<=\"00000010\"; when \"010\"=>A<=\"00000100\"; when \"011\"=>A<= \"00001000\"; when \"100\"=>A<=\"00010000\"; when \"101\"=>A<= \"00100000\"; when \"110\"=>A<=\"01000000\"; when \"111\"=>A<=\"10000000\"; when others =>A<=\"00000000\"; end case; else

A<=\"00000000\"; End if;

end process; end m1;

2-2:83译码器

- 12 -

library ieee;

use ieee.std_logic_1164.all;

entity trans83 is port(din:in std_logic_vector(0 to 7); en:in std_logic; output:out std_logic_vector(0 to 2)); end trans83;

architecture bhv of trans83 is signal sint:std_logic_vector(4 downto 0); begin process(din,en) begin if(en='1')then output<=\"ZZZ\"; else if(din(0)='1') then output<=\"111\"; elsif(din(1)='1') then output<=\"110\"; elsif(din(2)='1') then output<=\"101\"; elsif(din(3)='1') then output<=\"100\"; elsif(din(4)='1') then output<=\"011\"; elsif(din(5)='1') then output<=\"010\";

- 13 -

elsif(din(6)='1') then output<=\"001\"; elsif(din(7)='1')then output<=\"000\"; end if; end if; end process; end bhv;

2-3:jk触发器

library ieee;

use ieee.std_logic_1164.all; entity jk is

port(j,k,clk: in std_logic; q,nq: buffer std_logic); end;

architecture behave of jk is signal q_s,nq_s:std_logic; begin

process(j,k,clk) begin

if(clk'event and clk='1')then if(j='0')and(k='1')then q_s<='0'; nq_s<='1';

elsif (j='1')and(k='0')then q_s<='1'; nq_s<='0';

elsif(j='1')and(k='1')then q_s<=not q;

- 14 -

nq_s<=not nq; end if; end if; q<=q_s; nq<=nq_s; end process; end;

2-4:半减器

library ieee;

use ieee.std_logic_1164.all;

entity halfsub is port(x, y:in std_logic;

sub, bout: out std_logic); end halfsub;

architecture Equations of halfsub is begin

sub<=x xor y ;

bout<=(not x) and y; end Equations;

2-5:比较器

- 15 -

LIBRARY IEEE;

USE IEEE.STD_LOGIC_1164.ALL;

USE IEEE.STD_LOGIC_UNSIGNED.ALL; ENTITY compare IS

GENERIC(SIZE:INTEGER:=2);

PORT (DAT1,DAT2:IN STD_LOGIC_VECTOR(SIZE DOWNTO 1); MAX:OUT STD_LOGIC_VECTOR(SIZE DOWNTO 1)); END ENTITY compare;

ARCHITECTURE ART OF compare IS BEGIN

PROCESS(DAT1,DAT2) BEGIN

IF(DAT1(SIZE-1 DOWNTO 1)>DAT2(SIZE-1 DOWNTO 1)) THEN MAX<=DAT1;

ELSE MAX<=DAT2; END IF; END PROCESS;

END ARCHITECTURE ART;

2-6:计数器

- 16 -

LIBRARY IEEE;

USE IEEE.STD_LOGIC_1164.ALL;

USE IEEE.STD_LOGIC_UNSIGNED.ALL; ENTITY counter IS

PORT ( CLK ,clr : IN STD_LOGIC ;

CQ : OUT STD_LOGIC_VECTOR ( 3 DOWNTO 0 )); END ENTITY counter;

ARCHITECTURE ONE OF counter IS BEGIN

PROCESS ( CLK , clr )

VARIABLE LCQ : STD_LOGIC_VECTOR ( 3 DOWNTO 0 ); BEGIN

IF clr = '1' THEN LCQ := \"0000\"; ELSIF CLK'EVENT AND CLK = '1' THEN

IF LCQ < 9 THEN LCQ := LCQ + 1; ELSE LCQ := \"0000\" ; END IF; END IF; CQ <= LCQ ; END PROCESS;

END ARCHITECTURE ONE;

3:洗衣机控制系统

洗衣机控制器电路主要有五大部分组成,包括:减法计数器、时序控制电路、预置时间和编码电路、数码管显示、译码器组成。具体电路如图3所示:

- 17 -

洗衣机控制器总体设计图

洗衣机控制器程序仿真图

⑴数码管显示 ① 实现数码管显示

- 18 -

2数码管显示编码 ○

⑵时序电路

- 19 -

⑶预置时间和编码电路

⑷译码器

- 20 -

⑸定时器电路 ①计时器

②减法计数器

- 21 -

六、测试结果

七、项目团队成员贡献及心得体会

基于VHDL的洗衣机控制系统是我们小组的课题,在经过两周的实习时间后,我们将这一课题顺利结束。作为一名要考研的学生,我深知系统的知识模式和清晰的逻辑思维能力是一位考研人所必须的技能。在这次课程设计中,VHDL的专业知识使我充实了我自己的知识库,同时也复习了一些以前的C语言编程方面的知识,且又成为了新的学习窗口而拓展了我的视野。接触一门新的语言对任何人来说都是不简单的,但是我们要在短时间内学会并得以掌握,更是对我们提出了新的要求。作为一名考研人,这两周的锻炼也是为了的研究生生涯做了铺垫。这将是一份可贵的人生经验.

八、主要参考文献(列近5年主要参考文献6篇以上,格式如下) [1] 潘松著.EDA技术实用教程(第二版). 北京:科学出版社,2005. [2] 康华光主编.电子技术基础 模拟部分. 北京:高教出版社,2006. [3] 阎石主编.数字电子技术基础. 北京:高教出版社,2003.

[4] 赵岩岭 刘春等.在MAX+plusⅡ平台下用VHDL进行数字电路设计. 西安:

- 22 -

西电出版社,2005

[5] http://www.51kaifa.com/ 无忧电子开发网

- 23 -

因篇幅问题不能全部显示,请点此查看更多更全内容