?? pwm.vhd
字號:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity pwm is
port(ctrl:in std_logic_vector(3 downto 0); ----PWM控制信號
clk:in std_logic; ------------10KHz時鐘信號
pwm1,pwm2:out std_logic); ----------雙路PWM波輸出
end entity;
architecture one of pwm is
signal cnt:std_logic_vector(4 downto 0);--integer range 0 to 19; --計時變量
signal ctrl1:std_logic_vector(4 downto 0);
begin
ctrl1<='0'& ctrl;
process(clk)------------------------計數器計數
begin
if clk'event and clk='1' then
if cnt=19 then cnt<="00000";
else cnt<=cnt+1;
end if;
end if;
end process;
process(clk)-------------pwm1和pwm2的產生
begin
if clk'event and clk='1' then
if cnt<ctrl1 then
pwm1<='1';
pwm2<='0';
elsif ((cnt<10)and (cnt>=ctrl1)) then
pwm1<='0';
pwm2<='0';
elsif ((cnt>=10)and (cnt<ctrl1+10)) then
pwm1<='0';
pwm2<='1';
else pwm1<='0';
pwm2<='0';
end if;
end if;
end process;
end one;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -