-
Notifications
You must be signed in to change notification settings - Fork 0
/
zeichentablett.vhd
executable file
·329 lines (281 loc) · 7.89 KB
/
zeichentablett.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
library ieee;
use ieee.std_logic_1164.all;
use work.constants.all;
----------------------------------------------------------------------------------
-- ENTITY --
----------------------------------------------------------------------------------
entity zeichentablett is
port
(
sys_clk : in std_logic;
LTM_NCLK : out std_logic;
LTM_ADC_DCLK : out std_logic;
res_n : in std_logic;
b_color : in std_logic;
b_mode : in std_logic;
b_reset : in std_logic;
LTM_ADC_PENIRQ_n : in std_logic;
LTM_ADC_BUSY : in std_logic;
LTM_ADC_DOUT : in std_logic;
LTM_ADC_DIN : out std_logic;
LTM_GREST : out std_logic;
LTM_SCEN : out std_logic;
LTM_SDA : inout std_logic;
LTM_HD : out std_logic;
LTM_VD : out std_logic;
LTM_R : out std_logic_vector(7 downto 0);
LTM_G : out std_logic_vector(7 downto 0);
LTM_B : out std_logic_vector(7 downto 0);
LTM_DEN : out std_logic;
debug_lamp : out std_logic
);
end entity zeichentablett;
----------------------------------------------------------------------------------
-- ARCHITECTURE --
----------------------------------------------------------------------------------
architecture sim of zeichentablett is
signal vga_clk : std_logic := '0';
signal reset : std_logic := '0';
signal sync_data_color, sync_data_mode, sync_data_reset, input_logic_enable, vals_valid : std_logic := '0';
signal raddr1, waddr2 : std_logic_vector(RAM_DATA_WIDTH - 1 downto 0);
signal rdata1, wdata2 : std_logic_vector(( 3 * COLOR_BIT_WIDTH ) - 1 downto 0);
signal rd1, wr2 : std_logic;
signal xcoord, ycoord : std_logic_vector (7 downto 0) := "00000000";
component pll is
port
(
inclk0 : in STD_LOGIC := '0';
c0 : out STD_LOGIC;
c1 : out STD_LOGIC
);
end component pll;
component sync is
generic
(
-- number of stages in the input synchronizer
SYNC_STAGES : integer range 2 to integer'high;
-- reset value of the output signal
RESET_VALUE : std_logic
);
port
(
clk : in std_logic;
res_n : in std_logic;
data_in : in std_logic;
data_out : out std_logic
);
end component sync;
component input_logic is
generic
(
-- reset value of the output signal
RESET_VALUE : std_logic;
CLK_DIVISOR : integer;
DATA_WIDTH : integer
);
port
(
clk : in std_logic;
res_n : in std_logic;
busy : in std_logic;
dout : in std_logic;
input_logic_enable : in std_logic;
penirq : in std_logic;
cs : out std_logic;
din : out std_logic;
xcoord : out std_logic_vector (7 downto 0);
ycoord : out std_logic_vector (7 downto 0);
vals_valid : out std_logic
);
end component input_logic;
component vga_buffer is
generic
(
CLK_FREQ : integer;
-- reset value of the output signal
RESET_VALUE : std_logic;
H_PIXEL : integer;
V_PIXEL : integer;
RAM_DATA_WIDTH : integer;
COLOR_DATA_WIDTH : integer
);
port
(
clk : in std_logic;
res_n : in std_logic;
nclk : out std_logic;
raddr1 : out std_logic_vector( RAM_DATA_WIDTH - 1 downto 0);
rdata1 : in std_logic_vector( ( 3 * COLOR_DATA_WIDTH ) - 1 downto 0);
rd1 : out std_logic;
hsync : out std_logic;
vsync : out std_logic;
r : out std_logic_vector(7 downto 0);
g : out std_logic_vector(7 downto 0);
b : out std_logic_vector(7 downto 0);
den : out std_logic
);
end component vga_buffer;
component program_logic is
generic
(
CLK_FREQ : integer;
-- reset value of the output signal
RESET_VALUE : std_logic;
H_PIXEL : integer;
V_PIXEL : integer;
RAM_DATA_WIDTH : integer;
COLOR_DATA_WIDTH : integer
);
port
(
clk : in std_logic;
res_n : in std_logic;
b_color : in std_logic;
b_mode : in std_logic;
b_reset : in std_logic;
xcoord : in std_logic_vector (7 downto 0);
ycoord : in std_logic_vector (7 downto 0);
vals_valid : in std_logic;
debug_lamp : out std_logic;
waddr2 : out std_logic_vector( RAM_DATA_WIDTH - 1 downto 0);
wdata2 : out std_logic_vector( ( 3 * COLOR_DATA_WIDTH ) - 1 downto 0);
wr2 : out std_logic
);
end component program_logic;
component dp_ram_1c1r1w is
generic
(
ADDR_WIDTH : integer;
DATA_WIDTH : integer
);
port
(
clk : in std_logic;
raddr1 : in std_logic_vector(ADDR_WIDTH - 1 downto 0);
rdata1 : out std_logic_vector(DATA_WIDTH - 1 downto 0);
rd1 : in std_logic;
waddr2 : in std_logic_vector(ADDR_WIDTH - 1 downto 0);
wdata2 : in std_logic_vector(DATA_WIDTH - 1 downto 0);
wr2 : in std_logic
);
end component dp_ram_1c1r1w;
begin
pll_inst : pll
port map (
inclk0 => sys_clk,
c0 => vga_clk,
c1 => LTM_ADC_DCLK
);
sync_color_button : sync
generic map (
SYNC_STAGES => SYNC_STAGES,
RESET_VALUE => RESET_VALUE
)
port map (
clk => sys_clk,
res_n => res_n,
data_in => b_color,
data_out => sync_data_color
);
sync_mode_button : sync
generic map (
SYNC_STAGES => SYNC_STAGES,
RESET_VALUE => RESET_VALUE
)
port map (
clk => sys_clk,
res_n => res_n,
data_in => b_mode,
data_out => sync_data_mode
);
sync_reset_button : sync
generic map (
SYNC_STAGES => SYNC_STAGES,
RESET_VALUE => RESET_VALUE
)
port map (
clk => sys_clk,
res_n => res_n,
data_in => b_reset,
data_out => sync_data_reset
);
input_logic_inst : input_logic
generic map (
RESET_VALUE => RESET_VALUE,
CLK_DIVISOR => CLK_DIVISOR,
DATA_WIDTH => ADC_DATA_WIDTH
)
port map (
clk => sys_clk,
res_n => res_n,
busy => LTM_ADC_BUSY,
dout => LTM_ADC_DOUT,
input_logic_enable => input_logic_enable,
xcoord => xcoord,
ycoord => ycoord,
vals_valid => vals_valid,
din => LTM_ADC_DIN,
penirq => LTM_ADC_PENIRQ_n,
cs => LTM_SCEN
);
vga_output : vga_buffer
generic map (
CLK_FREQ => VGA_CLK_FREQ,
RESET_VALUE => RESET_VALUE,
H_PIXEL => HORIZONTAL_PIXEL,
V_PIXEL => VERTICAL_PIXEL,
RAM_DATA_WIDTH => RAM_DATA_WIDTH,
COLOR_DATA_WIDTH => COLOR_BIT_WIDTH
)
port map (
clk => vga_clk,
res_n => res_n,
nclk => LTM_NCLK,
raddr1 => raddr1,
rdata1 => rdata1,
rd1 => rd1,
hsync => LTM_HD,
vsync => LTM_VD,
r => LTM_R,
g => LTM_G,
b => LTM_B,
den => LTM_DEN
);
program_logic_inst : program_logic
generic map (
CLK_FREQ => SYS_CLK_FREQ,
RESET_VALUE => RESET_VALUE,
H_PIXEL => HORIZONTAL_PIXEL,
V_PIXEL => VERTICAL_PIXEL,
RAM_DATA_WIDTH => RAM_DATA_WIDTH,
COLOR_DATA_WIDTH => COLOR_BIT_WIDTH
)
port map (
clk => sys_clk,
res_n => res_n,
b_color => sync_data_color,
b_mode => sync_data_mode,
b_reset => sync_data_reset,
xcoord => xcoord,
ycoord => ycoord,
vals_valid => vals_valid,
debug_lamp => debug_lamp,
waddr2 => waddr2,
wdata2 => wdata2,
wr2 => wr2
);
ram_inst : dp_ram_1c1r1w
generic map (
ADDR_WIDTH => RAM_DATA_WIDTH,
DATA_WIDTH => ( 3 * COLOR_BIT_WIDTH )
)
port map (
clk => sys_clk,
raddr1 => raddr1,
rdata1 => rdata1,
rd1 => rd1,
waddr2 => waddr2,
wdata2 => wdata2,
wr2 => wr2
);
end architecture sim;