欢迎来到天天文库
浏览记录
ID:39549421
大小:125.04 KB
页数:19页
时间:2019-07-06
《CPLD课程设计代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、附:程序代码注:译码器,分频,点阵,流水灯,步进电机五部分为源代码的功能拓展,带下划线部分为修改或添加的代码。交通灯,多路选择器为编写设计代码。1、译码器:LIBRARYieee;USEieee.std_logic_1164.ALL;ENTITYdecoder3_8ISPORT(A,B,C:INSTD_LOGIC;Y:OUTSTD_LOGIC_VECTOR(7DOWNTO0);--段选输出en:OUTSTD_LOGIC_VECTOR(7DOWNTO0));--位选输出ENDdecoder3_8;ARCHITECTUREfunOFdecoder3_8ISSIGNALindata:STD_LO
2、GIC_VECTOR(2DOWNTO0);BEGINindata<=C&B&A;encoder:PROCESS(indata)BEGINCASEindataISWHEN"000"=>Y<="01000000";en<="00000001";WHEN"001"=>Y<="01111001";en<="00000010";WHEN"010"=>Y<="00100100";en<="00000100";WHEN"011"=>Y<="00110000";en<="00001000";WHEN"100"=>Y<="00011001";en<="00010000";WHEN"101"=>Y<="000
3、10010";en<="00100000";WHEN"110"=>Y<="00000010";en<="01000000";WHEN"111"=>Y<="01111000";en<="10000000";WHENOTHERS=>Y<="11111111";en<="00000000";ENDCASE;ENDPROCESSencoder;ENDfun;2、分频:libraryieee;useieee.std_logic_1164.all;entitydiv_fisport(clk:instd_logic;miao_out:outstd_logic;f_miao_out:outstd_logi
4、c;fourhz:outstd_logic;--4Hz输出halfhz:outstd_logic;--0.5Hz输出19en:outstd_logic);enddiv_f;architecturemiaoofdiv_fisbeginen<='1';p1:process(clk)variablecnt:integerrange0to3999999;variableff:std_logic;beginifclk'eventandclk='1'thenifcnt<3999999thencnt:=cnt+1;elsecnt:=0;ff:=notff;endif;endif;miao_out<=ff
5、;endprocessp1;p2:process(clk)variablecnn:integerrange0to1999999;variabledd:std_logic;beginifclk'eventandclk='1'thenifcnn<1999999thencnn:=cnn+1;elsecnn:=0;dd:=notdd;endif;endif;f_miao_out<=dd;endprocessp2;------------p3:4Hz生成部分--------------p3:process(clk)variablecnt0:integerrange0to999999;variable
6、aa:std_logic;beginifclk'eventandclk='1'thenifcnt0<999999thencnt0:=cnt0+1;elsecnt0:=0;aa:=notaa;19endif;endif;fourhz<=aa;endprocessp3;--------p4:0.5Hz生成部分-------------p4:process(clk)variablecnn0:integerrange0to7999999;variablebb:std_logic;beginifclk'eventandclk='1'thenifcnn0<7999999thencnn0:=cnn0+1
7、;elsecnn0:=0;bb:=notbb;endif;endif;halfhz<=bb;endprocessp4;endmiao;3、点阵libraryIEEE;useIEEE.STD_LOGIC_1164.ALL;useIEEE.STD_LOGIC_ARITH.ALL;useIEEE.STD_LOGIC_UNSIGNED.ALL;ENTITYdianzhenISPORT(clk:INSTD_LOGIC;l:outS
此文档下载收益归作者所有