1 |
34 |
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_VECTOR(0 DOWNTO 0);
|
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_VECTOR(0 DOWNTO 0);
|
24 |
|
|
VGA_R,
|
25 |
|
|
VGA_G,
|
26 |
|
|
VGA_B : OUT STD_LOGIC;
|
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 |
|
|
constant vid_width : std_logic_vector := "001010000"; -- 80 columns
|
37 |
|
|
signal Clock_video : std_logic;
|
38 |
|
|
signal VGA_R_sig : std_logic;
|
39 |
|
|
signal VGA_G_sig : std_logic;
|
40 |
|
|
signal VGA_B_sig : std_logic;
|
41 |
|
|
signal pixel_row_sig : std_logic_vector(9 downto 0);
|
42 |
|
|
signal pixel_column_sig : std_logic_vector(9 downto 0);
|
43 |
|
|
signal pixel_row_sigFF : std_logic_vector(9 downto 0);
|
44 |
|
|
signal pixel_column_sigFF : std_logic_vector(9 downto 0);
|
45 |
|
|
signal pixel_clock_sig : std_logic;
|
46 |
|
|
signal char_addr_sig : std_logic_vector(7 downto 0);
|
47 |
|
|
signal font_row_sig : std_logic_vector(2 downto 0);
|
48 |
|
|
signal font_col_sig : std_logic_vector(2 downto 0);
|
49 |
|
|
signal pixel_sig : std_logic;
|
50 |
|
|
signal video_on_sig : std_logic;
|
51 |
|
|
|
52 |
|
|
constant sv1 : integer := 3 + pixelsxchar - 1;
|
53 |
|
|
constant sv2 : integer := 8 + pixelsxchar - 1;
|
54 |
|
|
constant cv1 : integer := 0 + pixelsxchar - 1;
|
55 |
|
|
constant cv2 : integer := 2 + pixelsxchar - 1;
|
56 |
|
|
signal fix : integer;
|
57 |
|
|
|
58 |
|
|
COMPONENT VGA_SYNC
|
59 |
|
|
PORT( clock_25Mhz : IN STD_LOGIC;
|
60 |
|
|
red, green, blue : IN STD_LOGIC;
|
61 |
|
|
red_out, green_out, blue_out : OUT STD_LOGIC;
|
62 |
|
|
horiz_sync_out, vert_sync_out,
|
63 |
|
|
video_on, pixel_clock : OUT STD_LOGIC;
|
64 |
|
|
pixel_row, pixel_column : OUT STD_LOGIC_VECTOR(9 DOWNTO 0));
|
65 |
|
|
END COMPONENT;
|
66 |
|
|
|
67 |
|
|
BEGIN
|
68 |
|
|
|
69 |
|
|
VGA_R_sig <= '0';
|
70 |
|
|
VGA_G_sig <= '0';
|
71 |
|
|
VGA_B_sig <= pixel_sig;
|
72 |
|
|
|
73 |
|
|
-- Fonts ROM read
|
74 |
|
|
-- Picks next letter for a 80 Columns x 30 Lines display
|
75 |
|
|
VRAM_WREN(0) <= '1';
|
76 |
|
|
VRAM_CLOCK <= pixel_clock_sig;
|
77 |
|
|
VRAM_ADDR <= pixel_row_sig(sv2 downto sv1) * conv_std_logic_vector(vid_cols,7) + pixel_column_sig(sv2 downto sv1);
|
78 |
|
|
|
79 |
|
|
-- Fonts RAM read
|
80 |
|
|
-- Takes the letter, calculates the position in the char memory to get the pixel pattern
|
81 |
|
|
-- Plot the pixel in the video
|
82 |
|
|
-- Using pixel_row(3 downto 1) has the effect of "shifting" (multiplying by 2)
|
83 |
|
|
-- This will plot 2 pixels on video for every pixel defined on char memory
|
84 |
|
|
CRAM_WEB(0) <= '1';
|
85 |
|
|
CRAM_ADDR <= VRAM_DATA & pixel_row_sig(cv2 downto cv1);
|
86 |
|
|
fix <= 1 when pixelsxchar = 2 else 2;
|
87 |
|
|
pixel_sig <= CRAM_DATA (CONV_INTEGER(NOT (pixel_column_sig(cv2 downto cv1) - fix))) when
|
88 |
|
|
( (pixel_row_sig < (pixelsxchar * 8 * vid_lines)) and (pixel_column_sig < (pixelsxchar * 8 * vid_cols)) ) else
|
89 |
|
|
'0';
|
90 |
|
|
|
91 |
|
|
vga_sync_inst : vga_sync
|
92 |
|
|
port map (
|
93 |
|
|
clock_25Mhz => CLOCK_25,
|
94 |
|
|
red => VGA_R_sig,
|
95 |
|
|
green => VGA_G_sig,
|
96 |
|
|
blue => VGA_B_sig,
|
97 |
|
|
red_out => VGA_R,
|
98 |
|
|
green_out => VGA_G,
|
99 |
|
|
blue_out => VGA_B,
|
100 |
|
|
horiz_sync_out => VGA_HS,
|
101 |
|
|
vert_sync_out => VGA_VS,
|
102 |
|
|
video_on => video_on_sig,
|
103 |
|
|
pixel_clock => pixel_clock_sig,
|
104 |
|
|
pixel_row => pixel_row_sig,
|
105 |
|
|
pixel_column => pixel_column_sig
|
106 |
|
|
);
|
107 |
|
|
|
108 |
|
|
END A;
|