cpldfpga设计及应用课程设计数字密码锁 学位论文.docx

上传人:b****0 文档编号:16926930 上传时间:2023-07-19 格式:DOCX 页数:23 大小:315.17KB
下载 相关 举报
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第1页
第1页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第2页
第2页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第3页
第3页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第4页
第4页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第5页
第5页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第6页
第6页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第7页
第7页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第8页
第8页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第9页
第9页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第10页
第10页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第11页
第11页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第12页
第12页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第13页
第13页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第14页
第14页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第15页
第15页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第16页
第16页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第17页
第17页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第18页
第18页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第19页
第19页 / 共23页
cpldfpga设计及应用课程设计数字密码锁 学位论文.docx_第20页
第20页 / 共23页
亲,该文档总共23页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

cpldfpga设计及应用课程设计数字密码锁 学位论文.docx

《cpldfpga设计及应用课程设计数字密码锁 学位论文.docx》由会员分享,可在线阅读,更多相关《cpldfpga设计及应用课程设计数字密码锁 学位论文.docx(23页珍藏版)》请在冰点文库上搜索。

cpldfpga设计及应用课程设计数字密码锁 学位论文.docx

cpldfpga设计及应用课程设计数字密码锁学位论文

《CPLD/FPGA设计及应用课程设计》

课程设计报告

 

题目:

数字密码锁

院(系):

信息科学与工程学院

专业班级:

xxxxxxxx

学生姓名:

xxxxx

学号:

xxxxxxxxxx

指导教师:

xxxx

 

2016年4月11日至2016年5月6日

 

武昌首义学院制

CPLD/FPGA设计及应用课程设计任务书

一、设计题目

数字密码锁。

二、设计主要内容

1.掌握睿智FPGA开发板的基本构造和功能,并能设计一些简单的功能。

2.学会用VHDL语言来设计一些基本的逻辑模块。

3.了解时序逻辑的设计方式,并运用在密码锁的设计上。

4.精通数字编码,AD/DA方式在程序中的运作方式。

5.状态机的使用,实现密码比对和储存读取功能。

三、原始资料

1.《CPLD/FPGA设计及应用》实验指导书--马玲;

2.《CPLD/FPGA设计及应用》—马玲,彭敏;

四、要求的设计成果

1.熟练运用QuartusII来设计逻辑时序的模块;

2.熟悉设计一个成果的过程;

3.更深一步的学习VHDL语言;

4.运用FPGA开发板设计数字密码锁,并具备消隐、设置密码和三次报错的功能。

五、进程安排

第1天:

老师讲解课程设计目的、意义,布置课题任务,学生分组选题。

第2天:

学生根据所选课题自己下去通过网络或者其他途径寻找课题相关设计资料。

第3-7天:

在实验室或者自己的电脑上完成课题的程序以及相关的功能仿真通过。

第8天:

在实验室结合EDA实验箱完成程序的调试以及功能的实现。

第9天:

通过老师的验收并回答老师的提问。

第10天:

下去完成课程设计报告。

六、主要参考资料

1.《CPLD/FPGA设计及应用》实验指导书--马玲;

2.《CPLD/FPGA设计及应用》—马玲,彭敏;

指导教师(签名):

 

2016年4月10日

目录

1.课程设计目的…………………………………………………………………5

2.课程设计题目描述和要求……………………………………………5

3.课程设计报告内容……………………………………………………………5

3.1设计思路及原理……………………………………………………………5

3.2设计需要解决的问题………………………………………………………5

3.3设计过程……………………………………………………………6

4.总结……………………………………………………………………………11

5.附录…………………………………………………………………………12

数字密码锁设计

1.课程设计目的

●设计一个四位十进制的密码锁。

●跟深一步的理解FPGA的用途,精通相应的开发板。

2.课程设计题目描述和要求

a):

密码锁串行输入四位十进制数字口令

b):

输入口令全部正确即开锁

c):

口令输入最大次数3次,要求在完全输入四位之后进行判断口令正确与否;输入3次之后还不能开锁,进入锁死状态

d)有相应的显示功能

e)可以对输入的口令消隐

f)开锁后能再次上锁

3.课程设计报告的内容

1)设计思路及原理

i.密码锁原理

利用逻辑电路将外接输入的电信号转化为时序电路,经过内部设定的规则,当输入的信号经过处理后的时序逻辑达到内部设定的条件是开启某一种状态及时解锁状态,当没达到那种条件时始终保持一种或多种状态。

ii.密码锁的设计要求

设计密码锁的系统描述:

数字密码锁在设定口令和开锁时要求输入四位十进制数据,当输入状态开启时,输入正确显示一种状态,如果错误则显示错误次数加1,累计3次锁死状态并报警,如果不输入则一直保持原来状态;当检测到储存状态时,输入密码并存储改变原有的储存密码;当检测到消隐信号时,将不显示输入的数据。

2)设计中需要解决的问题

01.时钟扫描读取输入的信号:

过小,还没检测到就进入下次判断或者多记一次,过大,响应过慢,加上消斗模块后容易引起码间干扰不易读取信号

02.密码读取:

读入按键开关信号要将信号处理编码送入显示和密码比较状态

03.密码比较:

首先是要将存入的数字进行存储和逻辑排序,然后将输入的数据进行一一比对,并进行计数,正确与否输出状态信号

04.显示模块:

将输入模式、开锁状态、密码存储状态和锁死状态等的显示状态显示的编码

05.开发板引脚的配置等

3)设计过程

●密码锁的系统描述

a)输入输出端口定义:

Sdin:

输入十进制数信号按键(由于按键不够,将0—9数据以按键按下次数来编译)

Lock:

上锁按键

Sec:

解锁按键

Clr:

确认按键

Set:

密码存储按键

Crack:

开锁状态按键

Clk:

输入数字确定按键

Dout:

送现输出信号端

Yn:

选码信号

b)

系统状态转换图

错误

累计次数=3

解锁错误次数<3

密码正确

设置

上锁

 

c)编码规则

输入信号

编码信号

逻辑意义

0000

11000000

数字“0”

0001

11111001

数字“1”

0010

10100100

数字“2”

0011

10110000

数字“3”

0100

10011011

数字“4”

0101

10010010

数字“5”

0110

10000010

数字“6”

0111

11111000

数字“7”

1000

10000000

数字“8”

1001

10010000

数字“9”

1010

11101111

解锁成功“A”

1011

01111111

解锁失败

Others

11111111

其他状态

01--

11000000

上锁状态

10--

00011000

解锁状态

●时钟模块

由于输入时钟是50MHZ,一般扫描频率一般1000HZ左右,过50分频得到1M的频率后经过后续得到两路时钟来分别接入按键和比对模块。

●输入设置

输入模块,由于进行消斗处理用D触发器来消抖动,将输入的信号送入输出,时序时钟推迟一个周期。

 

●计数模块和按键累积计数

将输入的信号进行A/D转换,根据确认按键的输入来计数时序,将输入的3个数字按顺序送入下个模块;计数模块达到3次输出alert报警。

●编码和处理模块

将输入的十进制信号转化成断码,将时序逻辑进行编码来选码管。

 

●选码模块

将时序信号进行编码。

4)设计得到的成果及现象

●得到的总体结构:

 

●引脚配置:

 

●实物图:

1.初始状态:

 

2.解锁状态:

3.上锁状态:

4.总结

●在这次课设中虽然遇到很多麻烦,刚刚开始用自己的方法编写了个简单的密码比对,但缺乏很多功能,而且在消斗方面很不完善,容易属错误,现象出不来,后来网上搜了一个,但由于时钟没有完善,所以出错,后来看懂了也可以调,但各个模块的时钟不一,所以难以完善,后来看了指导书上才做出来。

●在VHDL语言上有了很大的完善和提高,对基本的设计都应该没问题了,但还需要努力。

●在设计过程中需要细心、冷静。

5.附页(程序)

50分频:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityPIN1Mis

port(clkin:

instd_logic;

clkout:

outstd_logic);

endentityPIN1M;

architecturebjofPIN1Mis

begin

process(clkin)

variablecnttemp:

INTEGERRANGE0To49;

begin

ifclkin'eventandclkin='1'then

ifcnttemp=49thencnttemp:

=0;

else

ifcnttemp<25thenclkout<='1';

else

clkout<='0';

endif;

cnttemp:

=cnttemp+1;

endif;

endif;

endprocess;

endbj;

 

时钟分频:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

useieee.std_logic_arith.all;

 

entityfdivis

port(clk:

instd_logic;

divout:

outstd_logic);

endentityfdiv;

architecturebjoffdivis

signald:

std_logic_vector(3downto0);

signalo:

std_logic;

begin

process(clk)

begin

ifclk'eventandclk='1'then

ifd="1001"thend<="0000";o<=noto;

elsed<=d+'1';

endif;

divout<=o;

endif;

endprocess;

endbj;

触发器:

LIBRARYIEEE;

USEIEEE.STD_LOGIC_1164.ALL;

ENTITYDchuIS

PORT(trig,sdin,lock,sec,clr,set,crack:

INSTD_LOGIC;

sdin1,lock1,sec1,clr1,set1,crack1:

OUTSTD_LOGIC);

END;

ARCHITECTUREFFQOFDchuIS

SIGNALQ1,Q2,Q3,Q4,Q5,Q6:

STD_LOGIC;

BEGIN

PROCESS(Q1,Q2,Q3,Q4,Q5,Q6,trig)

BEGIN

IFtrig'EVENTANDtrig='1'

THEN

Q1<=sdin;

Q2<=lock;

Q3<=sec;

Q4<=clr;

Q5<=set;

Q6<=crack;

ENDIF;

ENDPROCESS;

sdin1<=Q1;

lock1<=Q2;

sec1<=Q3;

clr1<=Q4;

set1<=Q5;

crack1<=Q6;

ENDFFQ;

编码计数模块:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

 

entitys_pwis

port(SDIN:

instd_logic;

trig:

instd_logic;

lock:

instd_logic;

sec:

instd_logic;

CR:

instd_logic;

SET:

instd_logic;

CRACK:

instd_logic;

din:

outINTEGERRANGE15DOWNTO0;

n_err:

outstd_logic_vector(1downto0);

n_cr:

outstd_logic_vector(1downto0);

ALERT:

outstd_logic;

lock_out:

outstd_logic;

sc:

outstd_logic;

dead_lock:

outstd_logic);

endentitys_pw;

architecturebjofs_pwis

signalpW_reg0:

INTEGERRANGE15DOWNTO0;

signalpW_reg1:

INTEGERRANGE15DOWNTO0;

signalpW_reg2:

INTEGERRANGE15DOWNTO0;

signalpW_reg3:

INTEGERRANGE15DOWNTO0;

signalpc_reg0:

INTEGERRANGE15DOWNTO0;

signalpc_reg1:

INTEGERRANGE15DOWNTO0;

signalpc_reg2:

INTEGERRANGE15DOWNTO0;

signalpc_reg3:

INTEGERRANGE15DOWNTO0;

signaldata_cnt:

INTEGERRANGE15DOWNTO0;

signalcr_cnt:

std_logic_vector(1downto0);

signalerr_cnt:

std_logic_vector(1downto0);

signaltag:

std_logic;

signalsb:

std_logic;

signalbff:

INTEGERRANGE15DOWNTO0;

 

begin

process(trig)

begin

iftrig'eventandtrig='1'then

ifsec='0'thensb<=notsb;sc<=sb;

endif;

iflock='0'thenlock_out<='0';

endif;

iftag='1'thendin<=11;

elseifSDIN='0'then

din<=data_cnt;

ifdata_cnt=9thendata_cnt<=0;

elsedata_cnt<=data_cnt+1;

endif;

endif;

endif;

iftag='0'then

ifCR='0'then

ifSET='0'then

casecr_cntis

when"00"=>pW_reg0<=data_cnt;cr_cnt<=cr_cnt+'1';

when"01"=>pW_reg1<=data_cnt;cr_cnt<=cr_cnt+'1';

when"10"=>pW_reg2<=data_cnt;cr_cnt<=cr_cnt+'1';

when"11"=>pW_reg3<=data_cnt;cr_cnt<=cr_cnt+'1';lock_out<='0';

whenothers=>pw_reg0<=0;

endcase;

elseifcrack='0'then

casecr_cntis

when"00"=>pc_reg0<=data_cnt;cr_cnt<=cr_cnt+'1';

when"01"=>pc_reg1<=data_cnt;cr_cnt<=cr_cnt+'1';

when"10"=>pc_reg2<=data_cnt;cr_cnt<=cr_cnt+'1';

when"11"=>cr_cnt<=cr_cnt+'1';

if(pc_reg0=pw_reg0)then

if(pc_reg1=pw_reg1)then

if(pc_reg2=pw_reg2)then

if(data_cnt=pw_reg3)thendin<=10;err_cnt<="00";

lock_out<='1';

elseerr_cnt<=err_cnt+'1';

endif;

elseerr_cnt<=err_cnt+'1';

endif;

elseerr_cnt<=err_cnt+'1';

endif;

elseerr_cnt<=err_cnt+'1';

endif;

whenothers=>ALERT<='1';

endcase;

endif;

endif;

endif;

endif;

caseerr_cntis

when"00"=>tag<='0';

when"01"=>tag<='0';

when"10"=>tag<='0';

when"11"=>tag<='1';ALERT<='1';

whenothers=>tag<='1';ALERT<='1';

endcase;

n_cr<=cr_cnt;

n_err<=err_cnt;

endif;

dead_lock<=tag;

endprocess;

endbj;

编码送显:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

 

entityDISis

port(din:

instd_logic_vector(3downto0);

cr_cnt:

instd_logic_vector(1downto0);

err_cnt:

instd_logic_vector(1downto0);

set_crack:

instd_logic_vector(1downto0);

disclk:

instd_logic;

sec:

instd_logic;

lock:

instd_logic;

dout:

outstd_logic_vector(7downto0);

encode:

outstd_logic_vector(2downto0));

endentityDIS;

architecturebjofDISis

signalcnt:

std_logic_vector(2downto0);

signalc:

std_logic;

begin

process(din,c,disclk)

begin

ifdisclk'eventanddisclk='1'then

ifcnt="100"thencnt<="000";elsecnt<=cnt+'1';

endif;

ifcnt="000"thenencode<="000";

ifc='0'then

casedinis

when"0000"=>dout<="11000000";

when"0001"=>dout<="11111001";

when"0010"=>dout<="10100100";

when"0011"=>dout<="10110000";

when"0100"=>dout<="10011001";

when"0101"=>dout<="10010010";

when"0110"=>dout<="10000010";

when"0111"=>dout<="11111000";

when"1000"=>dout<="10000000";

when"1001"=>dout<="10010000";

when"1010"=>dout<="11101111";

when"1011"=>dout<="01111111";

whenothers=>dout<="11111111";

endcase;

elsedout<="00000000";

endif;

elseifcnt="001"thenencode<="001";

casecr_cntis

when"00"=>dout<="11111001";

when"01"=>dout<="10100100";

when"10"=>dout<="10110000";

when"11"=>dout<="10011001";

whenothers=>NULL;

endcase;

elseifcnt="010"thenencode<="010";

caseerr_cntis

when"00"=>dout<="11111001";

when"01"=>dout<="10100100";

when"10"=>dout<="10110000";

when"11"=>dout<="10011001";

whenothers=>NULL;

endcase;

elseifcnt="011"thenencode<="011";

caseset_crackis

when"01"=>dout<="00000000";

when"10"=>dout<="11111111";

whenothers=>dout<="10111111";

endcase;

elseifcnt="100"thenencode<="100";

iflock='0'thendout<="00000001";

elsedout<="11111111";

endif;

endif;

endif;

endif;

endif;

endif;

endif;

endprocess;

process(sec)

begin

ifsec'eventandsec='1'thenc<=notc;

endif;

endprocess;

endbj;

课程设计成绩评定表

项目

比例

得分

平时成绩(百分制记分)

30%

业务考核成绩(百分制记分)

70%

总评成绩(百分制记分)

100%

评定等级

优良中及格不及格

指导教师(签名):

20年月日

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 职业教育 > 中职中专

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2