-
Notifications
You must be signed in to change notification settings - Fork 0
/
char_pos_counter_OLD.vhd
166 lines (135 loc) · 4.33 KB
/
char_pos_counter_OLD.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.vga_util.all;
-- rename to 'vga_text_frame_counter'
entity char_pos_counter is
generic (
videomode: vga_videomode;
CHAR_WIDTH: positive := 8;
CHAR_HEIGHT: positive := 8
);
port (
clk, en, reset: in std_logic;
hstate: in vga_hstate;
vstate: in vga_vstate;
pixel_local_x: out natural range 0 to CHAR_WIDTH - 1 := 0;
char_x: out natural range 0 to (videomode.width / CHAR_WIDTH) - 1 := 0;
pixel_local_y: out natural range 0 to CHAR_HEIGHT - 1 := 0;
char_y: out natural range 0 to (videomode.height / CHAR_HEIGHT) - 1 := 0
);
end entity;
architecture behavioural of char_pos_counter is
constant TXT_DISP_WIDTH: positive := videomode.width / CHAR_WIDTH;
constant TXT_DISP_HEIGHT: positive := videomode.height / CHAR_HEIGHT;
signal int_pixel_local_x: natural range 0 to CHAR_WIDTH - 1 := 0;
signal int_char_x: natural range 0 to TXT_DISP_WIDTH - 1 := 0;
signal int_pixel_local_y: natural range 0 to CHAR_HEIGHT - 1 := 0;
signal int_char_y: natural range 0 to TXT_DISP_HEIGHT - 1 := 0;
-- signal int_mem_addr: natural range 0 to MEM_BYTES - 1 := 0;
-- signal int_mem_bank: natural range 0 to MEM_BANKS - 1 := 0;
-- signal int_mem_addr_offset: natural range 0 to MEM_BYTES - 1 := 0;
-- signal int_mem_bank_offset: natural range 0 to MEM_BANKS - 1 := 0;
signal incr_pixel_local_x: boolean := false;
signal incr_char_x: boolean := false;
signal incr_pixel_local_y: boolean := false;
signal incr_char_y: boolean := false;
signal incr_frame: boolean := false;
begin
pixel_local_x <= int_pixel_local_x;
char_x <= int_char_x;
pixel_local_y <= int_pixel_local_y;
char_y <= int_char_y;
-- mem_addr <= int_mem_addr;
-- mem_bank <= int_mem_bank;
eval_incr_conds: process (int_pixel_local_x, int_char_x, int_pixel_local_y,
int_char_y, hstate, vstate) is
begin
if hstate = HActiveVideo and vstate = VActiveVideo then
-- Always increment pixel x while active video (trivial)
incr_pixel_local_x <= true;
incr_char_x <= int_pixel_local_x = CHAR_WIDTH - 1;
-- if int_pixel_local_x = CHAR_WIDTH - 1 then
-- incr_char_x <= true;
-- else
-- incr_char_x <= false;
-- end if;
incr_pixel_local_y <= incr_char_x and
int_char_x = TXT_DISP_WIDTH - 1;
-- if int_pixel_local_x = CHAR_WIDTH - 1 AND
-- int_char_x = TXT_DISP_WIDTH - 1 then
-- incr_pixel_local_y <= true;
-- else
-- incr_pixel_local_y <= false;
-- end if;
incr_char_y <= incr_pixel_local_y and
int_pixel_local_y = CHAR_HEIGHT - 1;
-- if int_pixel_local_x = CHAR_WIDTH - 1 AND
-- int_char_x = TXT_DISP_WIDTH - 1 AND
-- int_pixel_local_y = CHAR_HEIGHT - 1 then
-- incr_char_y <= true;
-- else
-- incr_char_y <= false;
-- end if;
incr_frame <= incr_char_y and
int_char_y = TXT_DISP_HEIGHT - 1;
-- if int_pixel_local_x = CHAR_WIDTH - 1 AND
-- int_char_x = TXT_DISP_WIDTH - 1 AND
-- int_pixel_local_y = CHAR_HEIGHT - 1 AND
-- int_char_y = TXT_DISP_HEIGHT - 1 then
-- incr_frame <= true;
-- else
-- incr_frame <= false;
-- end if;
else
incr_pixel_local_x <= false;
incr_char_x <= false;
incr_pixel_local_y <= false;
incr_char_y <= false;
incr_frame <= false;
end if;
end process;
count_position: process(clk, en, reset, int_pixel_local_x,
int_pixel_local_y, int_char_x, int_char_y,
hstate, vstate)
is
begin
if rising_edge(clk) then
if reset = '1' then
int_pixel_local_x <= 0;
int_char_x <= 0;
int_pixel_local_y <= 0;
int_char_y <= 0;
elsif en = '1' then
if incr_pixel_local_x then
if int_pixel_local_x = CHAR_WIDTH - 1 then
int_pixel_local_x <= 0;
else
int_pixel_local_x <= int_pixel_local_x + 1;
end if;
end if;
if incr_char_x then
if int_char_x = TXT_DISP_WIDTH - 1 then
int_char_x <= 0;
else
int_char_x <= int_char_x + 1;
end if;
end if;
if incr_pixel_local_y then
if int_pixel_local_y = CHAR_HEIGHT - 1 then
int_pixel_local_y <= 0;
else
int_pixel_local_y <= int_pixel_local_y + 1;
end if;
end if;
if incr_char_y then
if int_char_y = TXT_DISP_HEIGHT - 1 then
int_char_y <= 0;
else
int_char_y <= int_char_y + 1;
end if;
end if;
end if; -- en = '1'
end if; -- rising_edge(clk)
end process;
end architecture;