1 |
2 |
slavek |
----------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- Vertical sync generator ----
|
4 |
|
|
---- ----
|
5 |
|
|
---- Author(s): ----
|
6 |
|
|
---- - Slavek Valach, s.valach@dspfpga.com ----
|
7 |
|
|
---- ----
|
8 |
|
|
----------------------------------------------------------------------
|
9 |
|
|
---- ----
|
10 |
|
|
---- Copyright (C) 2008 Authors and OPENCORES.ORG ----
|
11 |
|
|
---- ----
|
12 |
|
|
---- This source file may be used and distributed without ----
|
13 |
|
|
---- restriction provided that this copyright statement is not ----
|
14 |
|
|
---- removed from the file and that any derivative work contains ----
|
15 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
16 |
|
|
---- ----
|
17 |
|
|
---- This source file is free software; you can redistribute it ----
|
18 |
|
|
---- and/or modify it under the terms of the GNU General ----
|
19 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
20 |
|
|
---- either version 2.0 of the License, or (at your option) any ----
|
21 |
|
|
---- later version. ----
|
22 |
|
|
---- ----
|
23 |
|
|
---- This source is distributed in the hope that it will be ----
|
24 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
25 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
26 |
|
|
---- PURPOSE. See the GNU General Public License for more details.----
|
27 |
|
|
---- ----
|
28 |
|
|
---- You should have received a copy of the GNU General ----
|
29 |
|
|
---- Public License along with this source; if not, download it ----
|
30 |
|
|
---- from http://www.gnu.org/licenses/gpl.txt ----
|
31 |
|
|
---- ----
|
32 |
|
|
----------------------------------------------------------------------
|
33 |
|
|
|
34 |
|
|
library IEEE;
|
35 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
36 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
37 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
38 |
|
|
|
39 |
|
|
---- Uncomment the following library declaration if instantiating
|
40 |
|
|
---- any Xilinx primitives in this code.
|
41 |
|
|
--library UNISIM;
|
42 |
|
|
--use UNISIM.VComponents.all;
|
43 |
|
|
|
44 |
|
|
entity vsync_gen is
|
45 |
|
|
Generic(
|
46 |
|
|
C_VCNT_SIZE : natural := 11;
|
47 |
|
|
C_BACK_PORCH : natural := 25+8;
|
48 |
|
|
C_FRONT_PORCH : natural := 2+8;
|
49 |
|
|
C_VIDEO_ACTIVE : natural := 480;
|
50 |
|
|
C_VSYNC_PULSE : natural := 2);
|
51 |
|
|
Port(
|
52 |
|
|
CLK : in std_logic;
|
53 |
|
|
RST : in std_logic;
|
54 |
|
|
VSYNC_VALUE : out std_logic_vector(C_VCNT_SIZE - 1 downto 0);
|
55 |
|
|
LCD_EN : in std_logic;
|
56 |
|
|
LINE_E : in std_logic;
|
57 |
|
|
FRAME_E : out std_logic;
|
58 |
|
|
LAST_LINE : out std_logic;
|
59 |
|
|
V_DE : out std_logic;
|
60 |
|
|
VSYNC : out std_logic);
|
61 |
|
|
end vsync_gen;
|
62 |
|
|
|
63 |
|
|
architecture Behavioral of vsync_gen is
|
64 |
|
|
|
65 |
|
|
constant c_frame : std_logic_vector(C_VCNT_SIZE - 1 downto 0) :=
|
66 |
|
|
CONV_STD_LOGIC_VECTOR(C_BACK_PORCH + C_FRONT_PORCH
|
67 |
|
|
+ C_VIDEO_ACTIVE + C_VSYNC_PULSE, C_VCNT_SIZE);
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
signal line_cnt : std_logic_vector(C_VCNT_SIZE - 1 downto 0);
|
71 |
|
|
signal vsync_i : std_logic;
|
72 |
|
|
signal de_i : std_logic;
|
73 |
|
|
signal frame_rst : std_logic;
|
74 |
|
|
signal rst_i : std_logic;
|
75 |
|
|
signal last_line_i : std_logic;
|
76 |
|
|
|
77 |
|
|
begin
|
78 |
|
|
|
79 |
|
|
rst_i <= frame_rst Or Not LCD_EN;
|
80 |
|
|
|
81 |
|
|
PROCESS(CLK, rst_i, line_cnt, LINE_E)
|
82 |
|
|
BEGIN
|
83 |
|
|
If RST = '1' Then
|
84 |
|
|
line_cnt <= (Others => '0');
|
85 |
|
|
ElsIf CLK'event And CLK = '1' Then
|
86 |
|
|
If rst_i = '1' Then
|
87 |
|
|
line_cnt <= (Others => '0');
|
88 |
|
|
ElsIf LINE_E = '1' Then
|
89 |
|
|
line_cnt <= line_cnt + '1';
|
90 |
|
|
End If;
|
91 |
|
|
End If;
|
92 |
|
|
END PROCESS;
|
93 |
|
|
|
94 |
|
|
last_line_i <= '0' When line_cnt < c_frame - 1 Else '1' after 1 ns;
|
95 |
|
|
vsync_i <= '1' When (line_cnt >= 0) And (line_cnt < C_VSYNC_PULSE) Else '0';
|
96 |
|
|
de_i <= '1' When (line_cnt >= C_VSYNC_PULSE + C_BACK_PORCH) And (line_cnt <
|
97 |
|
|
C_VSYNC_PULSE + C_BACK_PORCH + C_VIDEO_ACTIVE) Else '0';
|
98 |
|
|
|
99 |
|
|
frame_rst <= last_line_i And LINE_E;
|
100 |
|
|
|
101 |
|
|
VSYNC <= vsync_i;
|
102 |
|
|
V_DE <= de_i;
|
103 |
|
|
FRAME_E <= frame_rst;
|
104 |
|
|
VSYNC_VALUE <= line_cnt;
|
105 |
|
|
LAST_LINE <= last_line_i;
|
106 |
|
|
|
107 |
|
|
end Behavioral;
|
108 |
|
|
|