两段锁相的程序实在看不懂了,求前辈们帮忙看看
时间:10-02
整理:3721RD
点击:
第一段程序:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY pwmgen IS
generic
(
f_len:natural:=9;
delay_len:natural:=9;
dead:natural:=5
);
port(
rst,clk:in std_logic;
feedin:in std_logic;
di:in std_logic;
--delay:in std_logic_vector(f_len-1 downto 0);
pwm1,pwm3,pwm2,pwm4:out std_logic
);
end entity pwmgen ;
architecture bhv of pwmgen is
signal tm,pwm10,pwm20,pwm30,pwm40:std_logic;
signal delay_r:std_logic_vector(delay_len+f_len-1 downto 0);
signal cmp,cmp_dead:std_logic_vector(f_len-1 downto 0);
signal f,fi:std_logic_vector(f_len-1 downto 0);
signal delay:std_logic_vector(f_len-1 downto 0):="011001100";
signal feedcount:std_logic_vector(11 downto 0):="000000000000";
signal close:std_logic:='0';
signal dis: std_logic;
component fcounter
generic
(
f_len:natural:=9;
f_delta:natural:=10
);
port(
rst,clk,di:in std_logic;
f,fi:out std_logic_vector(f_len-1 downto 0);
tm:out std_logic
);
end component;
begin
d1:process(clk,close)
begin
if close='0' then
if clk'event and clk='1' then
if feedcount =0 and fi dead and fi ) of std_logic_vector(f_len-1 downto 0);
signal f_reg:f_reg_type(2+2 downto 0);
signal fsum:std_logic_vector(f_len-1+2 downto 0);
signal di_reg:std_logic_vector(3 downto 0);
signal di_rise,di_fall:std_logic;
signal cnt:std_logic_vector(f_len-1 downto 0);
begin
fsum '0');
f_reg (others=>'0'));
cnt '0');
tm '0');
tm '0');
tm f_reg(4) and f_reg(3)-f_delta f_reg(4)) then
f_reg(2 downto 0)<=f_reg(1 downto 0)&(f_reg(3)+f_reg(4));
end if;
end if;
end process;
di_rise<= '1' when (di_reg(2)='0' and di_reg(1)='0'and di_reg(0)='1' and di='1') else '0';
di_fall<= '1' when (di_reg(2)='1' and di_reg(1)='1'and di_reg(0)='0' and di='0') else '0';
end bhv;
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY pwmgen IS
generic
(
f_len:natural:=9;
delay_len:natural:=9;
dead:natural:=5
);
port(
rst,clk:in std_logic;
feedin:in std_logic;
di:in std_logic;
--delay:in std_logic_vector(f_len-1 downto 0);
pwm1,pwm3,pwm2,pwm4:out std_logic
);
end entity pwmgen ;
architecture bhv of pwmgen is
signal tm,pwm10,pwm20,pwm30,pwm40:std_logic;
signal delay_r:std_logic_vector(delay_len+f_len-1 downto 0);
signal cmp,cmp_dead:std_logic_vector(f_len-1 downto 0);
signal f,fi:std_logic_vector(f_len-1 downto 0);
signal delay:std_logic_vector(f_len-1 downto 0):="011001100";
signal feedcount:std_logic_vector(11 downto 0):="000000000000";
signal close:std_logic:='0';
signal dis: std_logic;
component fcounter
generic
(
f_len:natural:=9;
f_delta:natural:=10
);
port(
rst,clk,di:in std_logic;
f,fi:out std_logic_vector(f_len-1 downto 0);
tm:out std_logic
);
end component;
begin
d1:process(clk,close)
begin
if close='0' then
if clk'event and clk='1' then
if feedcount =0 and fi dead and fi ) of std_logic_vector(f_len-1 downto 0);
signal f_reg:f_reg_type(2+2 downto 0);
signal fsum:std_logic_vector(f_len-1+2 downto 0);
signal di_reg:std_logic_vector(3 downto 0);
signal di_rise,di_fall:std_logic;
signal cnt:std_logic_vector(f_len-1 downto 0);
begin
fsum '0');
f_reg (others=>'0'));
cnt '0');
tm '0');
tm '0');
tm f_reg(4) and f_reg(3)-f_delta f_reg(4)) then
f_reg(2 downto 0)<=f_reg(1 downto 0)&(f_reg(3)+f_reg(4));
end if;
end if;
end process;
di_rise<= '1' when (di_reg(2)='0' and di_reg(1)='0'and di_reg(0)='1' and di='1') else '0';
di_fall<= '1' when (di_reg(2)='1' and di_reg(1)='1'and di_reg(0)='0' and di='0') else '0';
end bhv;
仿真时为什么pwm1和pwm3 没有输出波形呢?请前辈们指教啊
这几天也在琢磨PWM,看半天,还是没有看懂你的程序
没有看懂,等待大神来解释了