--
|
--
|
-- Programmable sync generator.
|
-- Programmable sync generator.
|
--
|
--
|
-- (c) Copyright Andras Tantos <andras_tantos@yahoo.com> 2001/03/31
|
-- (c) Copyright Andras Tantos <andras_tantos@yahoo.com> 2001/03/31
|
-- This code is distributed under the terms and conditions of the GNU General Public Lince.
|
-- This code is distributed under the terms and conditions of the GNU General Public Lince.
|
--
|
--
|
|
|
-- Standard library.
|
-- Standard library.
|
library IEEE;
|
library IEEE;
|
use IEEE.std_logic_1164.all;
|
use IEEE.std_logic_1164.all;
|
use IEEE.numeric_std.all;
|
use IEEE.numeric_std.all;
|
|
|
library work;
|
library work;
|
use work.technology.all;
|
use work.technology.all;
|
|
|
entity sync_gen is
|
entity sync_gen is
|
port (
|
port (
|
clk: in std_logic;
|
clk: in std_logic;
|
clk_en: in std_logic;
|
clk_en: in std_logic;
|
reset: in std_logic := '0';
|
reset: in std_logic := '0';
|
|
|
bs: in std_logic_vector(7 downto 0);
|
bs: in std_logic_vector(7 downto 0);
|
ss: in std_logic_vector(7 downto 0);
|
ss: in std_logic_vector(7 downto 0);
|
se: in std_logic_vector(7 downto 0);
|
se: in std_logic_vector(7 downto 0);
|
total: in std_logic_vector(7 downto 0);
|
total: in std_logic_vector(7 downto 0);
|
|
|
sync: out std_logic;
|
sync: out std_logic;
|
blank: out std_logic;
|
blank: out std_logic;
|
tc: out std_logic;
|
tc: out std_logic;
|
|
|
count: out std_logic_vector (7 downto 0)
|
count: out std_logic_vector (7 downto 0)
|
);
|
);
|
end sync_gen;
|
end sync_gen;
|
|
|
architecture sync_gen of sync_gen is
|
architecture sync_gen of sync_gen is
|
begin
|
begin
|
-- And the sequential machine generating the output signals.
|
-- And the sequential machine generating the output signals.
|
generator: process is
|
generator: process is
|
variable state: std_logic_vector(7 downto 0);
|
variable state: std_logic_vector(7 downto 0);
|
begin
|
begin
|
wait until clk'event and clk='1';
|
wait until clk'event and clk='1';
|
if (reset = '1') then
|
if (reset = '1') then
|
tc <= '0';
|
tc <= '0';
|
state := (others => '0');
|
state := (others => '0');
|
sync <= '0';
|
sync <= '0';
|
tc <= '0';
|
tc <= '0';
|
blank <= '1';
|
blank <= '1';
|
else
|
else
|
if (clk_en='1') then
|
if (clk_en='1') then
|
if (state = bs) then
|
if (state = bs) then
|
sync <= '0';
|
sync <= '0';
|
blank <= '1';
|
blank <= '1';
|
tc <= '0';
|
tc <= '0';
|
state := add_one(state);
|
state := add_one(state);
|
elsif (state = ss) then
|
elsif (state = ss) then
|
sync <= '1';
|
sync <= '1';
|
blank <= '1';
|
blank <= '1';
|
tc <= '1';
|
tc <= '1';
|
state := add_one(state);
|
state := add_one(state);
|
elsif (state = se) then
|
elsif (state = se) then
|
sync <= '0';
|
sync <= '0';
|
blank <= '1';
|
blank <= '1';
|
tc <= '0';
|
tc <= '0';
|
state := add_one(state);
|
state := add_one(state);
|
elsif (state = total) then
|
elsif (state = total) then
|
sync <= '0';
|
sync <= '0';
|
blank <= '0';
|
blank <= '0';
|
tc <= '0';
|
tc <= '0';
|
state := (others => '0');
|
state := (others => '0');
|
else
|
else
|
tc <= '0';
|
tc <= '0';
|
state := add_one(state);
|
state := add_one(state);
|
end if;
|
end if;
|
count <= state;
|
count <= state;
|
else
|
else
|
tc <= '0';
|
tc <= '0';
|
end if;
|
end if;
|
end if;
|
end if;
|
end process;
|
end process;
|
end sync_gen;
|
end sync_gen;
|
|
|