EDA基于VHDL的时钟设计报告.docx

上传人:b****6 文档编号:7226031 上传时间:2023-01-22 格式:DOCX 页数:25 大小:102.37KB
下载 相关 举报
EDA基于VHDL的时钟设计报告.docx_第1页
第1页 / 共25页
EDA基于VHDL的时钟设计报告.docx_第2页
第2页 / 共25页
EDA基于VHDL的时钟设计报告.docx_第3页
第3页 / 共25页
EDA基于VHDL的时钟设计报告.docx_第4页
第4页 / 共25页
EDA基于VHDL的时钟设计报告.docx_第5页
第5页 / 共25页
点击查看更多>>
下载资源
资源描述

EDA基于VHDL的时钟设计报告.docx

《EDA基于VHDL的时钟设计报告.docx》由会员分享,可在线阅读,更多相关《EDA基于VHDL的时钟设计报告.docx(25页珍藏版)》请在冰豆网上搜索。

EDA基于VHDL的时钟设计报告.docx

EDA基于VHDL的时钟设计报告

12/24小时数字钟设计顶层图

12/24小时数字钟设计顶层图

二、模块和程序

1、计数器25000

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityyourname_cnt25000is

port(clk:

instd_logic;

clkout:

outstd_logic);

endyourname_cnt25000;

architecturebavofyourname_cnt25000is

signalcnt:

integerrange0to24999;

begin

process(clk)

begin

ifclk'eventandclk='1'then

ifcnt=24999then

cnt<=0;

else

cnt<=cnt+1;

endif;

ifcnt<12500then

clkout<='1';

else

clkout<='0';

endif;

endif;

endprocess;

endbav;

2、去抖模块

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityyourname_qudouis

port(key_in,clk_1kHz:

instd_logic;

key_out:

outstd_logic);

endyourname_qudou;

architecturebehavofyourname_qudouis

signalcnt20:

integerrange0to19;

begin

process(clk_1kHz,key_in)

begin

ifclk_1kHz'eventandclk_1kHz='1'then

ifcnt20=19then

cnt20<=0;

key_out<=key_in;

else

cnt20<=cnt20+1;

endif;

endif;

endprocess;

endbehav;

3、万年历模块

万年历顶层电路图

①年月日星期模块

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityyourname_ymdxis

port(

preset:

instd_logic;

co:

instd_logic;

date:

outstd_logic_vector(7downto0);

month,year:

outstd_logic_vector(7downto0);

xingqi:

outstd_logic_vector(3downto0));

endyourname_ymdx;

architecturebavofyourname_ymdxis

signalyue:

std_logic_vector(7downto0):

="00000001";

signalnian:

std_logic_vector(7downto0):

="00001100";

signalri:

std_logic_vector(7downto0):

="00001100";

signalxingqi1:

std_logic_vector(3downto0):

="0010";

signalcnt:

std_logic_vector(7downto0):

="00000000";

signalqm:

integerrange28to31;

begin

process(yue,nian)

begin

caseyueis

when"00000001"=>qm<=31;

when"00000010"=>

if(nian(0)='0')and(nian

(1)='0')thenqm<=29;

elseqm<=28;endif;

when"00000011"=>qm<=31;

when"00000100"=>qm<=30;

when"00000101"=>qm<=31;

when"00000110"=>qm<=30;

when"00000111"=>qm<=31;

when"00001000"=>qm<=31;

when"00001001"=>qm<=30;

when"00001010"=>qm<=31;

when"00001011"=>qm<=30;

when"00001100"=>qm<=31;

whenothers=>null;

endcase;

endprocess;

process(co,preset,xingqi1)

begin

ifpreset='0'then

yue<="00000001";

nian<="00001100";

ri<="00001100";

xingqi1<="0010";

else

ifco'eventandco='1'then

if(ri=qm)then

ri<="00000001";

ifxingqi1="0111"then

xingqi1<="0001";

elsexingqi1<=xingqi1+'1';

endif;

if(yue="00001100")thenyue<="00000001";nian<=nian+'1';

else

yue<=yue+'1';

endif;

elsif(ri

ri<=ri+'1';

ifxingqi1="0111"then

xingqi1<="0001";

elsexingqi1<=xingqi1+'1';

endif;

endif;

endif;

endif;

endprocess;

month<=yue;

year<=nian;

date<=ri;

xingqi<=xingqi1;

endbav;

Ⅰ、初始设为2012年1月12日星期4

Ⅱ、观察平年闰年2月不同显示

②7位矢量转换成BCD显示

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

useieee.std_logic_arith.all;

entityyourname_zhuanhuanis

port(input:

instd_logic_vector(7downto0);

output10,output1:

outstd_logic_vector(3downto0));

end;

architecturebavofyourname_zhuanhuanis

signalq:

integerrange0to255;

signalb10,b1:

std_logic_vector(3downto0);

signala,b:

integerrange0to9;

begin

process(input)

begin

q<=conv_integer(input);

a<=(q/10);

b<=(qmod10);

b10<=conv_std_logic_vector(a,4);

b1<=conv_std_logic_vector(b,4);

endprocess;

output10<=b10;

output1<=b1;

endbav;

③按键切换模块分别在en=00,01,10的情况下显示时间,年月日,星期

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityyourname_keyqiehuanis

port(key:

instd_logic;

en:

outstd_logic_vector(1downto0));

endyourname_keyqiehuan;

architecturebehavofyourname_keyqiehuanis

signalen1:

std_logic_vector(1downto0):

="11";

begin

process(key)

begin

ifkey'eventandkey='1'then

en1<=en1+'1';

endif;

endprocess;

en<=en1;

endbehav;

④切换选择输出模块

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityyourname_dispxianshiis

port(en:

instd_logic_vector(1downto0);

xingqi,a0,a1,a2,a3,a4,a5,b0,b1,b2,b3,b4,b5:

instd_logic_vector(3downto0);

c0,c1,c2,c3,c4,c5:

outstd_logic_vector(3downto0));

endyourname_dispxianshi;

architecturebehavofyourname_dispxianshiis

begin

process(en)

begin

ifen="00"then

c0<=a0;

c1<=a1;

c2<=a2;

c3<=a3;

c4<=a4;

c5<=a5;

elsifen="01"then

c0<=b0;

c1<=b1;

c2<=b2;

c3<=b3;

c4<=b4;

c5<=b5;

elsifen="11"then

c0<=xingqi;

endif;

endprocess;

endbehav;

4、分频模块

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityyourname_divis

port(clk_2KHz:

instd_logic;

clk_1KHz,clk_5HZ,clk_1Hz:

outstd_logic);

endyourname_div;

architecturebavofyourname_divis

signalclk1K,clk5,clk1:

std_logic;

signalcnt200:

integerrange0to199;

signalcnt1000:

integerrange0to999;

begin

process(clk_2KHz)

begin

ifclk_2KHz'eventandclk_2KHz='1'then

clk1K<=not(clk1K);

endif;

endprocess;

process(clk1K)

begin

ifclk1K'eventandclk1K='1'then

ifcnt200=199then

cnt200<=0;

else

cnt200<=cnt200+1;

endif;

ifcnt200<100then

clk5<='1';

else

clk5<='0';

endif;

endif;

endprocess;

process(clk1K)

begin

ifclk1K'eventandclk1K='1'then

ifcnt1000=999then

cnt1000<=0;

else

cnt1000<=cnt1000+1;

endif;

ifcnt1000<500then

clk1<='1';

else

clk1<='0';

endif;

endif;

endprocess;

clk_1KHz<=clk1K;

clk_5Hz<=clk5;

clk_1Hz<=clk1;

endbav;

5、两位BCD码六十进制计数器

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityyourname_cnt60is

port(clk,preset:

instd_logic;

bcd10,bcd1:

bufferstd_logic_vector(3downto0);

co:

outstd_logic);

endyourname_cnt60;

architecturebavofyourname_cnt60is

signalco_1:

std_logic;

begin

process(clk,preset)

begin

ifpreset='0'then

bcd1<="0000";

else

ifclk'eventandclk='1'then

ifbcd1="1001"then

bcd1<="0000";

else

bcd1<=bcd1+'1';

endif;

endif;

endif;

endprocess;

process(clk,preset,bcd1)

begin

ifpreset='0'then

bcd10<="0000";

co_1<='0';

else

ifclk'eventandclk='1'then

ifbcd1="1000"andbcd10="0101"then

co_1<='1';

elsifbcd1="1001"andbcd10="0101"then

bcd10<="0000";

co_1<='0';

elsifbcd1="1001"then

bcd10<=bcd10+'1';

co_1<='0';

endif;

endif;

endif;

endprocess;

co<=notco_1;

endbav;

6、报时模块

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityyourname_baoshiis

port(clk_2KHz,clk_1KHz,clk1Hz:

instd_logic;

bcd10S,bcd1S,bcd10M,bcd1M:

instd_logic_vector(3downto0);

clkout:

outstd_logic);

endyourname_baoshi;

architecturebavofyourname_baoshiis

signalclkout_1:

std_logic;

begin

process(bcd10S,bcd1S,bcd10M,bcd1M,clk_2KHz,clk_1KHz,clk1Hz)

begin

if(bcd10M="0101"andbcd1M="1001")and(bcd10S="0101")and(bcd1S>4)and(bcd1S<=9)then

ifclk1Hz='1'then

clkout_1<=clk_1KHz;

else

clkout_1<='Z';

endif;

elsif(bcd10M="0000"andbcd1M="0000")and(bcd10S="0000")and(bcd1S="0000")then

ifclk1Hz='1'then

clkout_1<=clk_2KHz;

else

clkout_1<='Z';

endif;

else

clkout_1<='Z';

endif;

clkout<=clkout_1;

endprocess;

endbav;

7、12/24小时切换控制模块

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityyourname_cnt12_24is

port(clk,contr12_24:

instd_logic;

bcd10,bcd1:

outstd_logic_vector(3downto0));

endyourname_cnt12_24;

architecturebehavofyourname_cnt12_24is

typelyis(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s20,s21,s22,s23);

signalp,n:

ly;

signalb10,b1:

std_logic_vector(3downto0);

begin

process(clk)

begin

ifclk'eventandclk='1'then

p<=n;

endif;

endprocess;

process(p,contr12_24)

begin

casepis

whens0=>ifcontr12_24='0'then

b10<="0000";

b1<="0000";

else

b10<="0001";

b1<="0010";

endif;

n<=s1;

whens1=>b10<="0000";

b1<="0001";

n<=s2;

whens2=>b10<="0000";

b1<="0010";

n<=s3;

whens3=>b10<="0000";

b1<="0011";

n<=s4;

whens4=>b10<="0000";

b1<="0100";

n<=s5;

whens5=>b10<="0000";

b1<="0101";

n<=s6;

whens6=>b10<="0000";

b1<="0110";

n<=s7;

whens7=>b10<="0000";

b1<="0111";

n<=s8;

whens8=>b10<="0000";

b1<="1000";

n<=s9;

whens9=>b10<="0000";

b1<="0101";

n<=s10;

whens10=>b10<="0001";

b1<="0000";

n<=s11;

whens11=>b10<="0001";

b1<="0001";

n<=s12;

whens12=>b10<="0001";

b1<="0010";

n<=s13;

whens13=>ifcontr12_24='0'then

b10<="0001";

b1<="0011";

else

b10<="0000";

b1<="0001";

endif;

n<=s14;

whens14=>ifcontr12_24='0'then

b10<="0001";

b1<="0100";

else

b10<="0000";

b1<="0010";

endif;

n<=s15;

whens15=>ifcontr12_24='0'then

b10<="0001";

b1<="0101";

else

b10<="0000";

b1<="0011";

endif;

n<=s16;

whens16=>ifcontr12_24='0'then

b10<="0001";

b1<="0110";

else

b10<="0000";

b1<="0100";

endif;

n<=s17;

whens17=>ifcontr12_24='0'then

b10<="0001";

b1<="0111";

else

b10<="0000";

b1<="0101";

endif;

n<=s18;

whens18=>ifcontr12_24='0'then

b10<="0001";

b1<="1000";

else

b10<="0000";

b1<="0110";

endif;

n<=s19;

whens19=>ifcontr12_24='0'then

b10<="0001";

b1<="1001";

else

b10<="0000";

b1<="0111";

endif;

n<=s20;

whens20=>ifcontr12_24='0'then

b10<="0010";

b1<="0000";

else

b10<="0000";

b1<="1000";

endif;

n<=s21;

whens21=>ifcontr12_24='0'then

b10<="0010";

b1<="0001";

else

b10<="0000";

b1<="1001";

endif;

n<=s22;

whens22=>ifcontr12_24='0'then

b10<="0010";

b1<="0010";

else

b10<="0001";

b1<="0000";

endif;

n<=s23;

whens23=>ifcontr12_24='0'then

b10<="0010";

b1<="0011";

else

b10<="0001";

b1<="0001";

endif;

n<=s

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

当前位置:首页 > 高等教育 > 研究生入学考试

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1