⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 new_pwm.vhd.bak

📁 一个PWM参数器
💻 BAK
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity new_pwm is
port(clk:in std_logic;
wrData:in std_logic_vector(15 downto 0);
PwmOut:out std_logic);
end entity;

architecture one of new_pwm is
shared variable wr_en:std_logic:='0';
shared variable y_en:std_logic;
constant wr_period: std_logic_vector(15 downto 0):="0000000100000000";
signal period:std_logic_vector(15 downto 0);
signal duty:std_logic_vector(15 downto 0);
signal counter:std_logic_vector(15 downto 0);
begin
process(clk,wrData)
begin
if rising_edge(clk) then
if(wr_en='0') then
if period=0 then                  ----addr='0' and wr_en='0',write wrData to the period
period<=wr_period;
duty<=duty;
else
period<=period;
duty<=wrData;
end if;
else
period<=period;
duty<=duty;
end if;
end if;
end process;

process(clk)
begin
if falling_edge(clk) then
if counter=0 then 
y_en:='0';
counter<=period;
else 
y_en:='1';
counter<=counter-'1';
end if;
if counter<duty then PwmOut<='0';
elsif counter>=duty and wr_en='1' then PwmOut<='1';
end if;
end if;
wr_en:=y_en;
end process;
end one;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -