|
好 初学 见笑了: entity new823572 is
PORT( clk2,wr,clk1 ,start: IN STD_LOGIC;
din : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
g1,g2,g3: out std_logic );
end new823572;
architecture Behavioral of new823572 is
signal count : integer range 0 to 4096 ; -- 取得数值 16 4000 --
signal mt1,mt2,mt3: integer RANGE 0 TO 1000:=0;
signal sen1,sen2,sen3 :std_logic :='0' ;
signal senb1,senb2,senb3:std_logic :='0';
begin
p0: process(wr)
begin
if (wr'EVENT) and (wr ='0') then
count <= conv_integer(din)-1;
end if;
end process p0;
x: process(clk1)
variable clkcount1 : integer range 0 to 6:=0;
begin
if (clk1'EVENT) and (clk1 ='1') then
-- if(start='0') then
clkcount1 := clkcount1+1;
if(clkcount1=1) then
senb1<='1';
senb2<='0';
elsif(clkcount1=3)then
senb2<='1';
senb3<='0';
elsif(clkcount1=5)then
senb3<='1';
senb1<='0';
elsif(clkcount1=6)then
clkcount1:=0;
end if;
-- else
-- senb1<='0';
-- senb2<='0';
-- senb3<='0';
-- clkcount1:=0;
-- end if ;
end if;
end process x;
p1: process(clk2)
begin
if (clk2'EVENT) and (clk2 = '1') then
--if(start='0') then
if (senb1='1') and (sen1='0') then
if(mt1=count) then
mt1<=0;
g1<='1';
sen1<='1';
sen2<='0';
else
-- g1<='0';
mt1<=mt1+1;
end if ;
else
g1<= '0' ;
end if;
if (senb2='1') and (sen2='0') then
if(mt2=count) then
mt2<=0;
g2<='1';
sen2<='1';
sen3<='0';
else
-- g2<='0';
mt2<=mt2+1;
end if ;
else
g2<='0' ;
end if;
if (senb3='1') and (sen3='0') then
if(mt3=count) then
mt3<=0;
g3<='1';
sen3<='1';
sen1<='0';
else
-- g3<='0';
mt3<=mt3+1;
end if ;
else
g3<='0' ;
end if;
-- else
-- mt1<=0;
-- mt2<=0;
-- mt3<=0;
-- sen1<='0';
-- sen2<='1';
-- sen3<='1';
-- end if ;
end if ;
end process p1;
end Behavioral;
我的本意如上图 在CLK1 的第一个上升沿 到来延时一段时间后 g1 有一个脉冲 但是现在仿真是对的 但是实际 在CLK1的下降沿 也出现了脉冲 |
|