1 |
3 |
dgisselq |
////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
//
|
3 |
|
|
// Filename: fastio.v
|
4 |
|
|
//
|
5 |
|
|
// Project: OpenArty, an entirely open SoC based upon the Arty platform
|
6 |
|
|
//
|
7 |
|
|
// Purpose:
|
8 |
|
|
//
|
9 |
|
|
// Creator: Dan Gisselquist, Ph.D.
|
10 |
|
|
// Gisselquist Technology, LLC
|
11 |
|
|
//
|
12 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
13 |
|
|
//
|
14 |
|
|
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
|
15 |
|
|
//
|
16 |
|
|
// This program is free software (firmware): you can redistribute it and/or
|
17 |
|
|
// modify it under the terms of the GNU General Public License as published
|
18 |
|
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
19 |
|
|
// your option) any later version.
|
20 |
|
|
//
|
21 |
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
22 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
23 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
24 |
|
|
// for more details.
|
25 |
|
|
//
|
26 |
|
|
// You should have received a copy of the GNU General Public License along
|
27 |
|
|
// with this program. (It's in the $(ROOT)/doc directory, run make with no
|
28 |
|
|
// target there if the PDF file isn't present.) If not, see
|
29 |
|
|
// <http://www.gnu.org/licenses/> for a copy.
|
30 |
|
|
//
|
31 |
|
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
32 |
|
|
// http://www.gnu.org/licenses/gpl.html
|
33 |
|
|
//
|
34 |
|
|
//
|
35 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
36 |
|
|
//
|
37 |
|
|
//
|
38 |
|
|
`include "builddate.v"
|
39 |
|
|
//
|
40 |
|
|
module fastio(i_clk,
|
41 |
|
|
// Board level I/O
|
42 |
|
|
i_sw, i_btn, o_led,
|
43 |
|
|
o_clr_led0, o_clr_led1, o_clr_led2, o_clr_led3,
|
44 |
|
|
// Board level PMod I/O
|
45 |
|
|
i_aux_rx, o_aux_tx, o_aux_cts, i_gps_rx, o_gps_tx,
|
46 |
|
|
// i_gpio, o_gpio,
|
47 |
|
|
// Wishbone control
|
48 |
|
|
i_wb_cyc, i_wb_stb, i_wb_we, i_wb_addr,
|
49 |
|
|
i_wb_data, o_wb_ack, o_wb_stall, o_wb_data,
|
50 |
|
|
// Cross-board I/O
|
51 |
|
|
i_rtc_ppd, i_buserr, i_other_ints, o_bus_int, o_board_ints);
|
52 |
|
|
parameter AUXUART_SETUP = 30'hd50, // 4M baud from 200MHz clock
|
53 |
|
|
GPSUART_SETUP = 30'hd20833; // 9600 baud from 200MHz clk
|
54 |
|
|
input i_clk;
|
55 |
|
|
// Board level I/O
|
56 |
|
|
input [3:0] i_sw;
|
57 |
|
|
input [3:0] i_btn;
|
58 |
|
|
output wire [3:0] o_led;
|
59 |
|
|
output reg [2:0] o_clr_led0;
|
60 |
|
|
output reg [2:0] o_clr_led1;
|
61 |
|
|
output reg [2:0] o_clr_led2;
|
62 |
|
|
output reg [2:0] o_clr_led3;
|
63 |
|
|
// Board level PMod I/O
|
64 |
|
|
//
|
65 |
|
|
// Auxilliary UART I/O
|
66 |
|
|
input i_aux_rx;
|
67 |
|
|
output wire o_aux_tx, o_aux_cts;
|
68 |
|
|
//
|
69 |
|
|
// GPS UART I/O
|
70 |
|
|
input i_gps_rx;
|
71 |
|
|
output wire o_gps_tx;
|
72 |
|
|
//
|
73 |
|
|
// GPIO
|
74 |
|
|
// input [(NGPI-1):0] i_gpio;
|
75 |
|
|
// output reg [(NGPO-1):0] o_gpio;
|
76 |
|
|
//
|
77 |
|
|
// Wishbone inputs
|
78 |
|
|
input i_wb_cyc, i_wb_stb, i_wb_we;
|
79 |
|
|
input [4:0] i_wb_addr;
|
80 |
|
|
input [31:0] i_wb_data;
|
81 |
|
|
// Wishbone outputs
|
82 |
|
|
output reg o_wb_ack;
|
83 |
|
|
output wire o_wb_stall;
|
84 |
|
|
output reg [31:0] o_wb_data;
|
85 |
|
|
// A strobe at midnight, to keep the calendar on "time"
|
86 |
|
|
input i_rtc_ppd;
|
87 |
|
|
// Address of the last bus error
|
88 |
|
|
input [31:0] i_buserr;
|
89 |
|
|
//
|
90 |
|
|
// Interrupts -- both the output bus interrupt, as well as those
|
91 |
|
|
// internally generated interrupts which may be used elsewhere
|
92 |
|
|
// in the design
|
93 |
|
|
input wire [8:0] i_other_ints;
|
94 |
|
|
output wire o_bus_int;
|
95 |
|
|
output wire [5:0] o_board_ints; // Button and switch interrupts
|
96 |
|
|
|
97 |
|
|
reg last_wb_stb;
|
98 |
|
|
reg [4:0] last_wb_addr;
|
99 |
|
|
reg [31:0] last_wb_data;
|
100 |
|
|
initial last_wb_stb = 1'b0;
|
101 |
|
|
always @(posedge i_clk)
|
102 |
|
|
begin
|
103 |
|
|
last_wb_addr <= i_wb_addr;
|
104 |
|
|
last_wb_data <= i_wb_data;
|
105 |
|
|
last_wb_stb <= (i_wb_stb)&&(i_wb_we);
|
106 |
|
|
end
|
107 |
|
|
|
108 |
|
|
wire [31:0] pic_data;
|
109 |
|
|
reg sw_int, btn_int;
|
110 |
|
|
wire pps_int, rtc_int, netrx_int, nettx_int,
|
111 |
|
|
auxrx_int, auxtx_int, gpio_int, flash_int, scop_int,
|
112 |
|
|
gpsrx_int, sd_int, oled_int, zip_int;
|
113 |
|
|
assign { zip_int, oled_int, rtc_int, sd_int,
|
114 |
|
|
nettx_int, netrx_int, scop_int, flash_int,
|
115 |
|
|
pps_int } = i_other_ints;
|
116 |
|
|
|
117 |
|
|
icontrol #(15) buspic(i_clk, 1'b0,
|
118 |
|
|
(last_wb_stb)&&(last_wb_addr==5'h1),
|
119 |
|
|
i_wb_data, pic_data,
|
120 |
|
|
{ zip_int, oled_int, sd_int,
|
121 |
|
|
gpsrx_int, scop_int, flash_int, gpio_int,
|
122 |
|
|
auxtx_int, auxrx_int, nettx_int, netrx_int,
|
123 |
|
|
rtc_int, pps_int, sw_int, btn_int },
|
124 |
|
|
o_bus_int);
|
125 |
|
|
|
126 |
|
|
//
|
127 |
|
|
// PWR Count
|
128 |
|
|
//
|
129 |
|
|
// A 32-bit counter that starts at power up and never resets. It's a
|
130 |
|
|
// read only counter if you will.
|
131 |
|
|
reg [31:0] pwr_counter;
|
132 |
|
|
initial pwr_counter = 32'h00;
|
133 |
|
|
always @(posedge i_clk)
|
134 |
|
|
pwr_counter <= pwr_counter+32'h001;
|
135 |
|
|
|
136 |
|
|
//
|
137 |
|
|
// BTNSW
|
138 |
|
|
//
|
139 |
|
|
// The button and switch control register
|
140 |
|
|
wire [31:0] w_btnsw;
|
141 |
|
|
reg [3:0] r_sw, swcfg, swnow, swlast;
|
142 |
|
|
reg [3:0] r_btn, btncfg, btnnow, btnlast, btnstate;
|
143 |
|
|
initial btn_int = 1'b0;
|
144 |
|
|
initial sw_int = 1'b0;
|
145 |
|
|
always @(posedge i_clk)
|
146 |
|
|
begin
|
147 |
|
|
r_sw <= i_sw;
|
148 |
|
|
swnow <= r_sw;
|
149 |
|
|
swlast<= swnow;
|
150 |
|
|
sw_int <= |((swnow^swlast)|swcfg);
|
151 |
|
|
|
152 |
|
|
if ((last_wb_stb)&&(last_wb_addr == 5'h4))
|
153 |
|
|
swcfg <= ((last_wb_data[3:0])&(last_wb_data[11:8]))
|
154 |
|
|
|((~last_wb_data[3:0])&(swcfg));
|
155 |
|
|
|
156 |
|
|
r_btn <= i_btn;
|
157 |
|
|
btnnow <= r_btn;
|
158 |
|
|
btn_int <= |(btnnow&btncfg);
|
159 |
|
|
if ((last_wb_stb)&&(last_wb_addr == 5'h4))
|
160 |
|
|
begin
|
161 |
|
|
btncfg <= ((last_wb_data[7:4])&(last_wb_data[15:12]))
|
162 |
|
|
|((~last_wb_data[7:4])&(btncfg));
|
163 |
|
|
btnstate<= (btnnow)|((btnstate)&(~last_wb_data[7:4]));
|
164 |
|
|
end else
|
165 |
|
|
btnstate <= (btnstate)|(btnnow);
|
166 |
|
|
end
|
167 |
|
|
assign w_btnsw = { 8'h00, btnnow, 4'h0, btncfg, swcfg, btnstate, swnow };
|
168 |
|
|
|
169 |
|
|
//
|
170 |
|
|
// LEDCTRL
|
171 |
|
|
//
|
172 |
|
|
reg [3:0] r_leds;
|
173 |
|
|
wire [31:0] w_ledreg;
|
174 |
|
|
reg last_cyc;
|
175 |
|
|
always @(posedge i_clk)
|
176 |
|
|
last_cyc <= i_wb_cyc;
|
177 |
|
|
initial r_leds = 4'h0;
|
178 |
|
|
always @(posedge i_clk)
|
179 |
|
|
if ((last_wb_stb)&&(last_wb_addr == 5'h5))
|
180 |
|
|
r_leds <= last_wb_data[3:0];
|
181 |
|
|
assign o_led = r_leds;
|
182 |
|
|
assign w_ledreg = { 28'h0, r_leds };
|
183 |
|
|
|
184 |
|
|
//
|
185 |
|
|
// GPIO
|
186 |
|
|
//
|
187 |
|
|
// Not used (yet), but this interface should allow us to control up to
|
188 |
|
|
// 16 GPIO inputs, and another 16 GPIO outputs. The interrupt trips
|
189 |
|
|
// when any of the inputs changes. (Sorry, which input isn't (yet)
|
190 |
|
|
// selectable.)
|
191 |
|
|
//
|
192 |
|
|
assign gpio_int = 1'b0;
|
193 |
|
|
|
194 |
|
|
//
|
195 |
|
|
// AUX (UART) SETUP
|
196 |
|
|
//
|
197 |
|
|
// Set us up for 4Mbaud, 8 data bits, no stop bits.
|
198 |
|
|
reg [29:0] aux_setup;
|
199 |
|
|
initial aux_setup = AUXUART_SETUP;
|
200 |
|
|
always @(posedge i_clk)
|
201 |
|
|
if ((last_wb_stb)&&(last_wb_addr == 5'h6))
|
202 |
|
|
aux_setup[29:0] <= last_wb_data[29:0];
|
203 |
|
|
|
204 |
|
|
//
|
205 |
|
|
// GPSSETUP
|
206 |
|
|
//
|
207 |
|
|
// Set us up for 9600 kbaud, 8 data bits, no stop bits.
|
208 |
|
|
reg [29:0] gps_setup;
|
209 |
|
|
initial gps_setup = GPSUART_SETUP;
|
210 |
|
|
always @(posedge i_clk)
|
211 |
|
|
if ((last_wb_stb)&&(last_wb_addr == 5'h7))
|
212 |
|
|
gps_setup[29:0] <= last_wb_data[29:0];
|
213 |
|
|
|
214 |
|
|
//
|
215 |
|
|
// CLR LEDs
|
216 |
|
|
//
|
217 |
|
|
|
218 |
|
|
// CLR LED 0
|
219 |
|
|
wire [31:0] w_clr_led0;
|
220 |
|
|
reg [8:0] r_clr_led0_r, r_clr_led0_g, r_clr_led0_b;
|
221 |
|
|
initial r_clr_led0_r = 9'h003; // Color LED on the far right
|
222 |
|
|
initial r_clr_led0_g = 9'h000;
|
223 |
|
|
initial r_clr_led0_b = 9'h000;
|
224 |
|
|
always @(posedge i_clk)
|
225 |
|
|
if ((last_wb_stb)&&(last_wb_addr == 5'h8))
|
226 |
|
|
begin
|
227 |
|
|
r_clr_led0_r <= { last_wb_data[26], last_wb_data[23:16] };
|
228 |
|
|
r_clr_led0_g <= { last_wb_data[25], last_wb_data[15: 8] };
|
229 |
|
|
r_clr_led0_b <= { last_wb_data[24], last_wb_data[ 7: 0] };
|
230 |
|
|
end
|
231 |
|
|
assign w_clr_led0 = { 5'h0,
|
232 |
|
|
r_clr_led0_r[8], r_clr_led0_g[8], r_clr_led0_b[8],
|
233 |
|
|
r_clr_led0_r[7:0], r_clr_led0_g[7:0], r_clr_led0_b[7:0]
|
234 |
|
|
};
|
235 |
|
|
always @(posedge i_clk)
|
236 |
|
|
o_clr_led0 <= { (pwr_counter[8:0] < r_clr_led0_r),
|
237 |
|
|
(pwr_counter[8:0] < r_clr_led0_g),
|
238 |
|
|
(pwr_counter[8:0] < r_clr_led0_b) };
|
239 |
|
|
|
240 |
|
|
// CLR LED 1
|
241 |
|
|
wire [31:0] w_clr_led1;
|
242 |
|
|
reg [8:0] r_clr_led1_r, r_clr_led1_g, r_clr_led1_b;
|
243 |
|
|
initial r_clr_led1_r = 9'h007;
|
244 |
|
|
initial r_clr_led1_g = 9'h000;
|
245 |
|
|
initial r_clr_led1_b = 9'h000;
|
246 |
|
|
always @(posedge i_clk)
|
247 |
|
|
if ((last_wb_stb)&&(last_wb_addr == 5'h9))
|
248 |
|
|
begin
|
249 |
|
|
r_clr_led1_r <= { last_wb_data[26], last_wb_data[23:16] };
|
250 |
|
|
r_clr_led1_g <= { last_wb_data[25], last_wb_data[15: 8] };
|
251 |
|
|
r_clr_led1_b <= { last_wb_data[24], last_wb_data[ 7: 0] };
|
252 |
|
|
end
|
253 |
|
|
assign w_clr_led1 = { 5'h0,
|
254 |
|
|
r_clr_led1_r[8], r_clr_led1_g[8], r_clr_led1_b[8],
|
255 |
|
|
r_clr_led1_r[7:0], r_clr_led1_g[7:0], r_clr_led1_b[7:0]
|
256 |
|
|
};
|
257 |
|
|
always @(posedge i_clk)
|
258 |
|
|
o_clr_led1 <= { (pwr_counter[8:0] < r_clr_led1_r),
|
259 |
|
|
(pwr_counter[8:0] < r_clr_led1_g),
|
260 |
|
|
(pwr_counter[8:0] < r_clr_led1_b) };
|
261 |
|
|
// CLR LED 0
|
262 |
|
|
wire [31:0] w_clr_led2;
|
263 |
|
|
reg [8:0] r_clr_led2_r, r_clr_led2_g, r_clr_led2_b;
|
264 |
|
|
initial r_clr_led2_r = 9'h00f;
|
265 |
|
|
initial r_clr_led2_g = 9'h000;
|
266 |
|
|
initial r_clr_led2_b = 9'h000;
|
267 |
|
|
always @(posedge i_clk)
|
268 |
|
|
if ((last_wb_stb)&&(last_wb_addr == 5'ha))
|
269 |
|
|
begin
|
270 |
|
|
r_clr_led2_r <= { last_wb_data[26], last_wb_data[23:16] };
|
271 |
|
|
r_clr_led2_g <= { last_wb_data[25], last_wb_data[15: 8] };
|
272 |
|
|
r_clr_led2_b <= { last_wb_data[24], last_wb_data[ 7: 0] };
|
273 |
|
|
end
|
274 |
|
|
assign w_clr_led2 = { 5'h0,
|
275 |
|
|
r_clr_led2_r[8], r_clr_led2_g[8], r_clr_led2_b[8],
|
276 |
|
|
r_clr_led2_r[7:0], r_clr_led2_g[7:0], r_clr_led2_b[7:0]
|
277 |
|
|
};
|
278 |
|
|
always @(posedge i_clk)
|
279 |
|
|
o_clr_led2 <= { (pwr_counter[8:0] < r_clr_led2_r),
|
280 |
|
|
(pwr_counter[8:0] < r_clr_led2_g),
|
281 |
|
|
(pwr_counter[8:0] < r_clr_led2_b) };
|
282 |
|
|
// CLR LED 3
|
283 |
|
|
wire [31:0] w_clr_led3;
|
284 |
|
|
reg [8:0] r_clr_led3_r, r_clr_led3_g, r_clr_led3_b;
|
285 |
|
|
initial r_clr_led3_r = 9'h01f; // LED is on far left
|
286 |
|
|
initial r_clr_led3_g = 9'h000;
|
287 |
|
|
initial r_clr_led3_b = 9'h000;
|
288 |
|
|
always @(posedge i_clk)
|
289 |
|
|
if ((last_wb_stb)&&(last_wb_addr == 5'hb))
|
290 |
|
|
begin
|
291 |
|
|
r_clr_led3_r <= { last_wb_data[26], last_wb_data[23:16] };
|
292 |
|
|
r_clr_led3_g <= { last_wb_data[25], last_wb_data[15: 8] };
|
293 |
|
|
r_clr_led3_b <= { last_wb_data[24], last_wb_data[ 7: 0] };
|
294 |
|
|
end
|
295 |
|
|
assign w_clr_led3 = { 5'h0,
|
296 |
|
|
r_clr_led3_r[8], r_clr_led3_g[8], r_clr_led3_b[8],
|
297 |
|
|
r_clr_led3_r[7:0], r_clr_led3_g[7:0], r_clr_led3_b[7:0]
|
298 |
|
|
};
|
299 |
|
|
always @(posedge i_clk)
|
300 |
|
|
o_clr_led3 <= { (pwr_counter[8:0] < r_clr_led3_r),
|
301 |
|
|
(pwr_counter[8:0] < r_clr_led3_g),
|
302 |
|
|
(pwr_counter[8:0] < r_clr_led3_b) };
|
303 |
|
|
|
304 |
|
|
//
|
305 |
|
|
// The Calendar DATE
|
306 |
|
|
//
|
307 |
|
|
wire [31:0] date_data;
|
308 |
|
|
`define GET_DATE
|
309 |
|
|
`ifdef GET_DATE
|
310 |
|
|
wire date_ack, date_stall;
|
311 |
|
|
rtcdate thedate(i_clk, i_rtc_ppd,
|
312 |
|
|
i_wb_cyc, last_wb_stb, (last_wb_addr==5'hc), last_wb_data,
|
313 |
|
|
date_ack, date_stall, date_data);
|
314 |
|
|
`else
|
315 |
|
|
assign date_data = 32'h20160000;
|
316 |
|
|
`endif
|
317 |
|
|
|
318 |
|
|
//////
|
319 |
|
|
//
|
320 |
|
|
// The auxilliary UART
|
321 |
|
|
//
|
322 |
|
|
//////
|
323 |
|
|
|
324 |
|
|
// First the receiver
|
325 |
|
|
wire auxrx_stb, auxrx_break, auxrx_perr, auxrx_ferr, auxck_uart;
|
326 |
|
|
wire [7:0] rx_data_aux_port;
|
327 |
|
|
rxuart auxrx(i_clk, 1'b0, aux_setup, i_aux_rx,
|
328 |
|
|
auxrx_stb, rx_data_aux_port, auxrx_break,
|
329 |
|
|
auxrx_perr, auxrx_ferr, auxck_uart);
|
330 |
|
|
|
331 |
|
|
wire [31:0] auxrx_data;
|
332 |
|
|
reg [11:0] r_auxrx_data;
|
333 |
|
|
always @(posedge i_clk)
|
334 |
|
|
if (auxrx_stb)
|
335 |
|
|
begin
|
336 |
|
|
r_auxrx_data[11] <= auxrx_break;
|
337 |
|
|
r_auxrx_data[10] <= auxrx_ferr;
|
338 |
|
|
r_auxrx_data[ 9] <= auxrx_perr;
|
339 |
|
|
r_auxrx_data[7:0]<= rx_data_aux_port;
|
340 |
|
|
end
|
341 |
|
|
always @(posedge i_clk)
|
342 |
|
|
if(((i_wb_stb)&&(~i_wb_we)&&(i_wb_addr == 5'h0d))||(auxrx_stb))
|
343 |
|
|
r_auxrx_data[8] <= auxrx_stb;
|
344 |
|
|
assign o_aux_cts = auxrx_stb;
|
345 |
|
|
assign auxrx_data = { 20'h00, r_auxrx_data };
|
346 |
|
|
assign auxrx_int = r_auxrx_data[8];
|
347 |
|
|
|
348 |
|
|
|
349 |
|
|
// Then the transmitter
|
350 |
|
|
wire auxtx_busy;
|
351 |
|
|
reg [7:0] r_auxtx_data;
|
352 |
|
|
reg r_auxtx_stb, r_auxtx_break;
|
353 |
|
|
wire [31:0] auxtx_data;
|
354 |
|
|
txuart auxtx(i_clk, 1'b0, aux_setup,
|
355 |
|
|
r_auxtx_break, r_auxtx_stb, r_auxtx_data,
|
356 |
|
|
o_aux_tx, auxtx_busy);
|
357 |
|
|
always @(posedge i_clk)
|
358 |
|
|
if ((last_wb_stb)&&(last_wb_addr == 5'h0e))
|
359 |
|
|
begin
|
360 |
|
|
r_auxtx_stb <= 1'b1;
|
361 |
|
|
r_auxtx_data <= last_wb_data[7:0];
|
362 |
|
|
r_auxtx_break<= last_wb_data[9];
|
363 |
|
|
end else if (~auxtx_busy)
|
364 |
|
|
begin
|
365 |
|
|
r_auxtx_stb <= 1'b0;
|
366 |
|
|
r_auxtx_data <= 8'h0;
|
367 |
|
|
end
|
368 |
|
|
assign auxtx_data = { 20'h00,
|
369 |
|
|
auxck_uart, o_aux_tx, r_auxtx_break, auxtx_busy,
|
370 |
|
|
r_auxtx_data };
|
371 |
|
|
assign auxtx_int = ~auxtx_busy;
|
372 |
|
|
|
373 |
|
|
//////
|
374 |
|
|
//
|
375 |
|
|
// The GPS UART
|
376 |
|
|
//
|
377 |
|
|
//////
|
378 |
|
|
|
379 |
|
|
// First the receiver
|
380 |
|
|
wire gpsrx_stb, gpsrx_break, gpsrx_perr, gpsrx_ferr, gpsck_uart;
|
381 |
|
|
wire [7:0] rx_data_gps_port;
|
382 |
|
|
rxuart gpsrx(i_clk, 1'b0, gps_setup, i_gps_rx,
|
383 |
|
|
gpsrx_stb, rx_data_gps_port, gpsrx_break,
|
384 |
|
|
gpsrx_perr, gpsrx_ferr, gpsck_uart);
|
385 |
|
|
|
386 |
|
|
wire [31:0] gpsrx_data;
|
387 |
|
|
reg [11:0] r_gpsrx_data;
|
388 |
|
|
always @(posedge i_clk)
|
389 |
|
|
if (gpsrx_stb)
|
390 |
|
|
begin
|
391 |
|
|
r_gpsrx_data[11] <= gpsrx_break;
|
392 |
|
|
r_gpsrx_data[10] <= gpsrx_ferr;
|
393 |
|
|
r_gpsrx_data[ 9] <= gpsrx_perr;
|
394 |
|
|
r_gpsrx_data[7:0]<= rx_data_gps_port;
|
395 |
|
|
end
|
396 |
|
|
always @(posedge i_clk)
|
397 |
|
|
if(((i_wb_stb)&&(~i_wb_we)&&(i_wb_addr == 5'h0d))||(gpsrx_stb))
|
398 |
|
|
r_gpsrx_data[8] <= gpsrx_stb;
|
399 |
|
|
assign gpsrx_data = { 20'h00, r_gpsrx_data };
|
400 |
|
|
assign gpsrx_int = r_gpsrx_data[8];
|
401 |
|
|
|
402 |
|
|
|
403 |
|
|
// Then the transmitter
|
404 |
|
|
reg r_gpstx_break, r_gpstx_stb;
|
405 |
|
|
reg [7:0] r_gpstx_data;
|
406 |
|
|
wire gpstx_busy;
|
407 |
|
|
wire [31:0] gpstx_data;
|
408 |
|
|
txuart gpstx(i_clk, 1'b0, gps_setup,
|
409 |
|
|
r_gpstx_break, r_gpstx_stb, r_gpstx_data,
|
410 |
|
|
o_gps_tx, gpstx_busy);
|
411 |
|
|
always @(posedge i_clk)
|
412 |
|
|
if ((last_wb_stb)&&(last_wb_addr == 5'h0e))
|
413 |
|
|
begin
|
414 |
|
|
r_gpstx_stb <= 1'b1;
|
415 |
|
|
r_gpstx_data <= last_wb_data[7:0];
|
416 |
|
|
r_gpstx_break<= last_wb_data[9];
|
417 |
|
|
end else if (~gpstx_busy)
|
418 |
|
|
begin
|
419 |
|
|
r_gpstx_stb <= 1'b0;
|
420 |
|
|
r_gpstx_data <= 8'h0;
|
421 |
|
|
end
|
422 |
|
|
assign gpstx_data = { 20'h00,
|
423 |
|
|
gpsck_uart, o_gps_tx, r_gpstx_break, gpstx_busy,
|
424 |
|
|
r_gpstx_data };
|
425 |
|
|
|
426 |
|
|
always @(posedge i_clk)
|
427 |
|
|
case(i_wb_addr)
|
428 |
|
|
5'h00: o_wb_data <= `DATESTAMP;
|
429 |
|
|
5'h01: o_wb_data <= pic_data;
|
430 |
|
|
5'h02: o_wb_data <= i_buserr;
|
431 |
|
|
5'h03: o_wb_data <= pwr_counter;
|
432 |
|
|
5'h04: o_wb_data <= w_btnsw;
|
433 |
|
|
5'h05: o_wb_data <= w_ledreg;
|
434 |
|
|
5'h06: o_wb_data <= { 2'b00, aux_setup };
|
435 |
|
|
5'h07: o_wb_data <= { 2'b00, gps_setup };
|
436 |
|
|
5'h08: o_wb_data <= w_clr_led0;
|
437 |
|
|
5'h09: o_wb_data <= w_clr_led1;
|
438 |
|
|
5'h0a: o_wb_data <= w_clr_led2;
|
439 |
|
|
5'h0b: o_wb_data <= w_clr_led3;
|
440 |
|
|
5'h0c: o_wb_data <= date_data;
|
441 |
|
|
5'h0d: o_wb_data <= auxrx_data;
|
442 |
|
|
5'h0e: o_wb_data <= auxtx_data;
|
443 |
|
|
5'h10: o_wb_data <= gpsrx_data;
|
444 |
|
|
5'h11: o_wb_data <= gpstx_data;
|
445 |
|
|
// 5'hf: UART_SETUP
|
446 |
|
|
// 4'h6: GPIO
|
447 |
|
|
// ?? : GPS-UARTRX
|
448 |
|
|
// ?? : GPS-UARTTX
|
449 |
|
|
default: o_wb_data <= 32'h00;
|
450 |
|
|
endcase
|
451 |
|
|
|
452 |
|
|
assign o_wb_stall = 1'b0;
|
453 |
|
|
always @(posedge i_clk)
|
454 |
|
|
o_wb_ack <= (i_wb_stb);
|
455 |
|
|
assign o_board_ints = { gpio_int, auxrx_int, auxtx_int, gpsrx_int, sw_int, btn_int };
|
456 |
|
|
|
457 |
|
|
|
458 |
|
|
endmodule
|