1 |
5 |
smpickett |
//==================================================================//
|
2 |
|
|
// File: d_TopLevel.v //
|
3 |
|
|
// Version: 0.0.0.2 //
|
4 |
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//
|
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 |
|
|
// //
|
29 |
|
|
//==================================================================//
|
30 |
2 |
smpickett |
|
31 |
|
|
module TopLevel(
|
32 |
|
|
CLK_50MHZ_IN, MASTER_RST,
|
33 |
|
|
H_SYNC, V_SYNC, VGA_OUTPUT,
|
34 |
|
|
PS2C, PS2D,
|
35 |
|
|
// TIME_BASE,
|
36 |
|
|
ADC_DATA, ADC_CLK,
|
37 |
|
|
VGA_RAM_ADDR, VGA_RAM_DATA,
|
38 |
|
|
VGA_RAM_OE, VGA_RAM_WE, VGA_RAM_CS,
|
39 |
|
|
|
40 |
|
|
SEG_OUT, SEG_SEL, leds, SHOW_LEVELS_BUTTON
|
41 |
|
|
);
|
42 |
|
|
|
43 |
|
|
//==================================================================//
|
44 |
|
|
// DEFINITIONS //
|
45 |
|
|
//==================================================================//
|
46 |
|
|
|
47 |
|
|
//==================================================================//
|
48 |
|
|
// VARIABLE DEFINITIONS //
|
49 |
|
|
//==================================================================//
|
50 |
|
|
|
51 |
|
|
//----------------------//
|
52 |
|
|
// INPUTS / OUTPUTS //
|
53 |
|
|
//----------------------//
|
54 |
|
|
input CLK_50MHZ_IN, MASTER_RST;
|
55 |
|
|
output H_SYNC, V_SYNC;
|
56 |
|
|
output[2:0] VGA_OUTPUT;
|
57 |
|
|
//input[5:0] TIME_BASE;
|
58 |
|
|
inout PS2C, PS2D;
|
59 |
|
|
input[7:0] ADC_DATA;
|
60 |
|
|
output ADC_CLK;
|
61 |
|
|
output[17:0] VGA_RAM_ADDR;
|
62 |
|
|
inout[15:0] VGA_RAM_DATA;
|
63 |
|
|
output VGA_RAM_OE, VGA_RAM_WE, VGA_RAM_CS;
|
64 |
|
|
|
65 |
|
|
output[7:0] leds;
|
66 |
|
|
output[6:0] SEG_OUT;
|
67 |
|
|
output[3:0] SEG_SEL;
|
68 |
|
|
input SHOW_LEVELS_BUTTON;
|
69 |
|
|
wire SHOW_LEVELS_BUTTON;
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
//----------------------//
|
73 |
|
|
// WIRES / NODES //
|
74 |
|
|
//----------------------//
|
75 |
|
|
wire CLK_50MHZ_IN, MASTER_RST;
|
76 |
|
|
wire H_SYNC, V_SYNC;
|
77 |
|
|
wire[2:0] VGA_OUTPUT;
|
78 |
|
|
wire[5:0] TIME_BASE;
|
79 |
|
|
wire PS2C, PS2D;
|
80 |
|
|
wire[7:0] ADC_DATA;
|
81 |
|
|
wire ADC_CLK;
|
82 |
|
|
wire[17:0] VGA_RAM_ADDR;
|
83 |
|
|
wire[15:0] VGA_RAM_DATA;
|
84 |
|
|
wire VGA_RAM_OE, VGA_RAM_WE, VGA_RAM_CS;
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
//----------------------//
|
88 |
|
|
// VARIABLES //
|
89 |
|
|
//----------------------//
|
90 |
|
|
assign TIME_BASE = 6'b0;
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
//==================================================================//
|
94 |
|
|
// TEMP //
|
95 |
|
|
//==================================================================//
|
96 |
|
|
wire[17:0] VGA_RAM_ADDRESS_w;
|
97 |
|
|
wire[15:0] VGA_RAM_DATA_w;
|
98 |
5 |
smpickett |
wire L_BUTTON, R_BUTTON, M_BUTTON;
|
99 |
2 |
smpickett |
|
100 |
|
|
wire VGA_RAM_ACCESS_OK;
|
101 |
|
|
wire CLK_50MHZ, CLK_64MHZ, CLK180_64MHZ;
|
102 |
|
|
wire[6:0] SEG_OUT;
|
103 |
|
|
wire[3:0] SEG_SEL;
|
104 |
|
|
|
105 |
|
|
sub_SegDriver segs(
|
106 |
|
|
.CLK_50MHZ(CLK_50MHZ), .MASTER_RST(MASTER_RST),
|
107 |
|
|
.DATA_IN(),
|
108 |
|
|
.SEG_OUT(SEG_OUT), .SEG_SEL(SEG_SEL)
|
109 |
|
|
);
|
110 |
|
|
|
111 |
|
|
wire[7:0] leds;
|
112 |
|
|
assign leds[0] = L_BUTTON;
|
113 |
|
|
assign leds[1] = M_BUTTON;
|
114 |
|
|
assign leds[2] = R_BUTTON;
|
115 |
5 |
smpickett |
assign leds[3] = 1'b0;
|
116 |
2 |
smpickett |
assign leds[7:4] = 4'b0;
|
117 |
|
|
//==================================================================//
|
118 |
|
|
// SUBROUTINES //
|
119 |
|
|
//==================================================================//
|
120 |
|
|
//wire CLK_50MHZ, CLK_64MHZ, CLK180_64MHZ;
|
121 |
|
|
wire CLK_64MHZ_LOCKED;
|
122 |
|
|
d_DCM clock_generator(
|
123 |
|
|
.CLKIN_IN(CLK_50MHZ_IN),
|
124 |
|
|
.RST_IN(MASTER_RST),
|
125 |
|
|
.CLKIN_IBUFG_OUT(CLK_50MHZ),
|
126 |
|
|
.CLK_64MHZ(CLK_64MHZ),
|
127 |
|
|
.CLK180_64MHZ(CLK180_64MHZ),
|
128 |
|
|
.LOCKED_OUT(CLK_64MHZ_LOCKED)
|
129 |
|
|
);
|
130 |
|
|
|
131 |
|
|
wire[11:0] XCOORD, YCOORD;
|
132 |
5 |
smpickett |
wire[9:0] TRIGGER_LEVEL;
|
133 |
2 |
smpickett |
Driver_mouse driver_MOUSE(
|
134 |
|
|
.CLK_50MHZ(CLK_50MHZ), .MASTER_RST(MASTER_RST),
|
135 |
|
|
.PS2C(PS2C), .PS2D(PS2D),
|
136 |
|
|
.XCOORD(XCOORD), .YCOORD(YCOORD),
|
137 |
|
|
.L_BUTTON(L_BUTTON), .M_BUTTON(M_BUTTON), .R_BUTTON(R_BUTTON)
|
138 |
|
|
);
|
139 |
|
|
|
140 |
|
|
Driver_MouseInput Driver_MouseInput_inst(
|
141 |
|
|
.CLK_50MHZ(CLK_50MHZ), .MASTER_RST(MASTER_RST),
|
142 |
5 |
smpickett |
.XCOORD(XCOORD[9:0]), .YCOORD(YCOORD[9:0]),
|
143 |
2 |
smpickett |
.L_BUTTON(L_BUTTON), .M_BUTTON(M_BUTTON), .R_BUTTON(R_BUTTON),
|
144 |
5 |
smpickett |
.TRIGGER_LEVEL(TRIGGER_LEVEL)
|
145 |
2 |
smpickett |
);
|
146 |
|
|
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
wire[7:0] ADC_RAM_DATA;
|
150 |
|
|
wire[10:0] ADC_RAM_ADDR;
|
151 |
|
|
wire ADC_RAM_CLK;
|
152 |
|
|
wire[10:0] TRIG_ADDR;
|
153 |
|
|
wire VGA_WRITE_DONE;
|
154 |
|
|
ADCDataBuffer ram_ADC_databuffer(
|
155 |
|
|
.CLK_64MHZ(CLK_64MHZ), .MASTER_RST(MASTER_RST),
|
156 |
|
|
.CLK180_64MHZ(CLK180_64MHZ),
|
157 |
|
|
.TIME_BASE(TIME_BASE),
|
158 |
|
|
.RAM_ADDR(ADC_RAM_ADDR), .RAM_DATA(ADC_RAM_DATA), .RAM_CLK(ADC_RAM_CLK),
|
159 |
|
|
.ADC_DATA(ADC_DATA), .ADC_CLK(ADC_CLK),
|
160 |
|
|
.TRIG_ADDR(TRIG_ADDR), .VGA_WRITE_DONE(VGA_WRITE_DONE),
|
161 |
5 |
smpickett |
.TRIGGER_LEVEL(TRIGGER_LEVEL[8:0])
|
162 |
2 |
smpickett |
);
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
//wire[17:0] VGA_RAM_ADDRESS_w;
|
167 |
|
|
//wire[15:0] VGA_RAM_DATA_w;
|
168 |
|
|
wire VGA_RAM_OE_w, VGA_RAM_WE_w, VGA_RAM_CS_w;
|
169 |
|
|
wire[17:0] VGA_RAM_ADDRESS_r;
|
170 |
|
|
wire VGA_RAM_OE_r, VGA_RAM_WE_r, VGA_RAM_CS_r;
|
171 |
|
|
//wire VGA_RAM_ACCESS_OK;
|
172 |
|
|
|
173 |
|
|
assign VGA_RAM_ADDR = (VGA_RAM_ACCESS_OK) ? VGA_RAM_ADDRESS_w : VGA_RAM_ADDRESS_r;
|
174 |
|
|
assign VGA_RAM_DATA = (VGA_RAM_ACCESS_OK) ? VGA_RAM_DATA_w : 16'bZ;
|
175 |
|
|
assign VGA_RAM_OE = (VGA_RAM_ACCESS_OK) ? VGA_RAM_OE_w : VGA_RAM_OE_r;
|
176 |
|
|
assign VGA_RAM_WE = (VGA_RAM_ACCESS_OK) ? VGA_RAM_WE_w : VGA_RAM_WE_r;
|
177 |
|
|
assign VGA_RAM_CS = (VGA_RAM_ACCESS_OK) ? VGA_RAM_CS_w : VGA_RAM_CS_r;
|
178 |
|
|
|
179 |
|
|
VGADataBuffer ram_VGA_ramwrite(
|
180 |
|
|
.CLK_50MHZ(CLK_50MHZ), .MASTER_RST(MASTER_RST),
|
181 |
|
|
.VGA_RAM_DATA(VGA_RAM_DATA_w), .VGA_RAM_ADDR(VGA_RAM_ADDRESS_w),
|
182 |
|
|
.VGA_RAM_OE(VGA_RAM_OE_w), .VGA_RAM_WE(VGA_RAM_WE_w), .VGA_RAM_CS(VGA_RAM_CS_w),
|
183 |
|
|
.VGA_RAM_ACCESS_OK(VGA_RAM_ACCESS_OK),
|
184 |
|
|
.ADC_RAM_DATA(ADC_RAM_DATA), .ADC_RAM_ADDR(ADC_RAM_ADDR), .ADC_RAM_CLK(ADC_RAM_CLK),
|
185 |
|
|
.TIME_BASE(TIME_BASE),
|
186 |
|
|
.TRIG_ADDR(TRIG_ADDR), .VGA_WRITE_DONE(VGA_WRITE_DONE)
|
187 |
|
|
);
|
188 |
|
|
|
189 |
|
|
Driver_VGA driver_VGA(
|
190 |
|
|
.CLK_50MHZ(CLK_50MHZ), .MASTER_RST(MASTER_RST),
|
191 |
|
|
.H_SYNC(H_SYNC), .V_SYNC(V_SYNC), .VGA_OUTPUT(VGA_OUTPUT),
|
192 |
|
|
.XCOORD(XCOORD), .YCOORD(YCOORD),
|
193 |
|
|
.VGA_RAM_DATA(VGA_RAM_DATA), .VGA_RAM_ADDR(VGA_RAM_ADDRESS_r),
|
194 |
|
|
.VGA_RAM_OE(VGA_RAM_OE_r), .VGA_RAM_WE(VGA_RAM_WE_r), .VGA_RAM_CS(VGA_RAM_CS_r),
|
195 |
|
|
.VGA_RAM_ACCESS_OK(VGA_RAM_ACCESS_OK),
|
196 |
5 |
smpickett |
.TRIGGER_LEVEL(TRIGGER_LEVEL[8:0]),
|
197 |
2 |
smpickett |
.SHOW_LEVELS(SHOW_LEVELS_BUTTON)
|
198 |
|
|
);
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
//==================================================================//
|
206 |
|
|
// FUNCTIONAL DEFINITIONS //
|
207 |
|
|
//==================================================================//
|
208 |
|
|
|
209 |
|
|
endmodule
|
210 |
|
|
|