1 |
3 |
dgisselq |
////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
//
|
3 |
|
|
// Filename: toplevel.v
|
4 |
|
|
//
|
5 |
|
|
// Project: OpenArty, an entirely open SoC based upon the Arty platform
|
6 |
|
|
//
|
7 |
|
|
// Purpose: This is the top level Verilog file. It is to be contrasted
|
8 |
|
|
// with the other top level Verilog file in this same project in
|
9 |
|
|
// that *this* top level is designed to create a *safe*, low-speed
|
10 |
25 |
dgisselq |
// (80MHz), configuration that can be used to test peripherals and other
|
11 |
|
|
// things on the way to building a full featured high speed (160MHz)
|
12 |
|
|
// configuration.
|
13 |
3 |
dgisselq |
//
|
14 |
|
|
// Differences between this file and fasttop.v should be limited to speed
|
15 |
|
|
// related differences (such as the number of counts per UART baud), and
|
16 |
|
|
// the different daughter module: fastmaster.v (for 200MHz designs) vs
|
17 |
|
|
// busmaster.v (for 100MHz designs).
|
18 |
|
|
//
|
19 |
|
|
// Creator: Dan Gisselquist, Ph.D.
|
20 |
|
|
// Gisselquist Technology, LLC
|
21 |
|
|
//
|
22 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
23 |
|
|
//
|
24 |
|
|
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
|
25 |
|
|
//
|
26 |
|
|
// This program is free software (firmware): you can redistribute it and/or
|
27 |
|
|
// modify it under the terms of the GNU General Public License as published
|
28 |
|
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
29 |
|
|
// your option) any later version.
|
30 |
|
|
//
|
31 |
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
32 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
33 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
34 |
|
|
// for more details.
|
35 |
|
|
//
|
36 |
|
|
// You should have received a copy of the GNU General Public License along
|
37 |
|
|
// with this program. (It's in the $(ROOT)/doc directory, run make with no
|
38 |
|
|
// target there if the PDF file isn't present.) If not, see
|
39 |
|
|
// <http://www.gnu.org/licenses/> for a copy.
|
40 |
|
|
//
|
41 |
|
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
42 |
|
|
// http://www.gnu.org/licenses/gpl.html
|
43 |
|
|
//
|
44 |
|
|
//
|
45 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
46 |
|
|
//
|
47 |
|
|
//
|
48 |
25 |
dgisselq |
module toplevel(sys_clk_i, i_reset_btn,
|
49 |
3 |
dgisselq |
i_sw, // Switches
|
50 |
|
|
i_btn, // Buttons
|
51 |
|
|
o_led, // Single color LEDs
|
52 |
|
|
o_clr_led0, o_clr_led1, o_clr_led2, o_clr_led3, // Color LEDs
|
53 |
|
|
// RS232 UART
|
54 |
|
|
i_uart_rx, o_uart_tx,
|
55 |
|
|
// Quad-SPI Flash control
|
56 |
|
|
o_qspi_sck, o_qspi_cs_n, io_qspi_dat,
|
57 |
30 |
dgisselq |
// Ethernet
|
58 |
|
|
o_eth_rstn, o_eth_ref_clk,
|
59 |
|
|
i_eth_rx_clk, i_eth_col, i_eth_crs, i_eth_rx_dv, i_eth_rxd, i_eth_rxerr,
|
60 |
|
|
i_eth_tx_clk, o_eth_tx_en, o_eth_txd,
|
61 |
|
|
// Ethernet (MDIO)
|
62 |
3 |
dgisselq |
o_eth_mdclk, io_eth_mdio,
|
63 |
|
|
// Memory
|
64 |
25 |
dgisselq |
ddr3_reset_n, ddr3_cke, ddr3_ck_p, ddr3_ck_n,
|
65 |
|
|
ddr3_cs_n, ddr3_ras_n, ddr3_cas_n, ddr3_we_n,
|
66 |
|
|
ddr3_dqs_p, ddr3_dqs_n,
|
67 |
|
|
ddr3_addr, ddr3_ba,
|
68 |
|
|
ddr3_dq, ddr3_dm, ddr3_odt,
|
69 |
3 |
dgisselq |
// SD Card
|
70 |
|
|
o_sd_sck, io_sd_cmd, io_sd, i_sd_cs, i_sd_wp,
|
71 |
|
|
// GPS Pmod
|
72 |
|
|
i_gps_pps, i_gps_3df, i_gps_rx, o_gps_tx,
|
73 |
|
|
// OLED Pmod
|
74 |
|
|
o_oled_sck, o_oled_cs_n, o_oled_mosi, o_oled_dcn, o_oled_reset_n,
|
75 |
|
|
o_oled_vccen, o_oled_pmoden,
|
76 |
|
|
// PMod I/O
|
77 |
50 |
dgisselq |
i_aux_rx, i_aux_cts_n, o_aux_tx, o_aux_rts_n,
|
78 |
|
|
// Chip-kit SPI port
|
79 |
|
|
o_ck_csn, o_ck_sck, o_ck_mosi
|
80 |
3 |
dgisselq |
);
|
81 |
25 |
dgisselq |
input [0:0] sys_clk_i;
|
82 |
|
|
input i_reset_btn;
|
83 |
3 |
dgisselq |
input [3:0] i_sw; // Switches
|
84 |
|
|
input [3:0] i_btn; // Buttons
|
85 |
|
|
output wire [3:0] o_led; // LED
|
86 |
|
|
output wire [2:0] o_clr_led0, o_clr_led1, o_clr_led2, o_clr_led3;
|
87 |
|
|
// UARTs
|
88 |
|
|
input i_uart_rx;
|
89 |
|
|
output wire o_uart_tx;
|
90 |
|
|
// Quad SPI flash
|
91 |
|
|
output wire o_qspi_sck, o_qspi_cs_n;
|
92 |
|
|
inout [3:0] io_qspi_dat;
|
93 |
30 |
dgisselq |
// Ethernet
|
94 |
|
|
output wire o_eth_rstn, o_eth_ref_clk;
|
95 |
|
|
input i_eth_rx_clk, i_eth_col, i_eth_crs, i_eth_rx_dv;
|
96 |
|
|
input [3:0] i_eth_rxd;
|
97 |
|
|
input i_eth_rxerr;
|
98 |
|
|
input i_eth_tx_clk;
|
99 |
|
|
output wire o_eth_tx_en;
|
100 |
|
|
output [3:0] o_eth_txd;
|
101 |
3 |
dgisselq |
// Ethernet control (MDIO)
|
102 |
|
|
output wire o_eth_mdclk;
|
103 |
|
|
inout wire io_eth_mdio;
|
104 |
|
|
// DDR3 SDRAM
|
105 |
25 |
dgisselq |
output wire ddr3_reset_n;
|
106 |
|
|
output wire [0:0] ddr3_cke;
|
107 |
|
|
output wire [0:0] ddr3_ck_p, ddr3_ck_n;
|
108 |
|
|
output wire [0:0] ddr3_cs_n;
|
109 |
|
|
output wire ddr3_ras_n, ddr3_cas_n, ddr3_we_n;
|
110 |
|
|
output wire [2:0] ddr3_ba;
|
111 |
|
|
output wire [13:0] ddr3_addr;
|
112 |
|
|
output wire [0:0] ddr3_odt;
|
113 |
|
|
output wire [1:0] ddr3_dm;
|
114 |
|
|
inout [1:0] ddr3_dqs_p, ddr3_dqs_n;
|
115 |
|
|
inout [15:0] ddr3_dq;
|
116 |
3 |
dgisselq |
//
|
117 |
|
|
// SD Card
|
118 |
|
|
output wire o_sd_sck;
|
119 |
|
|
inout io_sd_cmd;
|
120 |
|
|
inout [3:0] io_sd;
|
121 |
|
|
input i_sd_cs;
|
122 |
|
|
input i_sd_wp;
|
123 |
|
|
// GPS PMod
|
124 |
|
|
input i_gps_pps, i_gps_3df, i_gps_rx;
|
125 |
|
|
output wire o_gps_tx;
|
126 |
|
|
// OLEDRGB PMod
|
127 |
|
|
output wire o_oled_sck, o_oled_cs_n, o_oled_mosi,
|
128 |
|
|
o_oled_dcn, o_oled_reset_n, o_oled_vccen,
|
129 |
|
|
o_oled_pmoden;
|
130 |
|
|
// Aux UART
|
131 |
50 |
dgisselq |
input i_aux_rx, i_aux_cts_n;
|
132 |
|
|
output wire o_aux_tx, o_aux_rts_n;
|
133 |
|
|
output wire o_ck_csn, o_ck_sck, o_ck_mosi;
|
134 |
3 |
dgisselq |
|
135 |
30 |
dgisselq |
wire eth_tx_clk, eth_rx_clk;
|
136 |
|
|
`ifdef VERILATOR
|
137 |
|
|
wire s_clk, s_reset;
|
138 |
|
|
assign s_clk = sys_clk_i;
|
139 |
|
|
|
140 |
|
|
assign eth_tx_clk = i_eth_tx_clk;
|
141 |
|
|
assign eth_rx_clk = i_eth_rx_clk;
|
142 |
|
|
|
143 |
|
|
`else
|
144 |
3 |
dgisselq |
// Build our master clock
|
145 |
25 |
dgisselq |
wire s_clk, sys_clk, mem_clk_200mhz,
|
146 |
|
|
clk1_unused, clk2_unused, enet_clk, clk4_unnused,
|
147 |
|
|
clk5_unused, clk_feedback, clk_locked, mem_clk_200mhz_nobuf;
|
148 |
3 |
dgisselq |
PLLE2_BASE #(
|
149 |
|
|
.BANDWIDTH("OPTIMIZED"), // OPTIMIZED, HIGH, LOW
|
150 |
|
|
.CLKFBOUT_PHASE(0.0), // Phase offset in degrees of CLKFB, (-360-360)
|
151 |
25 |
dgisselq |
.CLKIN1_PERIOD(10.0), // Input clock period in ns resolution
|
152 |
3 |
dgisselq |
// CLKOUT0_DIVIDE - CLKOUT5_DIVIDE: divide amount for each CLKOUT(1-128)
|
153 |
|
|
.CLKFBOUT_MULT(8), // Multiply value for all CLKOUT (2-64)
|
154 |
25 |
dgisselq |
.CLKOUT0_DIVIDE(8), // 100 MHz (Clock for MIG)
|
155 |
|
|
.CLKOUT1_DIVIDE(4), // 200 MHz (MIG Reference clock)
|
156 |
30 |
dgisselq |
.CLKOUT2_DIVIDE(16), // 50 MHz (Unused)
|
157 |
|
|
.CLKOUT3_DIVIDE(32), // 25 MHz (Ethernet reference clk)
|
158 |
25 |
dgisselq |
.CLKOUT4_DIVIDE(32), // 50 MHz (Unused clock?)
|
159 |
|
|
.CLKOUT5_DIVIDE(24), // 66 MHz
|
160 |
3 |
dgisselq |
// CLKOUT0_DUTY_CYCLE -- Duty cycle for each CLKOUT
|
161 |
|
|
.CLKOUT0_DUTY_CYCLE(0.5),
|
162 |
|
|
.CLKOUT1_DUTY_CYCLE(0.5),
|
163 |
|
|
.CLKOUT2_DUTY_CYCLE(0.5),
|
164 |
|
|
.CLKOUT3_DUTY_CYCLE(0.5),
|
165 |
|
|
.CLKOUT4_DUTY_CYCLE(0.5),
|
166 |
|
|
.CLKOUT5_DUTY_CYCLE(0.5),
|
167 |
|
|
// CLKOUT0_PHASE -- phase offset for each CLKOUT
|
168 |
|
|
.CLKOUT0_PHASE(0.0),
|
169 |
25 |
dgisselq |
.CLKOUT1_PHASE(0.0),
|
170 |
3 |
dgisselq |
.CLKOUT2_PHASE(0.0),
|
171 |
|
|
.CLKOUT3_PHASE(0.0),
|
172 |
|
|
.CLKOUT4_PHASE(0.0),
|
173 |
|
|
.CLKOUT5_PHASE(0.0),
|
174 |
|
|
.DIVCLK_DIVIDE(1), // Master division value , (1-56)
|
175 |
25 |
dgisselq |
.REF_JITTER1(0.0), // Ref. input jitter in UI (0.000-0.999)
|
176 |
|
|
.STARTUP_WAIT("TRUE") // Delay DONE until PLL Locks, ("TRUE"/"FALSE")
|
177 |
3 |
dgisselq |
) genclock(
|
178 |
|
|
// Clock outputs: 1-bit (each) output
|
179 |
25 |
dgisselq |
.CLKOUT0(mem_clk_nobuf),
|
180 |
|
|
.CLKOUT1(mem_clk_200mhz_nobuf),
|
181 |
|
|
.CLKOUT2(clk2_unused),
|
182 |
3 |
dgisselq |
.CLKOUT3(enet_clk),
|
183 |
|
|
.CLKOUT4(clk4_unused),
|
184 |
|
|
.CLKOUT5(clk5_unused),
|
185 |
|
|
.CLKFBOUT(clk_feedback), // 1-bit output, feedback clock
|
186 |
|
|
.LOCKED(clk_locked),
|
187 |
25 |
dgisselq |
.CLKIN1(sys_clk),
|
188 |
3 |
dgisselq |
.PWRDWN(1'b0),
|
189 |
|
|
.RST(1'b0),
|
190 |
25 |
dgisselq |
.CLKFBIN(clk_feedback_bufd) // 1-bit input, feedback clock
|
191 |
3 |
dgisselq |
);
|
192 |
25 |
dgisselq |
|
193 |
|
|
BUFH feedback_buffer(.I(clk_feedback),.O(clk_feedback_bufd));
|
194 |
|
|
// BUFG memref_buffer(.I(mem_clk_200mhz_nobuf),.O(mem_clk_200mhz));
|
195 |
|
|
IBUF sysclk_buf(.I(sys_clk_i[0]), .O(sys_clk));
|
196 |
|
|
|
197 |
30 |
dgisselq |
BUFG eth_rx(.I(i_eth_rx_clk), .O(eth_rx_clk));
|
198 |
|
|
// assign eth_rx_clk = i_eth_rx_clk;
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
BUFG eth_tx(.I(i_eth_tx_clk), .O(eth_tx_clk));
|
202 |
|
|
// assign eth_tx_clk = i_eth_tx_clk;
|
203 |
|
|
`endif
|
204 |
|
|
|
205 |
25 |
dgisselq |
//
|
206 |
|
|
//
|
207 |
3 |
dgisselq |
// UART interface
|
208 |
25 |
dgisselq |
//
|
209 |
|
|
//
|
210 |
50 |
dgisselq |
// localparam BUSUART = 30'h50000014; // ~4MBaud, 7 bits, no flwctrl
|
211 |
|
|
localparam BUSUART = 31'h50000051; // ~1MBaud, 7 bits, no flwctrl
|
212 |
|
|
wire [30:0] bus_uart_setup;
|
213 |
|
|
assign bus_uart_setup = BUSUART;
|
214 |
3 |
dgisselq |
|
215 |
|
|
wire [7:0] rx_data, tx_data;
|
216 |
|
|
wire rx_break, rx_parity_err, rx_frame_err, rx_stb;
|
217 |
|
|
wire tx_stb, tx_busy;
|
218 |
|
|
|
219 |
25 |
dgisselq |
//
|
220 |
|
|
// RESET LOGIC
|
221 |
|
|
//
|
222 |
|
|
// Okay, so this looks bad at a first read--but it's not really that
|
223 |
|
|
// bad. If you look close, there are two parts to the reset logic.
|
224 |
|
|
// The first is the "PRE"-reset. This is a wire, set from the external
|
225 |
|
|
// reset button. In good old-fashioned asynch-logic to synchronous
|
226 |
|
|
// logic fashion, we synchronize this wire by registering it first
|
227 |
|
|
// to pre_reset, and then to pwr_reset (the actual reset wire).
|
228 |
|
|
//
|
229 |
30 |
dgisselq |
wire s_reset; // Ultimate system reset wire
|
230 |
25 |
dgisselq |
reg [7:0] pre_reset;
|
231 |
|
|
reg pwr_reset;
|
232 |
|
|
// Since all our stuff is synchronous to the clock that comes out of
|
233 |
|
|
// the memory controller, sys_reset must needs come out of the memory
|
234 |
|
|
// controller.
|
235 |
|
|
//
|
236 |
|
|
// Logic description starts with the PRE-reset, so as to make certain
|
237 |
|
|
// we include the reset button. The memory controller wants an active
|
238 |
|
|
// low reset here, so we provide such.
|
239 |
3 |
dgisselq |
initial pre_reset = 1'b0;
|
240 |
25 |
dgisselq |
always @(posedge sys_clk)
|
241 |
|
|
pre_reset <= ((!i_reset_btn)||(!clk_locked))
|
242 |
|
|
? 8'h00 : {pre_reset[6:0], 1'b1};
|
243 |
|
|
//
|
244 |
|
|
// and then continues with the actual reset, now that we've
|
245 |
|
|
// synchronized our reset button wire. This is an active LOW reset.
|
246 |
|
|
initial pwr_reset = 1'b0;
|
247 |
|
|
always @(posedge sys_clk)
|
248 |
|
|
pwr_reset <= pre_reset[7];
|
249 |
30 |
dgisselq |
`ifdef VERILATOR
|
250 |
|
|
assign s_reset = pwr_reset;
|
251 |
|
|
`else
|
252 |
25 |
dgisselq |
//
|
253 |
|
|
// Of course, this only goes into the memory controller. The true
|
254 |
|
|
// device reset comes out of that memory controller, synchronized to
|
255 |
|
|
// our memory generator provided clock(s)
|
256 |
30 |
dgisselq |
`endif
|
257 |
3 |
dgisselq |
|
258 |
|
|
wire w_ck_uart, w_uart_tx;
|
259 |
50 |
dgisselq |
rxuart #(BUSUART) rcv(s_clk, s_reset, bus_uart_setup, i_uart_rx,
|
260 |
3 |
dgisselq |
rx_stb, rx_data, rx_break,
|
261 |
|
|
rx_parity_err, rx_frame_err, w_ck_uart);
|
262 |
50 |
dgisselq |
txuart #(BUSUART) txv(s_clk, s_reset, bus_uart_setup, 1'b0,
|
263 |
|
|
tx_stb, tx_data, 1'b1, o_uart_tx, tx_busy);
|
264 |
3 |
dgisselq |
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
|
268 |
|
|
//////
|
269 |
|
|
//
|
270 |
|
|
//
|
271 |
|
|
// The WB bus interconnect, herein called busmaster, which handles
|
272 |
|
|
// just about ... everything. It is in contrast to the other WB bus
|
273 |
|
|
// interconnect, fastmaster, in that the busmaster build permits
|
274 |
25 |
dgisselq |
// peripherals that can *only* operate at 80MHz, no faster, no slower.
|
275 |
3 |
dgisselq |
//
|
276 |
|
|
//
|
277 |
|
|
//////
|
278 |
25 |
dgisselq |
wire w_qspi_sck, w_qspi_cs_n;
|
279 |
3 |
dgisselq |
wire [1:0] qspi_bmod;
|
280 |
|
|
wire [3:0] qspi_dat;
|
281 |
|
|
wire [3:0] i_qspi_dat;
|
282 |
|
|
|
283 |
50 |
dgisselq |
|
284 |
|
|
wire [1:0] i_gpio;
|
285 |
|
|
wire [3:0] o_gpio;
|
286 |
|
|
assign i_gpio = { o_aux_rts_n, i_aux_cts_n };
|
287 |
|
|
|
288 |
3 |
dgisselq |
//
|
289 |
25 |
dgisselq |
// The SDRAM interface wires
|
290 |
3 |
dgisselq |
//
|
291 |
25 |
dgisselq |
wire ram_cyc, ram_stb, ram_we;
|
292 |
|
|
wire [25:0] ram_addr;
|
293 |
|
|
wire [31:0] ram_rdata, ram_wdata;
|
294 |
50 |
dgisselq |
wire [3:0] ram_sel;
|
295 |
25 |
dgisselq |
wire ram_ack, ram_stall, ram_err;
|
296 |
|
|
wire [31:0] ram_dbg;
|
297 |
|
|
//
|
298 |
3 |
dgisselq |
wire w_mdio, w_mdwe;
|
299 |
|
|
//
|
300 |
|
|
wire w_sd_cmd;
|
301 |
|
|
wire [3:0] w_sd_data;
|
302 |
50 |
dgisselq |
busmaster
|
303 |
|
|
#(
|
304 |
|
|
.NGPI(2), .NGPO(4)
|
305 |
|
|
) wbbus(s_clk, s_reset,
|
306 |
3 |
dgisselq |
// External USB-UART bus control
|
307 |
|
|
rx_stb, rx_data, tx_stb, tx_data, tx_busy,
|
308 |
|
|
// Board lights and switches
|
309 |
50 |
dgisselq |
i_sw, i_btn, o_led,
|
310 |
3 |
dgisselq |
o_clr_led0, o_clr_led1, o_clr_led2, o_clr_led3,
|
311 |
|
|
// Board level PMod I/O
|
312 |
50 |
dgisselq |
i_aux_rx, o_aux_tx, i_aux_cts_n, o_aux_rts_n,i_gps_rx, o_gps_tx,
|
313 |
3 |
dgisselq |
// Quad SPI flash
|
314 |
25 |
dgisselq |
w_qspi_cs_n, w_qspi_sck, qspi_dat, i_qspi_dat, qspi_bmod,
|
315 |
3 |
dgisselq |
// DDR3 SDRAM
|
316 |
25 |
dgisselq |
// o_ddr_reset_n, o_ddr_cke, o_ddr_ck_p, o_ddr_ck_n,
|
317 |
|
|
// o_ddr_cs_n, o_ddr_ras_n, o_ddr_cas_n, o_ddr_we_n,
|
318 |
|
|
// o_ddr_ba, o_ddr_addr, o_ddr_odt, o_ddr_dm,
|
319 |
|
|
// io_ddr_dqs_p, io_ddr_dqs_n, io_ddr_data,
|
320 |
50 |
dgisselq |
ram_cyc, ram_stb, ram_we, ram_addr, ram_wdata, ram_sel,
|
321 |
25 |
dgisselq |
ram_ack, ram_stall, ram_rdata, ram_err,
|
322 |
|
|
ram_dbg,
|
323 |
3 |
dgisselq |
// SD Card
|
324 |
|
|
o_sd_sck, w_sd_cmd, w_sd_data, io_sd_cmd, io_sd, i_sd_cs,
|
325 |
30 |
dgisselq |
// Ethernet
|
326 |
|
|
o_eth_rstn,
|
327 |
|
|
eth_rx_clk, i_eth_col, i_eth_crs, i_eth_rx_dv,
|
328 |
|
|
i_eth_rxd, i_eth_rxerr,
|
329 |
|
|
eth_tx_clk, o_eth_tx_en, o_eth_txd,
|
330 |
3 |
dgisselq |
// Ethernet control (MDIO) lines
|
331 |
|
|
o_eth_mdclk, w_mdio, w_mdwe, io_eth_mdio,
|
332 |
|
|
// OLEDRGB PMod wires
|
333 |
|
|
o_oled_sck, o_oled_cs_n, o_oled_mosi, o_oled_dcn,
|
334 |
|
|
o_oled_reset_n, o_oled_vccen, o_oled_pmoden,
|
335 |
|
|
// GPS PMod
|
336 |
50 |
dgisselq |
i_gps_pps, i_gps_3df,
|
337 |
|
|
// Other GPIO wires
|
338 |
|
|
i_gpio, o_gpio
|
339 |
3 |
dgisselq |
);
|
340 |
|
|
|
341 |
|
|
//////
|
342 |
|
|
//
|
343 |
|
|
//
|
344 |
|
|
// The rest of this file *should* be identical to fasttop.v. Any
|
345 |
|
|
// differences should be worked out with meld or some such program
|
346 |
|
|
// to keep them to a minimum.
|
347 |
|
|
//
|
348 |
|
|
//
|
349 |
|
|
// Some wires need special treatment, and so are not quite completely
|
350 |
|
|
// handled by the bus master. These are handled below.
|
351 |
|
|
//
|
352 |
|
|
//
|
353 |
|
|
//////
|
354 |
|
|
|
355 |
|
|
//
|
356 |
|
|
//
|
357 |
|
|
// QSPI)BMOD, Quad SPI bus mode, Bus modes are:
|
358 |
|
|
// 0? Normal serial mode, one bit in one bit out
|
359 |
|
|
// 10 Quad SPI mode, going out
|
360 |
|
|
// 11 Quad SPI mode coming from the device (read mode)
|
361 |
|
|
//
|
362 |
|
|
// ?? Dual mode in (not yet)
|
363 |
|
|
// ?? Dual mode out (not yet)
|
364 |
|
|
//
|
365 |
|
|
//
|
366 |
25 |
dgisselq |
wire [3:0] i_qspi_pedge, i_qspi_nedge;
|
367 |
|
|
|
368 |
30 |
dgisselq |
`ifdef VERILATOR
|
369 |
|
|
assign o_qspi_sck = w_qspi_sck;
|
370 |
|
|
assign o_qspi_cs_n = w_qspi_cs_n;
|
371 |
|
|
;
|
372 |
|
|
();
|
373 |
|
|
[*];
|
374 |
|
|
`else
|
375 |
25 |
dgisselq |
xoddr xqspi_sck( s_clk, { w_qspi_sck, w_qspi_sck }, o_qspi_sck);
|
376 |
|
|
xoddr xqspi_csn( s_clk, { w_qspi_cs_n, w_qspi_cs_n },o_qspi_cs_n);
|
377 |
|
|
//
|
378 |
|
|
xioddr xqspi_d0( s_clk, (qspi_bmod != 2'b11),
|
379 |
3 |
dgisselq |
{ qspi_dat[0], qspi_dat[0] },
|
380 |
25 |
dgisselq |
{ i_qspi_pedge[0], i_qspi_nedge[0] }, io_qspi_dat[0]);
|
381 |
|
|
xioddr xqspi_d1( s_clk, (qspi_bmod==2'b10),
|
382 |
3 |
dgisselq |
{ qspi_dat[1], qspi_dat[1] },
|
383 |
25 |
dgisselq |
{ i_qspi_pedge[1], i_qspi_nedge[1] }, io_qspi_dat[1]);
|
384 |
|
|
xioddr xqspi_d2( s_clk, (qspi_bmod!=2'b11),
|
385 |
|
|
(qspi_bmod[1])?{ qspi_dat[2], qspi_dat[2] }:2'b11,
|
386 |
|
|
{ i_qspi_pedge[2], i_qspi_nedge[2] }, io_qspi_dat[2]);
|
387 |
|
|
xioddr xqspi_d3( s_clk, (qspi_bmod!=2'b11),
|
388 |
|
|
(qspi_bmod[1])?{ qspi_dat[3], qspi_dat[3] }:2'b11,
|
389 |
|
|
{ i_qspi_pedge[3], i_qspi_nedge[3] }, io_qspi_dat[3]);
|
390 |
30 |
dgisselq |
`endif
|
391 |
|
|
reg [3:0] r_qspi_dat;
|
392 |
|
|
always @(posedge s_clk)
|
393 |
|
|
r_qspi_dat <= i_qspi_pedge;
|
394 |
|
|
assign i_qspi_dat = r_qspi_dat;
|
395 |
3 |
dgisselq |
|
396 |
|
|
//
|
397 |
|
|
// Proposed QSPI mode select, to allow dual I/O mode
|
398 |
|
|
// 000 Normal SPI mode
|
399 |
|
|
// 001 Dual mode input
|
400 |
|
|
// 010 Dual mode, output
|
401 |
|
|
// 101 Quad I/O mode input
|
402 |
|
|
// 110 Quad I/O mode output
|
403 |
|
|
//
|
404 |
|
|
//
|
405 |
|
|
|
406 |
|
|
|
407 |
|
|
//
|
408 |
|
|
//
|
409 |
30 |
dgisselq |
// Generate a reference clock for the network
|
410 |
|
|
//
|
411 |
|
|
//
|
412 |
|
|
`ifdef VERILATOR
|
413 |
|
|
assign o_eth_ref_clk = i_eth_tx_clk;
|
414 |
|
|
`else
|
415 |
|
|
xoddr e_ref_clk( enet_clk, { 1'b1, 1'b0 }, o_eth_ref_clk );
|
416 |
|
|
`endif
|
417 |
|
|
|
418 |
|
|
//
|
419 |
|
|
//
|
420 |
3 |
dgisselq |
// Wires for setting up the SD Card Controller
|
421 |
|
|
//
|
422 |
|
|
//
|
423 |
|
|
assign io_sd_cmd = w_sd_cmd ? 1'bz:1'b0;
|
424 |
|
|
assign io_sd[0] = w_sd_data[0]? 1'bz:1'b0;
|
425 |
|
|
assign io_sd[1] = w_sd_data[1]? 1'bz:1'b0;
|
426 |
|
|
assign io_sd[2] = w_sd_data[2]? 1'bz:1'b0;
|
427 |
|
|
assign io_sd[3] = w_sd_data[3]? 1'bz:1'b0;
|
428 |
|
|
|
429 |
|
|
|
430 |
|
|
//
|
431 |
|
|
//
|
432 |
|
|
// Wire(s) for setting up the MDIO ethernet control structure
|
433 |
|
|
//
|
434 |
|
|
//
|
435 |
|
|
assign io_eth_mdio = (w_mdwe)?w_mdio : 1'bz;
|
436 |
|
|
|
437 |
|
|
//
|
438 |
|
|
//
|
439 |
25 |
dgisselq |
// Now, to set up our memory ...
|
440 |
3 |
dgisselq |
//
|
441 |
|
|
//
|
442 |
30 |
dgisselq |
migsdram #(.AXIDWIDTH(5)) rami(
|
443 |
25 |
dgisselq |
.i_clk(mem_clk_nobuf), .i_clk_200mhz(mem_clk_200mhz_nobuf),
|
444 |
|
|
.o_sys_clk(s_clk), .i_rst(pwr_reset), .o_sys_reset(s_reset),
|
445 |
|
|
.i_wb_cyc(ram_cyc), .i_wb_stb(ram_stb), .i_wb_we(ram_we),
|
446 |
|
|
.i_wb_addr(ram_addr), .i_wb_data(ram_wdata),
|
447 |
50 |
dgisselq |
.i_wb_sel(ram_sel),
|
448 |
25 |
dgisselq |
.o_wb_ack(ram_ack), .o_wb_stall(ram_stall),
|
449 |
|
|
.o_wb_data(ram_rdata), .o_wb_err(ram_err),
|
450 |
|
|
.o_ddr_ck_p(ddr3_ck_p), .o_ddr_ck_n(ddr3_ck_n),
|
451 |
|
|
.o_ddr_reset_n(ddr3_reset_n), .o_ddr_cke(ddr3_cke),
|
452 |
|
|
.o_ddr_cs_n(ddr3_cs_n), .o_ddr_ras_n(ddr3_ras_n),
|
453 |
|
|
.o_ddr_cas_n(ddr3_cas_n), .o_ddr_we_n(ddr3_we_n),
|
454 |
|
|
.o_ddr_ba(ddr3_ba), .o_ddr_addr(ddr3_addr),
|
455 |
|
|
.o_ddr_odt(ddr3_odt), .o_ddr_dm(ddr3_dm),
|
456 |
|
|
.io_ddr_dqs_p(ddr3_dqs_p), .io_ddr_dqs_n(ddr3_dqs_n),
|
457 |
|
|
.io_ddr_data(ddr3_dq),
|
458 |
|
|
//
|
459 |
|
|
.o_ram_dbg(ram_dbg)
|
460 |
|
|
);
|
461 |
3 |
dgisselq |
|
462 |
|
|
endmodule
|
463 |
|
|
|