您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 项目/工程管理 > 12--24小时数字时钟VHDL设计
±¨Ê±µç·libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityly4948_baoshiisport(clk_2KHz,clk_1KHz,clk1Hz:instd_logic;bcd10S,bcd1S,bcd10M,bcd1M:instd_logic_vector(3downto0);clkout:outstd_logic);endly4948_baoshi;architecturebavofly4948_baoshiissignalclkout_1:std_logic;beginprocess(bcd10S,bcd1S,bcd10M,bcd1M,clk_2KHz,clk_1KHz,clk1Hz)beginif(bcd10M=0101andbcd1M=1001)and(bcd10S=0101)and(bcd1S4)and(bcd1S=9)thenifclk1Hz='1'thenclkout_1=clk_1KHz;elseclkout_1='Z';endif;elsif(bcd10M=0000andbcd1M=0000)and(bcd10S=0000)and(bcd1S=0000)thenifclk1Hz='1'thenclkout_1=clk_2KHz;elseclkout_1='Z';endif;elseclkout_1='Z';endif;clkout=clkout_1;endprocess;endbav;1224Сʱת»»µç·libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityly4948_cnt12_24isport(clk,contr12_24:instd_logic;bcd10,bcd1:outstd_logic_vector(3downto0));endly4948_cnt12_24;architecturebehavofly4948_cnt12_24istypelyis(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);beginprocess(clk)beginifclk'eventandclk='1'thenp=n;endif;endprocess;process(p,contr12_24)begincasepiswhens0=ifcontr12_24='0'thenb10=0000;b1=0000;elseb10=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'thenb10=0001;b1=0011;elseb10=0000;b1=0001;endif;n=s14;whens14=ifcontr12_24='0'thenb10=0001;b1=0100;elseb10=0000;b1=0010;endif;n=s15;whens15=ifcontr12_24='0'thenb10=0001;b1=0101;elseb10=0000;b1=0011;endif;n=s16;whens16=ifcontr12_24='0'thenb10=0001;b1=0110;elseb10=0000;b1=0100;endif;n=s17;whens17=ifcontr12_24='0'thenb10=0001;b1=0111;elseb10=0000;b1=0101;endif;n=s18;whens18=ifcontr12_24='0'thenb10=0001;b1=1000;elseb10=0000;b1=0110;endif;n=s19;whens19=ifcontr12_24='0'thenb10=0001;b1=1001;elseb10=0000;b1=0111;endif;n=s20;whens20=ifcontr12_24='0'thenb10=0010;b1=0000;elseb10=0000;b1=1000;endif;n=s21;whens21=ifcontr12_24='0'thenb10=0010;b1=0001;elseb10=0000;b1=1001;endif;n=s22;whens22=ifcontr12_24='0'thenb10=0010;b1=0010;elseb10=0001;b1=0000;endif;n=s23;whens23=ifcontr12_24='0'thenb10=0010;b1=0011;elseb10=0001;b1=0001;endif;n=s0;whenothers=null;endcase;endprocess;bcd10=b10;bcd1=b1;endbehav;¶¯Ì¬ÒëÂëÆ÷displaylibraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityly4948_dispisport(din0,din1,din2,din3,din4,din5:instd_logic_vector(3downto0);clk:instd_logic;led_sa,led_sb,led_sc:outstd_logic;led_a,led_b,led_c,led_d,led_e:outstd_logic;led_f,led_g,led_dp:outstd_logic);endly4948_disp;architecturebavofly4948_dispissignalseg:std_logic_vector(6downto0);signalsel:std_logic_vector(2downto0);signalnum:std_logic_vector(3downto0);signals:std_logic_vector(2downto0);beginled_sa=sel(0);led_sb=sel(1);led_sc=sel(2);led_a=seg(0);led_b=seg(1);led_c=seg(2);led_d=seg(3);led_e=seg(4);led_f=seg(5);led_g=seg(6);process(clk)beginifclk'eventandclk='1'thenifs=101thens=000;elses=s+'1';endif;endif;endprocess;process(s,din0,din1,din2,din3,din4,din5)beginifs=000thensel=000;num=din0;led_dp='0';elsifs=001thensel=001;num=din1;led_dp='0';elsifs=010thensel=010;num=din2;led_dp='0';elsifs=011thensel=011;num=din3;led_dp='0';elsifs=100thensel=100;num=din4;led_dp='0';elsifs=101thensel=101;num=din5;led_dp='0';elsesel=XXX;num=XXXX;led_dp='0';endif;endprocess;seg=0111111whennum=0else0000110whennum=1else1011011whennum=2else1001111whennum=3else1100110whennum=4else1101101whennum=5else1111101whennum=6else0000111whennum=7else1111111whennum=8else1101111whennum=9else1110111whennum=10else1111100whennum=11else0111001whennum=12else1011110whennum=13else1111001whennum=14else1110001whennum=15else0000000;endbav;2Ñ¡1Ñ¡ÔñÆ÷libraryieee;useieee.std_logic_1164.all;entityly4948_mux2isport(sel,a,b:instd_logic;q:outstd_logic);endly4948_mux2;architecturebavofly4948_mux2isbeginprocess(sel,a,b)beginifsel='1'thenq=a;elseq=b;endif;endprocess;endbav;
本文标题:12--24小时数字时钟VHDL设计
链接地址:https://www.777doc.com/doc-4796813 .html