Forum Discussion
Altera_Forum
Honored Contributor
15 years agoheres the code I used:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
--use std.textio.all;
--use ieee.std_logic_textio.all;
------------------------------------------------------------------------------
entity tb_pwm is
end entity tb_pwm;
------------------------------------------------------------------------------
architecture arc_tb_pwm of tb_pwm is
signal Clk : std_logic := '0'; --
signal Rst : std_logic := '0'; --
signal Sw : std_logic_vector (2 downto 0):= "000"; --
signal Enable : std_logic := '0'; --
signal Pwm : std_logic; --
signal Led : std_logic_vector(7 downto 0); --
begin
test : entity work.pwm
generic map(
DC => 100 ns,
clock_period => 20 ns
)
port map (
Clk => Clk,
Rst => Rst,
Enable => Enable,
Sw => Sw,
Pwm => Pwm,
Led => Led );
Clk <= not Clk after 10 ns;
process
begin
wait until rising_edge(Clk);
Enable <= '1';
rst <= '1';
wait until rising_edge(clk);
rst <= '0';
Sw(0) <= '1';
Sw(1) <= '0';
Sw(2) <= '0';
wait for 100 ns;
wait until rising_edge(clk);
Sw(0) <= '0';
Sw(1) <= '1';
Sw(2) <= '0';
wait for 100 ns;
wait until rising_edge(clk);
Sw(0) <= '0';
Sw(1) <= '0';
Sw(2) <= '1';
wait for 100 ns;
wait until rising_edge(clk);
Enable <= '0';
wait for 100 ns;
wait until rising_edge(clk);
Rst <='0';
wait for 100 ns;
end process;
end architecture arc_tb_pwm;
As for the image - use printscreen key and paste it into paint.