1 |
5 |
smpickett |
//==================================================================//
|
2 |
|
|
// File: d_TopLevel.v //
|
3 |
11 |
smpickett |
// Version: 0.0.0.3 //
|
4 |
5 |
smpickett |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//
|
5 |
|
|
// Copyright (C) Stephen Pickett //
|
6 |
|
|
// Jun 08, 2005 //
|
7 |
|
|
// //
|
8 |
|
|
// This program is free software; you can redistribute it and/or //
|
9 |
|
|
// modify it under the terms of the GNU General Public License //
|
10 |
|
|
// as published by the Free Software Foundation; either version 2 //
|
11 |
|
|
// of the License, or (at your option) any later version. //
|
12 |
|
|
// //
|
13 |
|
|
// This program is distributed in the hope that it will be useful, //
|
14 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
15 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
16 |
|
|
// GNU General Public License for more details. //
|
17 |
|
|
// //
|
18 |
|
|
// If you have not received a copy of the GNU General Public License//
|
19 |
|
|
// along with this program; write to: //
|
20 |
|
|
// Free Software Foundation, Inc., //
|
21 |
|
|
// 51 Franklin Street, Fifth Floor, //
|
22 |
|
|
// Boston, MA 02110-1301, USA. //
|
23 |
|
|
// //
|
24 |
|
|
//------------------------------------------------------------------//
|
25 |
|
|
// Revisions: //
|
26 |
|
|
// Ver 0.0.0.1 Apr , 2005 Under Development //
|
27 |
|
|
// Ver 0.0.0.2 Jun 08, 2005 Updates //
|
28 |
11 |
smpickett |
// Ver 0.0.0.3 Jun 19, 2005 Added Character Display //
|
29 |
5 |
smpickett |
// //
|
30 |
|
|
//==================================================================//
|
31 |
2 |
smpickett |
|
32 |
|
|
module TopLevel(
|
33 |
|
|
CLK_50MHZ_IN, MASTER_RST,
|
34 |
|
|
H_SYNC, V_SYNC, VGA_OUTPUT,
|
35 |
|
|
PS2C, PS2D,
|
36 |
|
|
// TIME_BASE,
|
37 |
|
|
ADC_DATA, ADC_CLK,
|
38 |
|
|
VGA_RAM_ADDR, VGA_RAM_DATA,
|
39 |
|
|
VGA_RAM_OE, VGA_RAM_WE, VGA_RAM_CS,
|
40 |
|
|
|
41 |
|
|
SEG_OUT, SEG_SEL, leds, SHOW_LEVELS_BUTTON
|
42 |
|
|
);
|
43 |
|
|
|
44 |
|
|
//==================================================================//
|
45 |
|
|
// DEFINITIONS //
|
46 |
|
|
//==================================================================//
|
47 |
|
|
|
48 |
|
|
//==================================================================//
|
49 |
|
|
// VARIABLE DEFINITIONS //
|
50 |
|
|
//==================================================================//
|
51 |
|
|
|
52 |
|
|
//----------------------//
|
53 |
|
|
// INPUTS / OUTPUTS //
|
54 |
|
|
//----------------------//
|
55 |
|
|
input CLK_50MHZ_IN, MASTER_RST;
|
56 |
|
|
output H_SYNC, V_SYNC;
|
57 |
|
|
output[2:0] VGA_OUTPUT;
|
58 |
|
|
//input[5:0] TIME_BASE;
|
59 |
|
|
inout PS2C, PS2D;
|
60 |
|
|
input[7:0] ADC_DATA;
|
61 |
|
|
output ADC_CLK;
|
62 |
|
|
output[17:0] VGA_RAM_ADDR;
|
63 |
|
|
inout[15:0] VGA_RAM_DATA;
|
64 |
|
|
output VGA_RAM_OE, VGA_RAM_WE, VGA_RAM_CS;
|
65 |
|
|
|
66 |
|
|
output[7:0] leds;
|
67 |
|
|
output[6:0] SEG_OUT;
|
68 |
|
|
output[3:0] SEG_SEL;
|
69 |
|
|
input SHOW_LEVELS_BUTTON;
|
70 |
|
|
wire SHOW_LEVELS_BUTTON;
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
//----------------------//
|
74 |
|
|
// WIRES / NODES //
|
75 |
|
|
//----------------------//
|
76 |
|
|
wire CLK_50MHZ_IN, MASTER_RST;
|
77 |
|
|
wire H_SYNC, V_SYNC;
|
78 |
|
|
wire[2:0] VGA_OUTPUT;
|
79 |
|
|
wire[5:0] TIME_BASE;
|
80 |
|
|
wire PS2C, PS2D;
|
81 |
|
|
wire[7:0] ADC_DATA;
|
82 |
|
|
wire ADC_CLK;
|
83 |
|
|
wire[17:0] VGA_RAM_ADDR;
|
84 |
|
|
wire[15:0] VGA_RAM_DATA;
|
85 |
|
|
wire VGA_RAM_OE, VGA_RAM_WE, VGA_RAM_CS;
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
//----------------------//
|
89 |
|
|
// VARIABLES //
|
90 |
|
|
//----------------------//
|
91 |
|
|
assign TIME_BASE = 6'b0;
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
//==================================================================//
|
95 |
|
|
// TEMP //
|
96 |
|
|
//==================================================================//
|
97 |
|
|
wire[17:0] VGA_RAM_ADDRESS_w;
|
98 |
|
|
wire[15:0] VGA_RAM_DATA_w;
|
99 |
5 |
smpickett |
wire L_BUTTON, R_BUTTON, M_BUTTON;
|
100 |
2 |
smpickett |
|
101 |
|
|
wire VGA_RAM_ACCESS_OK;
|
102 |
|
|
wire CLK_50MHZ, CLK_64MHZ, CLK180_64MHZ;
|
103 |
11 |
smpickett |
reg CLK_VGA;
|
104 |
2 |
smpickett |
wire[6:0] SEG_OUT;
|
105 |
|
|
wire[3:0] SEG_SEL;
|
106 |
|
|
|
107 |
11 |
smpickett |
wire[7:0] data_charRamRead;
|
108 |
|
|
reg[7:0] data_charRamRead_buf;
|
109 |
|
|
wire[7:0] mask_charMap;
|
110 |
|
|
reg[7:0] mask_charMap_buf;
|
111 |
|
|
|
112 |
|
|
always @ (posedge CLK_50MHZ) begin
|
113 |
|
|
if(R_BUTTON) begin
|
114 |
|
|
data_charRamRead_buf <= data_charRamRead_buf;
|
115 |
|
|
mask_charMap_buf <= mask_charMap_buf;
|
116 |
|
|
end else begin
|
117 |
|
|
data_charRamRead_buf <= data_charRamRead;
|
118 |
|
|
mask_charMap_buf <= mask_charMap;
|
119 |
|
|
end
|
120 |
|
|
end
|
121 |
|
|
|
122 |
2 |
smpickett |
sub_SegDriver segs(
|
123 |
|
|
.CLK_50MHZ(CLK_50MHZ), .MASTER_RST(MASTER_RST),
|
124 |
11 |
smpickett |
.DATA_IN(data_charRamRead_buf),
|
125 |
2 |
smpickett |
.SEG_OUT(SEG_OUT), .SEG_SEL(SEG_SEL)
|
126 |
|
|
);
|
127 |
|
|
|
128 |
|
|
wire[7:0] leds;
|
129 |
11 |
smpickett |
assign leds = mask_charMap_buf;
|
130 |
|
|
|
131 |
2 |
smpickett |
//==================================================================//
|
132 |
|
|
// SUBROUTINES //
|
133 |
|
|
//==================================================================//
|
134 |
11 |
smpickett |
//d_DCM_VGA clock_gen_VGA (
|
135 |
|
|
// .CLKIN_IN(CLK_50MHZ_IN),
|
136 |
|
|
// .RST_IN(MASTER_RST),
|
137 |
|
|
// .CLKFX_OUT(CLK_VGA),
|
138 |
|
|
// .CLKIN_IBUFG_OUT(CLK_50MHZ_B),
|
139 |
|
|
// .LOCKED_OUT(CLK_VGA_LOCKED)
|
140 |
|
|
// );
|
141 |
|
|
|
142 |
|
|
always @ (posedge CLK_50MHZ or posedge MASTER_RST)
|
143 |
|
|
if(MASTER_RST) CLK_VGA <= 1'b0;
|
144 |
|
|
else CLK_VGA <= ~CLK_VGA;
|
145 |
|
|
|
146 |
|
|
|
147 |
2 |
smpickett |
wire CLK_64MHZ_LOCKED;
|
148 |
|
|
d_DCM clock_generator(
|
149 |
|
|
.CLKIN_IN(CLK_50MHZ_IN),
|
150 |
|
|
.RST_IN(MASTER_RST),
|
151 |
|
|
.CLKIN_IBUFG_OUT(CLK_50MHZ),
|
152 |
|
|
.CLK_64MHZ(CLK_64MHZ),
|
153 |
|
|
.CLK180_64MHZ(CLK180_64MHZ),
|
154 |
|
|
.LOCKED_OUT(CLK_64MHZ_LOCKED)
|
155 |
|
|
);
|
156 |
|
|
|
157 |
|
|
wire[11:0] XCOORD, YCOORD;
|
158 |
5 |
smpickett |
wire[9:0] TRIGGER_LEVEL;
|
159 |
2 |
smpickett |
Driver_mouse driver_MOUSE(
|
160 |
|
|
.CLK_50MHZ(CLK_50MHZ), .MASTER_RST(MASTER_RST),
|
161 |
|
|
.PS2C(PS2C), .PS2D(PS2D),
|
162 |
|
|
.XCOORD(XCOORD), .YCOORD(YCOORD),
|
163 |
|
|
.L_BUTTON(L_BUTTON), .M_BUTTON(M_BUTTON), .R_BUTTON(R_BUTTON)
|
164 |
|
|
);
|
165 |
|
|
|
166 |
|
|
Driver_MouseInput Driver_MouseInput_inst(
|
167 |
|
|
.CLK_50MHZ(CLK_50MHZ), .MASTER_RST(MASTER_RST),
|
168 |
5 |
smpickett |
.XCOORD(XCOORD[9:0]), .YCOORD(YCOORD[9:0]),
|
169 |
2 |
smpickett |
.L_BUTTON(L_BUTTON), .M_BUTTON(M_BUTTON), .R_BUTTON(R_BUTTON),
|
170 |
5 |
smpickett |
.TRIGGER_LEVEL(TRIGGER_LEVEL)
|
171 |
2 |
smpickett |
);
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
wire[7:0] ADC_RAM_DATA;
|
176 |
|
|
wire[10:0] ADC_RAM_ADDR;
|
177 |
|
|
wire ADC_RAM_CLK;
|
178 |
|
|
wire[10:0] TRIG_ADDR;
|
179 |
|
|
wire VGA_WRITE_DONE;
|
180 |
|
|
ADCDataBuffer ram_ADC_databuffer(
|
181 |
|
|
.CLK_64MHZ(CLK_64MHZ), .MASTER_RST(MASTER_RST),
|
182 |
|
|
.CLK180_64MHZ(CLK180_64MHZ),
|
183 |
|
|
.TIME_BASE(TIME_BASE),
|
184 |
|
|
.RAM_ADDR(ADC_RAM_ADDR), .RAM_DATA(ADC_RAM_DATA), .RAM_CLK(ADC_RAM_CLK),
|
185 |
|
|
.ADC_DATA(ADC_DATA), .ADC_CLK(ADC_CLK),
|
186 |
|
|
.TRIG_ADDR(TRIG_ADDR), .VGA_WRITE_DONE(VGA_WRITE_DONE),
|
187 |
5 |
smpickett |
.TRIGGER_LEVEL(TRIGGER_LEVEL[8:0])
|
188 |
2 |
smpickett |
);
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
192 |
11 |
smpickett |
//------------------------------------------------------------------//
|
193 |
|
|
// VGA //
|
194 |
|
|
//------------------------------------------------------------------//
|
195 |
|
|
wire[9:0] HCNT, VCNT;
|
196 |
|
|
wire[2:0] RGB_CHAR;
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
CharacterDisplay charTest(
|
200 |
|
|
.MASTER_CLK(CLK_50MHZ), .MASTER_RST(MASTER_RST),
|
201 |
|
|
.CLK_VGA(CLK_VGA), .HCNT(HCNT), .VCNT(VCNT),
|
202 |
|
|
.RGB_OUT(RGB_CHAR),
|
203 |
|
|
.data_charMap(mask_charMap), .data_charRamRead(data_charRamRead)
|
204 |
|
|
);
|
205 |
|
|
|
206 |
|
|
|
207 |
2 |
smpickett |
//wire[17:0] VGA_RAM_ADDRESS_w;
|
208 |
|
|
//wire[15:0] VGA_RAM_DATA_w;
|
209 |
|
|
wire VGA_RAM_OE_w, VGA_RAM_WE_w, VGA_RAM_CS_w;
|
210 |
|
|
wire[17:0] VGA_RAM_ADDRESS_r;
|
211 |
|
|
wire VGA_RAM_OE_r, VGA_RAM_WE_r, VGA_RAM_CS_r;
|
212 |
|
|
//wire VGA_RAM_ACCESS_OK;
|
213 |
|
|
|
214 |
|
|
assign VGA_RAM_ADDR = (VGA_RAM_ACCESS_OK) ? VGA_RAM_ADDRESS_w : VGA_RAM_ADDRESS_r;
|
215 |
|
|
assign VGA_RAM_DATA = (VGA_RAM_ACCESS_OK) ? VGA_RAM_DATA_w : 16'bZ;
|
216 |
|
|
assign VGA_RAM_OE = (VGA_RAM_ACCESS_OK) ? VGA_RAM_OE_w : VGA_RAM_OE_r;
|
217 |
|
|
assign VGA_RAM_WE = (VGA_RAM_ACCESS_OK) ? VGA_RAM_WE_w : VGA_RAM_WE_r;
|
218 |
|
|
assign VGA_RAM_CS = (VGA_RAM_ACCESS_OK) ? VGA_RAM_CS_w : VGA_RAM_CS_r;
|
219 |
|
|
|
220 |
|
|
VGADataBuffer ram_VGA_ramwrite(
|
221 |
|
|
.CLK_50MHZ(CLK_50MHZ), .MASTER_RST(MASTER_RST),
|
222 |
|
|
.VGA_RAM_DATA(VGA_RAM_DATA_w), .VGA_RAM_ADDR(VGA_RAM_ADDRESS_w),
|
223 |
|
|
.VGA_RAM_OE(VGA_RAM_OE_w), .VGA_RAM_WE(VGA_RAM_WE_w), .VGA_RAM_CS(VGA_RAM_CS_w),
|
224 |
|
|
.VGA_RAM_ACCESS_OK(VGA_RAM_ACCESS_OK),
|
225 |
|
|
.ADC_RAM_DATA(ADC_RAM_DATA), .ADC_RAM_ADDR(ADC_RAM_ADDR), .ADC_RAM_CLK(ADC_RAM_CLK),
|
226 |
|
|
.TIME_BASE(TIME_BASE),
|
227 |
|
|
.TRIG_ADDR(TRIG_ADDR), .VGA_WRITE_DONE(VGA_WRITE_DONE)
|
228 |
|
|
);
|
229 |
|
|
|
230 |
|
|
Driver_VGA driver_VGA(
|
231 |
|
|
.CLK_50MHZ(CLK_50MHZ), .MASTER_RST(MASTER_RST),
|
232 |
11 |
smpickett |
.CLK_VGA(CLK_VGA),
|
233 |
2 |
smpickett |
.H_SYNC(H_SYNC), .V_SYNC(V_SYNC), .VGA_OUTPUT(VGA_OUTPUT),
|
234 |
|
|
.XCOORD(XCOORD), .YCOORD(YCOORD),
|
235 |
|
|
.VGA_RAM_DATA(VGA_RAM_DATA), .VGA_RAM_ADDR(VGA_RAM_ADDRESS_r),
|
236 |
|
|
.VGA_RAM_OE(VGA_RAM_OE_r), .VGA_RAM_WE(VGA_RAM_WE_r), .VGA_RAM_CS(VGA_RAM_CS_r),
|
237 |
|
|
.VGA_RAM_ACCESS_OK(VGA_RAM_ACCESS_OK),
|
238 |
5 |
smpickett |
.TRIGGER_LEVEL(TRIGGER_LEVEL[8:0]),
|
239 |
11 |
smpickett |
.SHOW_LEVELS(SHOW_LEVELS_BUTTON),
|
240 |
|
|
.HCNT(HCNT), .VCNT(VCNT),
|
241 |
|
|
.RGB_CHAR(RGB_CHAR)
|
242 |
2 |
smpickett |
);
|
243 |
|
|
|
244 |
|
|
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
|
248 |
|
|
|
249 |
|
|
//==================================================================//
|
250 |
|
|
// FUNCTIONAL DEFINITIONS //
|
251 |
|
|
//==================================================================//
|
252 |
|
|
|
253 |
|
|
endmodule
|
254 |
|
|
|