Gast
#882143
Hier mal ein einfacher Frequenzteiler.
Ich habe irgendwo etwas geändert und jetzt fehlt mir das clock-Signal
und dadurch geht nichts mehr.
Seh den Wald vor lauter Bäumen nicht mehr.
Zusatz: Enable wird nicht benutzt !
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity frequenzteiler is
generic (teiler : integer := 5);
port (clock : in std_logic;
reset : in std_logic;
enable : in std_logic;
cout : out std_logic
);
end frequenzteiler;
architecture frequenzteiler_rtl of frequenzteiler is
signal positive_counter : natural range 0 to (teiler-1);
signal negative_counter : natural range 0 to (teiler-1);
signal hilf1 : bit;
signal hilf2 : bit;
begin
-- Zählt die positiven Taktflanken
process (clock, reset)
begin
if (reset = '1') then
positive_counter <= 0;
elsif (rising_edge(clock)) then
if positive_counter < (teiler-1)
then positive_counter <= positive_counter + 1;
else positive_counter <= 0;
end if;
end if;
end process;
-- Zählt die negativen Taktflanken
process (clock, reset)
begin
if (reset = '1') then
negative_counter <= 0;
elsif (falling_edge(clock)) then
if negative_counter < (teiler-1)
then negative_counter <= negative_counter + 1;
else negative_counter <= 0;
end if;
end if;
end process;
-- Generisches ungerades Teilerverhältnis
hilf1 <= '1' when negative_counter < ((teiler-1)/2) else '0';
hilf2 <= '1' when positive_counter < ((teiler-1)/2) else '0';
cout <= '1' when (hilf1 = '1' or hilf2 = '1') else '0';
end frequenzteiler_rtl;
Eine simple Testbench zur Erzeugung des clock-Signals :
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;
ENTITY TestBench_vhd IS
END TestBench_vhd;
ARCHITECTURE behavior OF TestBench_vhd IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT frequenzteiler
PORT(
clock : IN std_logic;
reset : IN std_logic;
enable : IN std_logic;
cout : OUT std_logic
);
END COMPONENT;
--Inputs
SIGNAL clock : std_logic := '0';
SIGNAL reset : std_logic := '0';
SIGNAL enable : std_logic := '0';
--Outputs
SIGNAL cout : std_logic;
constant clock_period: time := 20 ns;
signal stop_the_clock: boolean := false;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: frequenzteiler PORT MAP(
clock => clock,
reset => reset,
enable => enable,
cout => cout
);
stimulus:process
begin
reset <= '1';
wait for 10 ns;
reset <= '0';
wait;
end process;
clocking : process
begin
while not stop_the_clock loop
clock <= '1';
wait for clock_period / 2;
clock <= '0';
wait for clock_period / 2;
end loop;
end process;
END;