VHDL数字秒表设计文档格式.docx
《VHDL数字秒表设计文档格式.docx》由会员分享,可在线阅读,更多相关《VHDL数字秒表设计文档格式.docx(10页珍藏版)》请在冰豆网上搜索。
3、一个24进制计数器,用来对小时进行计数;
3、分频率器:
用来产生100Hz的计数脉冲;
4、显示译码器:
完成对显示译码的控制。
四、设计过程:
1.分频器:
由10MHz变为100Hz,10MHz的周期是10的(-7)次方,而100Hz的周期是10的(-2)次方,而且方波是高低相间,只有高电平有效,所以100Hz的周期需要取一半,即0.02秒,这样算出的分频倍数就是50000
分频器代码:
将10MHz脉冲变成100Hz
程序:
libraryieee;
useieee.std_logic_1164.all;
entityfenpinis
port(clr,clk:
inbit;
q:
bufferbit);
endfenpin;
architectureaoffenpinis
signalcounter:
integerrange0to49999;
begin
process(clr,clk)
begin
if(clk='
1'
andclk'
event)then
ifclr='
then
counter<
=0;
elsifcounter=49999then
q<
=notq;
else
=counter+1;
endif;
endprocess;
enda;
分频器的仿真图:
2.十进制计数器:
原理为加法计数器,从0加到9,计到10个数时由cout进位
useieee.std_logic_unsigned.all;
entityc10is
port(clr,start,clk:
cout:
outbit;
daout:
outstd_logic_vector(3downto0));
endc10;
architectureaofc10is
signaltemp:
std_logic_vector(3downto0);
daout<
=temp;
process(clk,clr)
then
temp<
="
0000"
;
cout<
='
0'
elsif(clk'
eventandclk='
)then
ifstart='
iftemp>
1001"
temp<
cout<
else
=temp+1;
endprocess;
十进制计数器仿真图:
3.六进制计数器:
原理为加法计数器,从0加到5计到第六个数时由cout进位。
entityc6is
daout:
outstd_logic_vector(3downto0);
cout:
outstd_logic);
endc6;
architectureaofc6is
process(clk,clr)
ifstart='
0101"
endprocess;
6进制计数器仿真图:
4、二十四进制计数器
采用一个二进制的计数器和一个四进制的计数器相结合到一起,低位从0到9,到9向高位进一,当低位计到四,高位计到2,进行进位输出,即每二十四个数进行一次进位输出
entityc24is
port(clr,start,clk:
instd_logic;
hour1,hour0:
outstd_logic_vector(3downto0));
endc24;
architectureaofc24is
begin
process(clr,clk)
variablet1,t0:
ifclr='
thent0:
t1:
elsifclk'
ift1="
0010"
andt0="
0011"
thent1:
t0:
elsift0<
"
=t0+1;
elset0:
t1:
=t1+1;
endif;
hour1<
=t1;
hour0<
=t0;
24进制计数器仿真图:
5.数据选择和数码管选择模块代码:
其功能是选择计数端口来的数据,当相应的数据到来时数据选择器数据后输数给数码管,并由数码管显示。
八个数码管分别显示小时,分钟,秒,百分秒
entityseltimeis
port(clk:
dain0,dain1,dain2,dain3,dain4,dain5,dain6,dain7:
instd_logic_vector(3downto0);
sel:
outstd_logic_vector(2downto0);
endseltime;
architectureaofseltimeis
signaltemp:
integerrange0to7;
process(clk)
andclk'
event)then
iftemp=7thentemp<
elsetemp<
=temp+1;
casetempis
when0=>
sel<
000"
=dain0;
when1=>
001"
=dain1;
when2=>
=dain2;
when3=>
011"
=dain3;
when4=>
100"
=dain4;
when5=>
101"
=dain5;
when6=>
110"
=dain6;
when7=>
111"
=dain7;
endcase;
仿真图:
5.数码管驱动模块代码:
数码管驱动电路,驱动数码管发光。
entitydeledis
port(num:
instd_logic_vector(3downto0);
led:
outstd_logic_vector(6downto0));
enddeled;
architectureaofdeledis
process(num)
casenumis
when"
=>
led<
0111111"
-----------3FH
0001"
0000110"
-----------06H
1011011"
-----------5BH
1001111"
-----------4FH
0100"
1100110"
-----------66H
1101101"
-----------6DH
0110"
1111101"
-----------7DH
0111"
0100111"
-----------27H
1000"
1111111"
-----------7FH
1101111"
-----------6FH
whenothers=>
0000000"
-----------00H
五、秒表原理图
六:
实验总结
通过本次的课程设计,我初步了解了vhdl语言的编程思想,以及利用EDA软件进行电子电路设计的方法,通过对一个课题的分析,将实验的容进行分块解读,具体到每一个模块的具体作用,然后将各个功能的模块通过连线进行总体的电路实现,也可以通过Vhdl语言对各个模块进行组合,然后需要在程序编译成功的基础上,安装硬件,将程序下载到具体的芯片上进行硬件的实现。
通过整个实验的完成,我从老师和同学那里学到了更多关于vhdl编程,仿真以及硬件实现的知识,自己以前模糊不清的地方也通过此次的课程设计了解清楚了,并且通过这次课程设计,我也锻炼了独立思考,独立操作的能力,虽然对于vhdl语言的应用我还很生疏,但是此次的课程设计却让我学到了很多,也对这门语言有了更深的理解,对eda软件的使用有了更多的体会。