1 |
46 |
rrred |
-- Z80SoC for Spartan 3E
|
2 |
|
|
-- Ronivon Candido Costa
|
3 |
|
|
--
|
4 |
|
|
-- 2010 - 02 - 17 Update
|
5 |
|
|
-- Changed the entity to include signals for the char memory
|
6 |
|
|
-- The char memory is a dual port ram memory, and now
|
7 |
|
|
-- the char paterns can be modified by software.
|
8 |
|
|
--
|
9 |
|
|
--
|
10 |
|
|
library IEEE;
|
11 |
|
|
use IEEE.STD_LOGIC_1164.all;
|
12 |
|
|
use IEEE.STD_LOGIC_ARITH.all;
|
13 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.all;
|
14 |
|
|
|
15 |
|
|
ENTITY video is
|
16 |
|
|
PORT( CLOCK_25 : IN STD_LOGIC;
|
17 |
|
|
VRAM_DATA : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
|
18 |
|
|
VRAM_ADDR : OUT STD_LOGIC_VECTOR(12 DOWNTO 0);
|
19 |
|
|
VRAM_CLOCK : OUT STD_LOGIC;
|
20 |
|
|
VRAM_WREN : OUT STD_LOGIC;
|
21 |
|
|
CRAM_DATA : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
|
22 |
|
|
CRAM_ADDR : OUT STD_LOGIC_VECTOR(10 DOWNTO 0);
|
23 |
|
|
CRAM_WEB : OUT STD_LOGIC;
|
24 |
|
|
VGA_R,
|
25 |
|
|
VGA_G,
|
26 |
|
|
VGA_B : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
|
27 |
|
|
VGA_HS,
|
28 |
|
|
VGA_VS : OUT STD_LOGIC);
|
29 |
|
|
END video;
|
30 |
|
|
|
31 |
|
|
ARCHITECTURE A OF video IS
|
32 |
|
|
|
33 |
|
|
use work.z80soc_pack.all;
|
34 |
|
|
|
35 |
|
|
-- Added for VDU support
|
36 |
|
|
signal Clock_video : std_logic;
|
37 |
|
|
signal VGA_R_sig : std_logic_vector(3 downto 0);
|
38 |
|
|
signal VGA_G_sig : std_logic_vector(3 downto 0);
|
39 |
|
|
signal VGA_B_sig : std_logic_vector(3 downto 0);
|
40 |
|
|
signal pixel_row_sig : std_logic_vector(9 downto 0);
|
41 |
|
|
signal pixel_column_sig : std_logic_vector(9 downto 0);
|
42 |
|
|
signal pixel_clock_sig : std_logic;
|
43 |
|
|
signal char_addr_sig : std_logic_vector(7 downto 0);
|
44 |
|
|
signal font_row_sig : std_logic_vector(2 downto 0);
|
45 |
|
|
signal font_col_sig : std_logic_vector(2 downto 0);
|
46 |
|
|
signal pixel_sig : std_logic;
|
47 |
|
|
signal video_on_sig : std_logic;
|
48 |
|
|
|
49 |
|
|
COMPONENT VGA_SYNC
|
50 |
|
|
PORT( clock_25Mhz : IN STD_LOGIC;
|
51 |
|
|
red, green, blue : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
|
52 |
|
|
red_out, green_out, blue_out : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
|
53 |
|
|
horiz_sync_out, vert_sync_out,
|
54 |
|
|
video_on, pixel_clock : OUT STD_LOGIC;
|
55 |
|
|
pixel_row, pixel_column : OUT STD_LOGIC_VECTOR(9 DOWNTO 0));
|
56 |
|
|
END COMPONENT;
|
57 |
|
|
|
58 |
|
|
BEGIN
|
59 |
|
|
|
60 |
|
|
VGA_R_sig <= "0000";
|
61 |
|
|
VGA_G_sig <= "0000";
|
62 |
|
|
VGA_B_sig <= pixel_sig & pixel_sig & pixel_sig & pixel_sig when
|
63 |
|
|
( (pixel_row_sig < (8 * vid_lines)) and (pixel_column_sig < (8 * vid_cols)) ) else
|
64 |
|
|
"0000";
|
65 |
|
|
|
66 |
|
|
-- Fonts ROM read
|
67 |
|
|
-- Picks next letter for a 80 Columns x 30 Lines display
|
68 |
|
|
VRAM_WREN <= '1';
|
69 |
|
|
VRAM_CLOCK <= pixel_clock_sig;
|
70 |
|
|
VRAM_ADDR <= pixel_row_sig(8 downto 3) * conv_std_logic_vector(vid_cols,7) + pixel_column_sig(8 downto 3);
|
71 |
|
|
|
72 |
|
|
-- Fonts RAM read
|
73 |
|
|
-- Takes the letter, calculates the position in the char memory to get the pixel pattern
|
74 |
|
|
-- Plot the pixel in the video
|
75 |
|
|
-- Using pixel_row(3 downto 1) has the effect of "shifting" (multiplying by 2)
|
76 |
|
|
-- This will plot 2 pixels on video for every pixel defined on char memory
|
77 |
|
|
CRAM_WEB <= '1';
|
78 |
|
|
CRAM_ADDR <= VRAM_DATA & pixel_row_sig(2 downto 0);
|
79 |
|
|
pixel_sig <= CRAM_DATA (CONV_INTEGER(NOT (pixel_column_sig(2 downto 0) - 1)));
|
80 |
|
|
|
81 |
|
|
vga_sync_inst: VGA_SYNC
|
82 |
|
|
port map (
|
83 |
|
|
clock_25Mhz => CLOCK_25,
|
84 |
|
|
red => VGA_R_sig,
|
85 |
|
|
green => VGA_G_sig,
|
86 |
|
|
blue => VGA_B_sig,
|
87 |
|
|
red_out => VGA_R,
|
88 |
|
|
green_out => VGA_G,
|
89 |
|
|
blue_out => VGA_B,
|
90 |
|
|
horiz_sync_out => VGA_HS,
|
91 |
|
|
vert_sync_out => VGA_VS,
|
92 |
|
|
video_on => video_on_sig,
|
93 |
|
|
pixel_clock => pixel_clock_sig,
|
94 |
|
|
pixel_row => pixel_row_sig,
|
95 |
|
|
pixel_column => pixel_column_sig
|
96 |
|
|
);
|
97 |
|
|
|
98 |
|
|
END A;
|