完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
这是一个奇偶数控分频器的程序,我可以实现就分频了,可是K-OR占空比不是50%是怎么回事,谁能找出问题所在
LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; USE IEEE.STD_LOGIC_ARITH.ALL; ENtiTY DIV IS PORT (CLK:IN STD_LOGIC; D:in STD_LOGIC_VECTOR(3 DOWNTO 0); K_OR,K1,K2:OUT STD_LOGIC); END; ARCHITECTURE bhv OF DIV IS SIGNAL R,C1,C2:STD_LOGIC_VECTOR(3 DOWNTO 0); SIGNAL M1,M2:STD_LOGIC; --VARIABLE R: INTEGER RANGE 0 TO 1; BEGIN PROCESS(R) BEGIN R<=D+1; END PROCESS; PROCESS(CLK,C1) BEGIN --R := (D REM 2);--TO_STDLOGICVECTOR(TO_BITVECTOR(R) SRL(1))) IF RISING_EDGE(CLK) THEN IF (D(0)='1') THEN IF (C1=D-1) THEN C1<="0000"; ELSE C1<= C1+1; END IF; IF (C1="0001") THEN M1<=NOT M1; ELSIF (C1<="0"&R(3 DOWNTO 1)) THEN M1<=NOT M1;END IF; ELSE--IF(D(0)='0') THEN IF (C1=D-1) THEN C1<="0000"; ELSE C1<= C1+1; END IF; IF (C1="0000") THEN M1<=NOT M1; ELSIF (C1<="0"&D(3 DOWNTO 1))THEN M1<=NOT M1; END IF; END IF; END IF; END PROCESS; PROCESS(CLK,C2) BEGIN IF FALLING_EDGE(CLK) THEN IF (D(0)='1') THEN IF (C2=D-1) THEN C2<="0000"; ELSE C2<= C2+1; END IF; IF (C2="0001") THEN M2<=NOT M2; ELSIF (C2<="0"&R(3 DOWNTO 1))THEN M2<=NOT M2;END IF; --ELSIF(D(0)='0') THEN --IF (C2=D-1) THEN C2<="0000"; ELSE C2<= C2+1; END IF; --IF (C2="0000") THEN M2<=NOT M2; ELSIF (C2<=TO_STDLOGICVECTOR(TO_BITVECTOR(D) SRL(1))) THEN M2<=NOT M2; END IF; END IF; END IF; END PROCESS; K1<=M1; K2<=M2; K_OR<=M1 OR M2; END bhv; |
|
相关推荐
1个回答
|
|
IF (D(0)='1') THEN
IF (C1=D-1) THEN C1<="0000"; ELSE C1<= C1+1; END IF; IF (C1="0001") THEN M1<=NOT M1; ELSIF (C1<="0"&R(3 DOWNTO 1)) THEN M1<=NOT M1;END IF; ELSE--IF(D(0)='0') THEN IF (C1=D-1) THEN C1<="0000"; ELSE C1<= C1+1; END IF; IF (C1="0000") THEN M1<=NOT M1; ELSIF (C1<="0"&D(3 DOWNTO 1))THEN M1<= 有问题 |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
4607 浏览 3 评论
5890 浏览 1 评论
6164 浏览 0 评论
Protues中自己封装的芯片元件无Program File、Clock Frequency选项怎么解决,求求大神了!
7901 浏览 1 评论
基于51单片机的车辆倒车雷达报警系统,HC-SR04超声波测距,全套资料
1226 浏览 0 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 08:16 , Processed in 0.617813 second(s), Total 74, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号