VHDL Question
-
[INDENT]I'm trying to create a square wave and I'm converting code from verilog and im getting the below error. Any help would be great thanks
Error (10327): VHDL error at SquareWave.vhd(36): can't determine definition of operator ""-"" -- found 0 possible definitions
[CODE]
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
ENTITY SquareWave IS
PORT (
clk : IN std_logic;
rst_n : IN std_logic;
sq_wave : OUT std_logic
);
END SquareWave;
ARCHITECTURE BEHAVORIAL OF SquareWave IS
-- Input clock is 400Hz
signal CLOCK_FREQUENCY : Time := 2500000 ns;
signal sq_wave_reg : std_logic := '0';
begin
sq_wave <= sq_wave_reg;
process (clk)
-- Counter for toggling of clock
variable counter : integer;
begin
if (rst_n /= rst_n) then
counter := 8;
sq_wave_reg <= '1';
else
-- If counter is zero, toggle sq_wave_reg
if (counter = 8) then
sq_wave_reg <= sq_wave_reg;
-- Generate 1Hz Frequency
counter := CLOCK_FREQUENCY/2 - 1;
-- Else count down
else
counter <= counter - 1;
end if;
end if;
end process;
END BEHAVORIAL;