1 |
2 |
slavek |
----------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- Horizontal 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 |
|
|
library IEEE;
|
34 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
35 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
36 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
37 |
|
|
|
38 |
|
|
library UNISIM;
|
39 |
|
|
use UNISIM.VComponents.all;
|
40 |
|
|
|
41 |
|
|
entity hsync_gen is
|
42 |
|
|
Generic (
|
43 |
|
|
C_HCNT_SIZE : natural := 11;
|
44 |
|
|
C_BACK_PORCH : natural := 40+8;
|
45 |
|
|
C_FRONT_PORCH : natural := 8+8;
|
46 |
|
|
C_VIDEO_ACTIVE : natural := 640;
|
47 |
|
|
C_HSYNC_PULSE : natural := 96);
|
48 |
|
|
Port (
|
49 |
|
|
CLK : in std_logic;
|
50 |
|
|
RST : in std_logic;
|
51 |
|
|
|
52 |
|
|
HSYNC_VALUE : out std_logic_vector(C_HCNT_SIZE - 1 downto 0);
|
53 |
|
|
HSYNC_EN : in std_logic;
|
54 |
|
|
LINE_E : out std_logic;
|
55 |
|
|
DE : out std_logic;
|
56 |
|
|
HSYNC : out std_logic);
|
57 |
|
|
end hsync_gen;
|
58 |
|
|
|
59 |
|
|
architecture Behavioral of hsync_gen is
|
60 |
|
|
|
61 |
|
|
constant c_scan_line : std_logic_vector(C_HCNT_SIZE - 1 downto 0) :=
|
62 |
|
|
CONV_STD_LOGIC_VECTOR(C_BACK_PORCH + C_FRONT_PORCH +
|
63 |
|
|
C_VIDEO_ACTIVE + C_HSYNC_PULSE, C_HCNT_SIZE);
|
64 |
|
|
|
65 |
|
|
signal pixel_cnt : std_logic_vector(C_HCNT_SIZE - 1 downto 0);
|
66 |
|
|
signal hsync_i : std_logic;
|
67 |
|
|
signal de_i : std_logic;
|
68 |
|
|
signal line_rst : std_logic;
|
69 |
|
|
signal rst_i : std_logic;
|
70 |
|
|
|
71 |
|
|
begin
|
72 |
|
|
|
73 |
|
|
rst_i <= line_rst Or (Not HSYNC_EN);
|
74 |
|
|
|
75 |
|
|
hsync_cnt : PROCESS(CLK, rst_i, pixel_cnt)
|
76 |
|
|
BEGIN
|
77 |
|
|
If RST = '1' Then
|
78 |
|
|
pixel_cnt <= (Others => '0');
|
79 |
|
|
ElsIf CLK'event And CLK = '1' Then
|
80 |
|
|
If rst_i = '1' Then
|
81 |
|
|
pixel_cnt <= (Others => '0');
|
82 |
|
|
Else
|
83 |
|
|
pixel_cnt <= pixel_cnt + 1;
|
84 |
|
|
End If;
|
85 |
|
|
End If;
|
86 |
|
|
END PROCESS;
|
87 |
|
|
|
88 |
|
|
line_rst <= '0' When pixel_cnt < c_scan_line - 1 Else '1' after 1 ns;
|
89 |
|
|
hsync_i <= '1' When (pixel_cnt >= 0) And (pixel_cnt < C_HSYNC_PULSE) Else '0';
|
90 |
|
|
de_i <= '1' When (pixel_cnt >= C_HSYNC_PULSE + C_BACK_PORCH) And (pixel_cnt <
|
91 |
|
|
C_HSYNC_PULSE + C_BACK_PORCH + C_VIDEO_ACTIVE) Else '0';
|
92 |
|
|
|
93 |
|
|
HSYNC <= hsync_i;
|
94 |
|
|
DE <= de_i;
|
95 |
|
|
LINE_E <= line_rst;
|
96 |
|
|
HSYNC_VALUE <= pixel_cnt;
|
97 |
|
|
|
98 |
|
|
end Behavioral;
|
99 |
|
|
|