-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathboard_specific_top.sv
234 lines (171 loc) · 6.33 KB
/
board_specific_top.sv
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
// This board is referred as "MINI FPGA", EPI-MiniCY4
// and as a part of a kit called EPI-LITE304.
//
// See http://emooc.cc
// and http://www.emooc.cc/ProductDetail/1600208.html
// for more details.
`include "config.svh"
`include "lab_specific_board_config.svh"
module board_specific_top
# (
parameter clk_mhz = 50,
pixel_mhz = 25,
w_key = 8,
w_sw = 8,
w_led = 16,
w_digit = 6,
w_gpio = 8,
screen_width = 640,
screen_height = 480,
w_red = 4,
w_green = 4,
w_blue = 4,
w_x = $clog2 ( screen_width ),
w_y = $clog2 ( screen_height ),
w_gpio_j7 = 36,
w_gpio_p1 = 21,
w_gpio_p2 = 21
)
(
input CLK,
input [w_key - 1:0] KEY_N,
input [w_sw - 1:0] SW,
output [w_led - 1:0] LED,
output [ 7:0] ABCDEFGH,
output [w_digit - 1:0] DIGIT_N,
input UART_RX,
output UART_TX,
inout [w_gpio_j7 + 3 - 1:3] GPIO_J7,
inout [w_gpio_p1 + 2 - 1:2] GPIO_P1,
inout [w_gpio_p2 + 2 - 1:2] GPIO_P2
);
//------------------------------------------------------------------------
wire clk;
wire rst;
wire [w_key - 2:0] lab_key;
wire [w_led - 1:0] lab_led;
wire [w_gpio - 1:0] lab_gpio;
// A dynamic seven-segment display
wire [ 7:0] abcdefgh;
wire [ w_digit - 1:0] digit;
// Graphics
wire [ w_x - 1:0] x;
wire [ w_y - 1:0] y;
// VGA
wire vga_hsync;
wire vga_vsync;
wire [ w_red - 1:0] vga_red;
wire [ w_green - 1:0] vga_green;
wire [ w_blue - 1:0] vga_blue;
// Microphone, sound output and UART
wire [ 23:0] mic;
wire [ 15:0] sound;
//------------------------------------------------------------------------
wire slow_clk;
slow_clk_gen # (.fast_clk_mhz (clk_mhz), .slow_clk_hz (1))
i_slow_clk_gen (.slow_clk (slow_clk), .*);
//------------------------------------------------------------------------
lab_top
# (
.clk_mhz ( clk_mhz ),
.w_key ( w_key ),
.w_sw ( w_sw ),
.w_led ( w_led ),
.w_digit ( w_digit ),
.w_gpio ( w_gpio ),
.screen_width ( screen_width ),
.screen_height ( screen_height ),
.w_red ( w_red ), // This is not true RGB channel width
.w_green ( w_green ),
.w_blue ( w_blue )
)
i_lab_top
(
.clk ( clk ),
.slow_clk ( slow_clk ),
.rst ( rst ),
.key ( lab_key ),
.sw ( ~ SW ),
.led ( lab_led ),
.abcdefgh ( abcdefgh ),
.digit ( digit ),
.x ( x ),
.y ( y ),
.red ( vga_red ),
.green ( vga_green ),
.blue ( vga_blue ),
.uart_rx ( UART_RX ),
.uart_tx ( UART_TX ),
.mic ( mic ),
.sound ( sound ),
.gpio ( lab_gpio )
);
//------------------------------------------------------------------------
assign clk = CLK;
assign LED = ~ lab_led;
assign ABCDEFGH = abcdefgh;
assign DIGIT_N = ~ digit;
assign rst = ~ KEY_N [w_key - 1 ];
assign lab_key = ~ KEY_N [w_key - 2:0];
assign GPIO_P1 [2] = vga_hsync; // PIN_C6
assign GPIO_P1 [3] = vga_vsync; // PIN_B6
assign GPIO_P1 [7 : 4] = vga_red ; // PIN_B8, A7, B7, A6
assign GPIO_P1 [11 : 8] = vga_green; // PIN_A11, B9, A9, A8
assign GPIO_P1 [15 : 12] = vga_blue ; // PIN_A13, B12, A12, B11
assign GPIO_P2 [14 : 6] = lab_gpio; //
//------------------------------------------------------------------------
`ifdef INSTANTIATE_GRAPHICS_INTERFACE_MODULE
wire [9:0] x10; assign x = x10;
wire [9:0] y10; assign y = y10;
vga
# (
.CLK_MHZ ( clk_mhz ),
.PIXEL_MHZ ( pixel_mhz )
)
i_vga
(
.clk ( clk ),
.rst ( rst ),
.hsync ( vga_hsync ),
.vsync ( vga_vsync ),
.display_on ( ),
.hpos ( x10 ),
.vpos ( y10 ),
.pixel_clk ( )
);
`endif
//------------------------------------------------------------------------
`ifdef INSTANTIATE_MICROPHONE_INTERFACE_MODULE
inmp441_mic_i2s_receiver
# (
.clk_mhz ( clk_mhz )
)
i_microphone
(
.clk ( clk ),
.rst ( rst ),
.lr ( GPIO_P1 [16] ), // PIN_B13
.ws ( GPIO_P1 [17] ), // PIN_A14
.sck ( GPIO_P1 [18] ), // PIN_B14
.sd ( GPIO_P1 [19] ), // PIN_A15
.value ( mic )
);
`endif
//------------------------------------------------------------------------
`ifdef INSTANTIATE_SOUND_OUTPUT_INTERFACE_MODULE
i2s_audio_out
# (
.clk_mhz ( clk_mhz )
)
inst_audio_out
(
.clk ( clk ),
.reset ( rst ),
.data_in ( sound ),
.mclk ( GPIO_P2 [2] ), // PIN_N6 on FPGA // SCK on sound card
.bclk ( GPIO_P2 [3] ), // PIN_R8 on FPGA // BCK on sound card
.lrclk ( GPIO_P2 [4] ), // PIN_T8 on FPGA // LCK on sound card
.sdata ( GPIO_P2 [5] ) // PIN_T9 on FPGA // DIN on sound card
);
`endif
endmodule