📄 pwm18.vhd
字号:
------------------------------------------------------------------------
-- pwm2x.vhd -- Pulse Width Modulator
------------------------------------------------------------------------
-- Author : Kovacs Laszlo - Attila
------------------------------------------------------------------------
-- Software version: Xilinx ISE 7.1.04i
-- WebPack
------------------------------------------------------------------------
-- This Pulse Width Modulator according to the 6 most significant bits
-- of the data input selects one of the 32 logics (pulse widths).
------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity pwm18 is
Port ( CLK2X : in std_logic;
CLK : in std_logic;
CLK2 : in std_logic;
CLK4 : in std_logic;
CLK8 : in std_logic;
DO : out std_logic;
DI : in std_logic_vector(7 downto 0));
end pwm18;
architecture Behavioral of pwm18 is
signal pwmsel, pwmsel2 : std_logic_vector(4 downto 0) := "00000";
signal pwmsel3 : std_logic_vector(3 downto 0) := "0000";
begin
pwmsel(4) <= DI(7);
pwmsel(3 downto 0) <= pwmsel3 when DI(7) = '1' else not pwmsel3;
pwmsel2 <= DI(6 downto 2) when DI(7) = '1' else not DI(6 downto 2);
with pwmsel2(4 downto 0) select
pwmsel3
<= "1111" when "11111",
"1111" when "11110",
"1111" when "11101",
"1111" when "11100",
"1111" when "11011",
"1110" when "11010",
"1110" when "11001",
"1110" when "11000",
"1110" when "10111",
"1101" when "10110",
"1101" when "10101",
"1101" when "10100",
"1100" when "10011",
"1100" when "10010",
"1011" when "10001",
"1011" when "10000",
"1010" when "01111",
"1010" when "01110",
"1001" when "01101",
"1001" when "01100",
"1000" when "01011",
"1000" when "01010",
"0111" when "01001",
"0111" when "01000",
"0110" when "00111",
"0110" when "00110",
"0101" when "00101",
"0100" when "00100",
"0011" when "00011",
"0010" when "00010",
"0001" when "00001",
"0000" when others;
with pwmsel select
DO <= '1' when "11111",--32
CLK8 or CLK4 or CLK2 or CLK or CLK2X when "11110",--31
CLK8 or CLK4 or CLK2 or CLK when "11101",--30
CLK8 or CLK4 or CLK2 or (CLK and CLK2X) when "11100",--29
CLK8 or CLK4 or CLK2 when "11011",--28
CLK8 or CLK4 or (CLK2 and (CLK or CLK2X)) when "11010",--27
CLK8 or CLK4 or (CLK2 and CLK) when "11001",--26
CLK8 or CLK4 or (CLK2 and CLK and CLK2X) when "11000",--25
CLK8 or CLK4 when "10111",--24
CLK8 or (CLK4 and (CLK2 or CLK or CLK2X)) when "10110",--23
CLK8 or (CLK4 and (CLK2 or CLK)) when "10101",--22
CLK8 or (CLK4 and (CLK2 or (CLK and CLK2X)))when "10100",--21
CLK8 or (CLK4 and CLK2) when "10011",--20
CLK8 or (CLK4 and CLK2 and (CLK or CLK2X)) when "10010",--19
CLK8 or (CLK4 and CLK2 and CLK) when "10001",--18
CLK8 or (CLK4 and CLK2 and CLK and CLK2X) when "10000",--17
CLK8 when "01111",--16
CLK8 and (CLK4 or CLK2 or CLK or CLK2X) when "01110",--15
CLK8 and (CLK4 or CLK2 or CLK) when "01101",--14
CLK8 and (CLK4 or CLK2 or (CLK and CLK2X)) when "01100",--13
CLK8 and (CLK4 or CLK2) when "01011",--12
CLK8 and (CLK4 or (CLK2 and (CLK or CLK2X)))when "01010",--11
CLK8 and (CLK4 or (CLK2 and CLK)) when "01001",--10
CLK8 and (CLK4 or (CLK2 and CLK and CLK2X)) when "01000",--09
CLK8 and CLK4 when "00111",--08
CLK8 and CLK4 and (CLK2 or CLK or CLK2X) when "00110",--07
CLK8 and CLK4 and (CLK2 or CLK) when "00101",--06
CLK8 and CLK4 and (CLK2 or (CLK and CLK2X)) when "00100",--05
CLK8 and CLK4 and CLK2 when "00011",--04
CLK8 and CLK4 and CLK2 and not CLK when "00010",--03
CLK8 and CLK4 and CLK2 and CLK2X when "00001",--01
'0' when others; --00
end Behavioral;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -