|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
本人在VHDL方面是小白,下面的程序的激励信号怎么添加啊?
源程序:LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
ENTITY PWM IS
PORT(
CLK:IN STD_LOGIC;
D :IN STD_LOGIC_VECTOR(11 DOWNTO 0);
A :OUT STD_LOGIC_VECTOR(11 DOWNTO 0);
PWMH:OUT STD_LOGIC;
PWML:OUT STD_LOGIC
);
END;
ARCHITECTURE BEHAVE OF PWM IS
SIGNAL PH:STD_LOGIC;
SIGNAL PL:STD_LOGIC;
SIGNAL COUNTH :STD_LOGIC_VECTOR(11 DOWNTO 0);
BEGIN
PROCESS(CLK)
BEGIN
IF CLK'EVENT AND CLK='1' AND CLK'LAST_VALUE='0' THEN
COUNTH<=COUNTH+'1';
IF COUNTH="000000001111" THEN COUNTH<="000000000000";
END IF;
END IF;
IF COUNTH<=D THEN PH<='1'; PL<='0';
ELSIF COUNTH>D THEN PH<='0'; PL<='1';
END IF;
END PROCESS ;
PWMH<=PH;
PWML<=PL;
A<=COUNTH;
END;
测试平台程序:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY test IS
END test;
ARCHITECTURE behavior OF test IS
COMPONENT PWM
PORT(
CLK : IN std_logic;
D : IN std_logic_vector(11 downto 0);
A : OUT std_logic_vector(11 downto 0);
PWMH : OUT std_logic;
PWML : OUT std_logic
);
END COMPONENT;
--Inputs
signal CLK : std_logic := '0';
signal D : std_logic_vector(11 downto 0) := (others => '0');
--Outputs
signal A : std_logic_vector(11 downto 0);
signal PWMH : std_logic;
signal PWML : std_logic;
-- Clock period definitions
constant CLK_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: PWM PORT MAP (
CLK => CLK,
- 本人在VHDL方面是小白,下面的程序的激励信号怎么添加啊?
- 源程序:
- LIBRARY IEEE;
- USE IEEE.STD_LOGIC_1164.ALL;
- USE IEEE.STD_LOGIC_UNSIGNED.ALL;
- USE IEEE.STD_LOGIC_ARITH.ALL;
- ENTITY PWM IS
- PORT(
- CLK:IN STD_LOGIC;
- D :IN STD_LOGIC_VECTOR(11 DOWNTO 0);
- A :OUT STD_LOGIC_VECTOR(11 DOWNTO 0);
- PWMH:OUT STD_LOGIC;
- PWML:OUT STD_LOGIC
- );
- END;
- ARCHITECTURE BEHAVE OF PWM IS
- SIGNAL PH:STD_LOGIC;
- SIGNAL PL:STD_LOGIC;
- SIGNAL COUNTH :STD_LOGIC_VECTOR(11 DOWNTO 0);
- BEGIN
- PROCESS(CLK)
- BEGIN
- IF CLK'EVENT AND CLK='1' AND CLK'LAST_VALUE='0' THEN
- COUNTH<=COUNTH+'1';
- IF COUNTH="000000001111" THEN COUNTH<="000000000000";
- END IF;
- END IF;
- IF COUNTH<=D THEN PH<='1';PL<='0';
- ELSIF COUNTH>D THEN PH<='0'; PL<='1';
- END IF;
- END PROCESS ;
- PWMH<=PH;
- PWML<=PL;
- A<=COUNTH;
- END;
- 测试平台程序:
- LIBRARY ieee;
- USE ieee.std_logic_1164.ALL;
- -- Uncomment the following library declaration if using
- -- arithmetic functions with Signed or Unsigned values
- --USE ieee.numeric_std.ALL;
- ENTITY test IS
- END test;
- ARCHITECTURE behavior OF test IS
- -- Component Declaration for the Unit Under Test (UUT)
- COMPONENT PWM
- PORT(
- CLK : IN std_logic;
- D : IN std_logic_vector(11 downto 0);
- A : OUT std_logic_vector(11 downto 0);
- PWMH : OUT std_logic;
- PWML : OUT std_logic
- );
- END COMPONENT;
- --Inputs
- signal CLK : std_logic := '0';
- signal D : std_logic_vector(11 downto 0) := (others => '0');
- --Outputs
- signal A : std_logic_vector(11 downto 0);
- signal PWMH : std_logic;
- signal PWML : std_logic;
- -- Clock period definitions
- constant CLK_period : time := 10 ns;
- BEGIN
- -- Instantiate the Unit Under Test (UUT)
- uut: PWM PORT MAP (
- CLK => CLK,
- D => D,
- A => A,
- PWMH => PWMH,
- PWML => PWML
- );
- -- Clock process definitions
- CLK_process :process
- begin
- CLK <= '0';
- wait for CLK_period/2;
- CLK <= '1';
- wait for CLK_period/2;
- end process;
- -- Stimulus process
- stim_proc: process
- begin
- -- hold reset state for 100 ns.
- wait for 100 ns;
- wait for CLK_period*10;
- -- insert stimulus here
- wait;
- end process;
- END;
- 拜托了!!
复制代码
D => D,
A => A,
PWMH => PWMH,
PWML => PWML
);
-- Clock process definitions
CLK_process :process
begin
CLK <= '0';
wait for CLK_period/2;
CLK <= '1';
wait for CLK_period/2;
end process;
END;
拜托了!! |
|