-- 表示8位数值比较器>=DCH,输出=1 LIBRARY IEEE ; USE IEEE.STD_LOGIC_1164.ALL ; ENTITY comparator_bc IS PORT ( dataA : IN STD_LOGIC_VECTOR ( 7 DOWNTO 0 ) ; rfmute : IN STD_LOGIC; greater_bc : OUT STD_LOGIC ); -- A大于DCH输出信号 END ENTITY comparator_bc ;
ARCHITECTURE behavioral OF comparator_bc IS SIGNAL dataB : STD_LOGIC_VECTOR ( 7 DOWNTO 0 ) ;--can't in
BEGIN inst_comparator : PROCESS ( rfmute,dataA, dataB ) BEGIN dataB <= "11011100"; --dataB=DCH IF ( rfmute='1' ) THEN FOR i IN 7 DOWNTO 0 LOOP IF ( dataA ( i ) = '1' AND dataB ( i ) = '0' ) THEN greater_bc <= '1' ; EXIT ; -- 已经判断出dataA> dataB,则跳出循环 ELSE greater_bc <= '0' ; END IF; END LOOP; ELSE greater_bc <= '0' ; END IF ; END PROCESS inst_comparator ; END ARCHITECTURE behavioral ;
在maxplus2试验时,EXIT要删除,否则编译不能通过。 做试验时,在高四位输入为1101时输出改变,与低四位无关,不知道程序有什么问题。请高手指点。谢谢! |