Divisore di frequenza VHDL
Sono alle prese con il seguente esercizio e sono arrivato ad impostare questo codice che però mi da degli errori in fase di visualizzazione con MODELSIM :
testbench relativo:
- Codice: Seleziona tutto
entity freq_variabile is
port(clk, reset, enable : in std_logic;
out_vf : out std_logic);
end freq_variabile;
architecture Behavioral of freq_variabile is
signal counter : integer:=0;
signal out_vf2 : std_logic;
begin
process(clk,reset,enable)
begin
if reset='1' then
out_vf2<='0';
counter <= 0;
elsif rising_edge(clk) then
if enable='1' then
if counter=0 then
out_vf2 <= clk;
counter<=counter+1;
end if;
if counter=1 then
out_vf2<='1';
counter<=counter+1;
end if;
if counter=2 then
out_vf2<='0';
counter<=counter+1;
end if;
if counter=3 then
out_vf2<= '1';
counter<=counter+1;
end if;
if counter=4 then
out_vf2<= '1';
counter<=counter+1;
end if;
if counter=5 then
out_vf2<= '0';
counter<=counter+1;
end if;
if counter=6 then
out_vf2<='0';
counter<=counter+1;
if counter=7 then
out_vf2<= '1';
counter<=counter+1;
end if;
if counter=8 then
out_vf2<= '0';
counter<=0;
end if;
elsif enable='0' then --enable disattivo
out_vf2<='X';
counter<=0;
end if;
end if;
end if;
end process;
out_vf<=out_vf2;
end Behavioral;
testbench relativo: