-
Notifications
You must be signed in to change notification settings - Fork 0
/
character_address_unit.vhd
85 lines (64 loc) · 1.72 KB
/
character_address_unit.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.vga_util.all;
entity character_address_unit is
port (
clk, reset: in std_logic;
incr_frame: in boolean;
incr_char_y: in boolean;
incr_pixel_y: in boolean;
incr_char_x: in boolean;
offset: in std_logic_vector(15 downto 0);
load_offset: in std_logic;
addr: out std_logic_vector(15 downto 0) := X"0000"
);
end entity;
architecture rtl of character_address_unit is
-- sl = start line, sf = start frame
signal address, sl_address, sf_address:
std_logic_vector(15 downto 0) := X"0000";
begin
addr <= address;
address_ctrl: process (clk, reset, incr_frame, incr_char_y,
incr_pixel_y, incr_char_x,
address, sl_address, sf_address) is
begin
if rising_edge(clk) then
if reset = '1' then
address <= X"0000";
elsif incr_frame then
address <= sf_address;
elsif incr_char_y then
address <= std_logic_vector(unsigned(address) + 1);
elsif incr_pixel_y then
address <= sl_address;
elsif incr_char_x then
address <= std_logic_vector(unsigned(address) + 1);
end if;
end if;
end process;
sl_address_ctrl: process (clk, reset, sl_address, address, load_offset,
offset) is
begin
if rising_edge(clk) then
if reset = '1' then
sl_address <= X"0000";
elsif incr_frame then
sl_address <= sf_address;
elsif incr_char_y then
sl_address <= std_logic_vector(unsigned(address) + 1);
end if;
end if;
end process;
sf_address_ctrl: process (clk, reset, offset) is
begin
if rising_edge(clk) then
if reset = '1' then
sf_address <= X"0000";
elsif load_offset = '1' then
sf_address <= offset;
end if;
end if;
end process;
end architecture;