1 | library IEEE;
|
2 | use IEEE.std_logic_1164.all;
|
3 |
|
4 | entity vga_core is
|
5 | port
|
6 | (
|
7 | clk_50: in std_logic;
|
8 | red: out std_logic_vector(3 downto 0);
|
9 | green: out std_logic_vector(3 downto 0);
|
10 | blue: out std_logic_vector(3 downto 0);
|
11 | hsync: out std_logic;
|
12 | vsync: out std_logic
|
13 | );
|
14 | end vga_core;
|
15 |
|
16 | architecture vga_core_arch of vga_core is
|
17 |
|
18 | signal clk: std_logic;
|
19 | signal lineCounter: integer:=0;
|
20 | signal pixelCounter: integer:=0;
|
21 | signal bitmap_lineCounter: integer:=0;
|
22 | signal bitmap_pixelCounter: integer:=0;
|
23 | signal ascii_a0: std_logic_vector(6 downto 0):= "0011100";
|
24 | signal ascii_a1: std_logic_vector(6 downto 0):= "1100011";
|
25 | signal ascii_a2: std_logic_vector(6 downto 0):= "1111111";
|
26 | signal ascii_a3: std_logic_vector(6 downto 0):= "1000001";
|
27 | signal ascii_a4: std_logic_vector(6 downto 0):= "1000001";
|
28 |
|
29 |
|
30 | begin
|
31 | vga_clk: process(clk_50)
|
32 | begin
|
33 | if rising_edge(clk_50) then
|
34 | clk <= NOT clk;
|
35 | end if;
|
36 | end process vga_clk;
|
37 | ------------------------------------------------
|
38 | vga_testpic: process(clk)
|
39 | begin
|
40 | if clk = '1' then
|
41 |
|
42 | pixelCounter <= pixelCounter + 1;
|
43 | bitmap_pixelCounter <= bitmap_pixelCounter + 1;
|
44 |
|
45 | if pixelCounter = 800 then
|
46 | pixelCounter <= 0;
|
47 | bitmap_pixelCounter <= 0;
|
48 | lineCounter <= lineCounter + 1;
|
49 | bitmap_lineCounter <= bitmap_lineCounter + 1;
|
50 | end if;
|
51 |
|
52 | if lineCounter = 524 then
|
53 | lineCounter <= 0;
|
54 | bitmap_lineCounter <= 0;
|
55 | end if;
|
56 | ------------------------------------------------
|
57 | if pixelCounter > 0 AND pixelCounter < 96 then
|
58 | hsync <= '0';
|
59 | else
|
60 | hsync <= '1';
|
61 | end if;
|
62 |
|
63 | if lineCounter > 0 AND lineCounter < 2 then
|
64 | vsync <= '0';
|
65 | else
|
66 | vsync <= '1';
|
67 | end if;
|
68 | -------------------------------------------------
|
69 | if pixelCounter > 112 AND pixelCounter < 752 AND lineCounter > 13 AND lineCounter < 493 then
|
70 | red <= "0000";
|
71 | green <= "0000";
|
72 | blue <= "0000";
|
73 |
|
74 | if bitmap_lineCounter < 6 then
|
75 | if bitmap_pixelCounter < 8 then
|
76 | if bitmap_lineCounter = 0 then
|
77 | if ascii_a0(bitmap_pixelCounter) = '1' then
|
78 | green <= "1111";
|
79 | else
|
80 | green <= "0000";
|
81 | end if;
|
82 | end if;
|
83 | if bitmap_lineCounter = 1 then
|
84 | if ascii_a1(bitmap_pixelCounter) = '1' then
|
85 | green <= "1111";
|
86 | else
|
87 | green <= "0000";
|
88 | end if;
|
89 | end if;
|
90 | if bitmap_lineCounter = 2 then
|
91 | if ascii_a2(bitmap_pixelCounter) = '1' then
|
92 | green <= "1111";
|
93 | else
|
94 | green <= "0000";
|
95 | end if;
|
96 | end if;
|
97 | if bitmap_lineCounter = 3 then
|
98 | if ascii_a3(bitmap_pixelCounter) = '1' then
|
99 | green <= "1111";
|
100 | else
|
101 | green <= "0000";
|
102 | end if;
|
103 | end if;
|
104 | if bitmap_lineCounter = 4 then
|
105 | if ascii_a4(bitmap_pixelCounter) = '1' then
|
106 | green <= "1111";
|
107 | else
|
108 | green <= "0000";
|
109 | end if;
|
110 | end if;
|
111 | end if;
|
112 | else
|
113 | green <= "0000";
|
114 | end if;
|
115 | else
|
116 | red <= "0000";
|
117 | green <= "0000";
|
118 | blue <= "0000";
|
119 | end if;
|
120 | end if;
|
121 | end process vga_testpic;
|
122 | end architecture vga_core_arch;
|