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 |
|
|
i_aux_rx, i_aux_rts, o_aux_tx, o_aux_cts
|
78 |
|
|
);
|
79 |
25 |
dgisselq |
input [0:0] sys_clk_i;
|
80 |
|
|
input i_reset_btn;
|
81 |
3 |
dgisselq |
input [3:0] i_sw; // Switches
|
82 |
|
|
input [3:0] i_btn; // Buttons
|
83 |
|
|
output wire [3:0] o_led; // LED
|
84 |
|
|
output wire [2:0] o_clr_led0, o_clr_led1, o_clr_led2, o_clr_led3;
|
85 |
|
|
// UARTs
|
86 |
|
|
input i_uart_rx;
|
87 |
|
|
output wire o_uart_tx;
|
88 |
|
|
// Quad SPI flash
|
89 |
|
|
output wire o_qspi_sck, o_qspi_cs_n;
|
90 |
|
|
inout [3:0] io_qspi_dat;
|
91 |
30 |
dgisselq |
// Ethernet
|
92 |
|
|
output wire o_eth_rstn, o_eth_ref_clk;
|
93 |
|
|
input i_eth_rx_clk, i_eth_col, i_eth_crs, i_eth_rx_dv;
|
94 |
|
|
input [3:0] i_eth_rxd;
|
95 |
|
|
input i_eth_rxerr;
|
96 |
|
|
input i_eth_tx_clk;
|
97 |
|
|
output wire o_eth_tx_en;
|
98 |
|
|
output [3:0] o_eth_txd;
|
99 |
3 |
dgisselq |
// Ethernet control (MDIO)
|
100 |
|
|
output wire o_eth_mdclk;
|
101 |
|
|
inout wire io_eth_mdio;
|
102 |
|
|
// DDR3 SDRAM
|
103 |
25 |
dgisselq |
output wire ddr3_reset_n;
|
104 |
|
|
output wire [0:0] ddr3_cke;
|
105 |
|
|
output wire [0:0] ddr3_ck_p, ddr3_ck_n;
|
106 |
|
|
output wire [0:0] ddr3_cs_n;
|
107 |
|
|
output wire ddr3_ras_n, ddr3_cas_n, ddr3_we_n;
|
108 |
|
|
output wire [2:0] ddr3_ba;
|
109 |
|
|
output wire [13:0] ddr3_addr;
|
110 |
|
|
output wire [0:0] ddr3_odt;
|
111 |
|
|
output wire [1:0] ddr3_dm;
|
112 |
|
|
inout [1:0] ddr3_dqs_p, ddr3_dqs_n;
|
113 |
|
|
inout [15:0] ddr3_dq;
|
114 |
3 |
dgisselq |
//
|
115 |
|
|
// SD Card
|
116 |
|
|
output wire o_sd_sck;
|
117 |
|
|
inout io_sd_cmd;
|
118 |
|
|
inout [3:0] io_sd;
|
119 |
|
|
input i_sd_cs;
|
120 |
|
|
input i_sd_wp;
|
121 |
|
|
// GPS PMod
|
122 |
|
|
input i_gps_pps, i_gps_3df, i_gps_rx;
|
123 |
|
|
output wire o_gps_tx;
|
124 |
|
|
// OLEDRGB PMod
|
125 |
|
|
output wire o_oled_sck, o_oled_cs_n, o_oled_mosi,
|
126 |
|
|
o_oled_dcn, o_oled_reset_n, o_oled_vccen,
|
127 |
|
|
o_oled_pmoden;
|
128 |
|
|
// Aux UART
|
129 |
|
|
input i_aux_rx, i_aux_rts;
|
130 |
|
|
output wire o_aux_tx, o_aux_cts;
|
131 |
|
|
|
132 |
30 |
dgisselq |
wire eth_tx_clk, eth_rx_clk;
|
133 |
|
|
`ifdef VERILATOR
|
134 |
|
|
wire s_clk, s_reset;
|
135 |
|
|
assign s_clk = sys_clk_i;
|
136 |
|
|
|
137 |
|
|
assign eth_tx_clk = i_eth_tx_clk;
|
138 |
|
|
assign eth_rx_clk = i_eth_rx_clk;
|
139 |
|
|
|
140 |
|
|
`else
|
141 |
3 |
dgisselq |
// Build our master clock
|
142 |
25 |
dgisselq |
wire s_clk, sys_clk, mem_clk_200mhz,
|
143 |
|
|
clk1_unused, clk2_unused, enet_clk, clk4_unnused,
|
144 |
|
|
clk5_unused, clk_feedback, clk_locked, mem_clk_200mhz_nobuf;
|
145 |
3 |
dgisselq |
PLLE2_BASE #(
|
146 |
|
|
.BANDWIDTH("OPTIMIZED"), // OPTIMIZED, HIGH, LOW
|
147 |
|
|
.CLKFBOUT_PHASE(0.0), // Phase offset in degrees of CLKFB, (-360-360)
|
148 |
25 |
dgisselq |
.CLKIN1_PERIOD(10.0), // Input clock period in ns resolution
|
149 |
3 |
dgisselq |
// CLKOUT0_DIVIDE - CLKOUT5_DIVIDE: divide amount for each CLKOUT(1-128)
|
150 |
|
|
.CLKFBOUT_MULT(8), // Multiply value for all CLKOUT (2-64)
|
151 |
25 |
dgisselq |
.CLKOUT0_DIVIDE(8), // 100 MHz (Clock for MIG)
|
152 |
|
|
.CLKOUT1_DIVIDE(4), // 200 MHz (MIG Reference clock)
|
153 |
30 |
dgisselq |
.CLKOUT2_DIVIDE(16), // 50 MHz (Unused)
|
154 |
|
|
.CLKOUT3_DIVIDE(32), // 25 MHz (Ethernet reference clk)
|
155 |
25 |
dgisselq |
.CLKOUT4_DIVIDE(32), // 50 MHz (Unused clock?)
|
156 |
|
|
.CLKOUT5_DIVIDE(24), // 66 MHz
|
157 |
3 |
dgisselq |
// CLKOUT0_DUTY_CYCLE -- Duty cycle for each CLKOUT
|
158 |
|
|
.CLKOUT0_DUTY_CYCLE(0.5),
|
159 |
|
|
.CLKOUT1_DUTY_CYCLE(0.5),
|
160 |
|
|
.CLKOUT2_DUTY_CYCLE(0.5),
|
161 |
|
|
.CLKOUT3_DUTY_CYCLE(0.5),
|
162 |
|
|
.CLKOUT4_DUTY_CYCLE(0.5),
|
163 |
|
|
.CLKOUT5_DUTY_CYCLE(0.5),
|
164 |
|
|
// CLKOUT0_PHASE -- phase offset for each CLKOUT
|
165 |
|
|
.CLKOUT0_PHASE(0.0),
|
166 |
25 |
dgisselq |
.CLKOUT1_PHASE(0.0),
|
167 |
3 |
dgisselq |
.CLKOUT2_PHASE(0.0),
|
168 |
|
|
.CLKOUT3_PHASE(0.0),
|
169 |
|
|
.CLKOUT4_PHASE(0.0),
|
170 |
|
|
.CLKOUT5_PHASE(0.0),
|
171 |
|
|
.DIVCLK_DIVIDE(1), // Master division value , (1-56)
|
172 |
25 |
dgisselq |
.REF_JITTER1(0.0), // Ref. input jitter in UI (0.000-0.999)
|
173 |
|
|
.STARTUP_WAIT("TRUE") // Delay DONE until PLL Locks, ("TRUE"/"FALSE")
|
174 |
3 |
dgisselq |
) genclock(
|
175 |
|
|
// Clock outputs: 1-bit (each) output
|
176 |
25 |
dgisselq |
.CLKOUT0(mem_clk_nobuf),
|
177 |
|
|
.CLKOUT1(mem_clk_200mhz_nobuf),
|
178 |
|
|
.CLKOUT2(clk2_unused),
|
179 |
3 |
dgisselq |
.CLKOUT3(enet_clk),
|
180 |
|
|
.CLKOUT4(clk4_unused),
|
181 |
|
|
.CLKOUT5(clk5_unused),
|
182 |
|
|
.CLKFBOUT(clk_feedback), // 1-bit output, feedback clock
|
183 |
|
|
.LOCKED(clk_locked),
|
184 |
25 |
dgisselq |
.CLKIN1(sys_clk),
|
185 |
3 |
dgisselq |
.PWRDWN(1'b0),
|
186 |
|
|
.RST(1'b0),
|
187 |
25 |
dgisselq |
.CLKFBIN(clk_feedback_bufd) // 1-bit input, feedback clock
|
188 |
3 |
dgisselq |
);
|
189 |
25 |
dgisselq |
|
190 |
|
|
BUFH feedback_buffer(.I(clk_feedback),.O(clk_feedback_bufd));
|
191 |
|
|
// BUFG memref_buffer(.I(mem_clk_200mhz_nobuf),.O(mem_clk_200mhz));
|
192 |
|
|
IBUF sysclk_buf(.I(sys_clk_i[0]), .O(sys_clk));
|
193 |
|
|
|
194 |
30 |
dgisselq |
BUFG eth_rx(.I(i_eth_rx_clk), .O(eth_rx_clk));
|
195 |
|
|
// assign eth_rx_clk = i_eth_rx_clk;
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
BUFG eth_tx(.I(i_eth_tx_clk), .O(eth_tx_clk));
|
199 |
|
|
// assign eth_tx_clk = i_eth_tx_clk;
|
200 |
|
|
`endif
|
201 |
|
|
|
202 |
25 |
dgisselq |
//
|
203 |
|
|
//
|
204 |
3 |
dgisselq |
// UART interface
|
205 |
25 |
dgisselq |
//
|
206 |
|
|
//
|
207 |
3 |
dgisselq |
wire [29:0] bus_uart_setup;
|
208 |
25 |
dgisselq |
// assign bus_uart_setup = 30'h10000014; // ~4MBaud, 7 bits
|
209 |
|
|
assign bus_uart_setup = 30'h10000051; // ~1MBaud, 7 bits
|
210 |
3 |
dgisselq |
|
211 |
|
|
wire [7:0] rx_data, tx_data;
|
212 |
|
|
wire rx_break, rx_parity_err, rx_frame_err, rx_stb;
|
213 |
|
|
wire tx_stb, tx_busy;
|
214 |
|
|
|
215 |
25 |
dgisselq |
//
|
216 |
|
|
// RESET LOGIC
|
217 |
|
|
//
|
218 |
|
|
// Okay, so this looks bad at a first read--but it's not really that
|
219 |
|
|
// bad. If you look close, there are two parts to the reset logic.
|
220 |
|
|
// The first is the "PRE"-reset. This is a wire, set from the external
|
221 |
|
|
// reset button. In good old-fashioned asynch-logic to synchronous
|
222 |
|
|
// logic fashion, we synchronize this wire by registering it first
|
223 |
|
|
// to pre_reset, and then to pwr_reset (the actual reset wire).
|
224 |
|
|
//
|
225 |
30 |
dgisselq |
wire s_reset; // Ultimate system reset wire
|
226 |
25 |
dgisselq |
reg [7:0] pre_reset;
|
227 |
|
|
reg pwr_reset;
|
228 |
|
|
// Since all our stuff is synchronous to the clock that comes out of
|
229 |
|
|
// the memory controller, sys_reset must needs come out of the memory
|
230 |
|
|
// controller.
|
231 |
|
|
//
|
232 |
|
|
// Logic description starts with the PRE-reset, so as to make certain
|
233 |
|
|
// we include the reset button. The memory controller wants an active
|
234 |
|
|
// low reset here, so we provide such.
|
235 |
3 |
dgisselq |
initial pre_reset = 1'b0;
|
236 |
25 |
dgisselq |
always @(posedge sys_clk)
|
237 |
|
|
pre_reset <= ((!i_reset_btn)||(!clk_locked))
|
238 |
|
|
? 8'h00 : {pre_reset[6:0], 1'b1};
|
239 |
|
|
//
|
240 |
|
|
// and then continues with the actual reset, now that we've
|
241 |
|
|
// synchronized our reset button wire. This is an active LOW reset.
|
242 |
|
|
initial pwr_reset = 1'b0;
|
243 |
|
|
always @(posedge sys_clk)
|
244 |
|
|
pwr_reset <= pre_reset[7];
|
245 |
30 |
dgisselq |
`ifdef VERILATOR
|
246 |
|
|
assign s_reset = pwr_reset;
|
247 |
|
|
`else
|
248 |
25 |
dgisselq |
//
|
249 |
|
|
// Of course, this only goes into the memory controller. The true
|
250 |
|
|
// device reset comes out of that memory controller, synchronized to
|
251 |
|
|
// our memory generator provided clock(s)
|
252 |
30 |
dgisselq |
`endif
|
253 |
3 |
dgisselq |
|
254 |
|
|
wire w_ck_uart, w_uart_tx;
|
255 |
25 |
dgisselq |
rxuart rcv(s_clk, s_reset, bus_uart_setup, i_uart_rx,
|
256 |
3 |
dgisselq |
rx_stb, rx_data, rx_break,
|
257 |
|
|
rx_parity_err, rx_frame_err, w_ck_uart);
|
258 |
25 |
dgisselq |
txuart txv(s_clk, s_reset, bus_uart_setup|30'h8000000, 1'b0,
|
259 |
3 |
dgisselq |
tx_stb, tx_data, o_uart_tx, tx_busy);
|
260 |
|
|
|
261 |
|
|
|
262 |
25 |
dgisselq |
wire [3:0] w_led;
|
263 |
|
|
reg [24:0] dbg_counter;
|
264 |
|
|
always @(posedge sys_clk)
|
265 |
|
|
dbg_counter <= dbg_counter + 25'h01;
|
266 |
|
|
assign o_led = { w_led[3:2],
|
267 |
|
|
((!pwr_reset)&(dbg_counter[24]))
|
268 |
|
|
||((pwr_reset)&&(w_led[1])),
|
269 |
|
|
(s_reset & dbg_counter[23])
|
270 |
|
|
||((!s_reset)&&(w_led[0])) };
|
271 |
3 |
dgisselq |
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
//////
|
275 |
|
|
//
|
276 |
|
|
//
|
277 |
|
|
// The WB bus interconnect, herein called busmaster, which handles
|
278 |
|
|
// just about ... everything. It is in contrast to the other WB bus
|
279 |
|
|
// interconnect, fastmaster, in that the busmaster build permits
|
280 |
25 |
dgisselq |
// peripherals that can *only* operate at 80MHz, no faster, no slower.
|
281 |
3 |
dgisselq |
//
|
282 |
|
|
//
|
283 |
|
|
//////
|
284 |
25 |
dgisselq |
wire w_qspi_sck, w_qspi_cs_n;
|
285 |
3 |
dgisselq |
wire [1:0] qspi_bmod;
|
286 |
|
|
wire [3:0] qspi_dat;
|
287 |
|
|
wire [3:0] i_qspi_dat;
|
288 |
|
|
|
289 |
|
|
//
|
290 |
25 |
dgisselq |
// The SDRAM interface wires
|
291 |
3 |
dgisselq |
//
|
292 |
25 |
dgisselq |
wire ram_cyc, ram_stb, ram_we;
|
293 |
|
|
wire [25:0] ram_addr;
|
294 |
|
|
wire [31:0] ram_rdata, ram_wdata;
|
295 |
|
|
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 |
25 |
dgisselq |
busmaster wbbus(s_clk, s_reset,
|
303 |
3 |
dgisselq |
// External USB-UART bus control
|
304 |
|
|
rx_stb, rx_data, tx_stb, tx_data, tx_busy,
|
305 |
|
|
// Board lights and switches
|
306 |
25 |
dgisselq |
i_sw, i_btn, w_led,
|
307 |
3 |
dgisselq |
o_clr_led0, o_clr_led1, o_clr_led2, o_clr_led3,
|
308 |
|
|
// Board level PMod I/O
|
309 |
|
|
i_aux_rx, o_aux_tx, o_aux_cts, i_gps_rx, o_gps_tx,
|
310 |
|
|
// Quad SPI flash
|
311 |
25 |
dgisselq |
w_qspi_cs_n, w_qspi_sck, qspi_dat, i_qspi_dat, qspi_bmod,
|
312 |
3 |
dgisselq |
// DDR3 SDRAM
|
313 |
25 |
dgisselq |
// o_ddr_reset_n, o_ddr_cke, o_ddr_ck_p, o_ddr_ck_n,
|
314 |
|
|
// o_ddr_cs_n, o_ddr_ras_n, o_ddr_cas_n, o_ddr_we_n,
|
315 |
|
|
// o_ddr_ba, o_ddr_addr, o_ddr_odt, o_ddr_dm,
|
316 |
|
|
// io_ddr_dqs_p, io_ddr_dqs_n, io_ddr_data,
|
317 |
|
|
ram_cyc, ram_stb, ram_we, ram_addr, ram_wdata,
|
318 |
|
|
ram_ack, ram_stall, ram_rdata, ram_err,
|
319 |
|
|
ram_dbg,
|
320 |
3 |
dgisselq |
// SD Card
|
321 |
|
|
o_sd_sck, w_sd_cmd, w_sd_data, io_sd_cmd, io_sd, i_sd_cs,
|
322 |
30 |
dgisselq |
// Ethernet
|
323 |
|
|
o_eth_rstn,
|
324 |
|
|
eth_rx_clk, i_eth_col, i_eth_crs, i_eth_rx_dv,
|
325 |
|
|
i_eth_rxd, i_eth_rxerr,
|
326 |
|
|
eth_tx_clk, o_eth_tx_en, o_eth_txd,
|
327 |
3 |
dgisselq |
// Ethernet control (MDIO) lines
|
328 |
|
|
o_eth_mdclk, w_mdio, w_mdwe, io_eth_mdio,
|
329 |
|
|
// OLEDRGB PMod wires
|
330 |
|
|
o_oled_sck, o_oled_cs_n, o_oled_mosi, o_oled_dcn,
|
331 |
|
|
o_oled_reset_n, o_oled_vccen, o_oled_pmoden,
|
332 |
|
|
// GPS PMod
|
333 |
|
|
i_gps_pps, i_gps_3df
|
334 |
|
|
);
|
335 |
|
|
|
336 |
|
|
//////
|
337 |
|
|
//
|
338 |
|
|
//
|
339 |
|
|
// The rest of this file *should* be identical to fasttop.v. Any
|
340 |
|
|
// differences should be worked out with meld or some such program
|
341 |
|
|
// to keep them to a minimum.
|
342 |
|
|
//
|
343 |
|
|
//
|
344 |
|
|
// Some wires need special treatment, and so are not quite completely
|
345 |
|
|
// handled by the bus master. These are handled below.
|
346 |
|
|
//
|
347 |
|
|
//
|
348 |
|
|
//////
|
349 |
|
|
|
350 |
|
|
//
|
351 |
|
|
//
|
352 |
|
|
// QSPI)BMOD, Quad SPI bus mode, Bus modes are:
|
353 |
|
|
// 0? Normal serial mode, one bit in one bit out
|
354 |
|
|
// 10 Quad SPI mode, going out
|
355 |
|
|
// 11 Quad SPI mode coming from the device (read mode)
|
356 |
|
|
//
|
357 |
|
|
// ?? Dual mode in (not yet)
|
358 |
|
|
// ?? Dual mode out (not yet)
|
359 |
|
|
//
|
360 |
|
|
//
|
361 |
25 |
dgisselq |
wire [3:0] i_qspi_pedge, i_qspi_nedge;
|
362 |
|
|
|
363 |
30 |
dgisselq |
`ifdef VERILATOR
|
364 |
|
|
assign o_qspi_sck = w_qspi_sck;
|
365 |
|
|
assign o_qspi_cs_n = w_qspi_cs_n;
|
366 |
|
|
;
|
367 |
|
|
();
|
368 |
|
|
[*];
|
369 |
|
|
`else
|
370 |
25 |
dgisselq |
xoddr xqspi_sck( s_clk, { w_qspi_sck, w_qspi_sck }, o_qspi_sck);
|
371 |
|
|
xoddr xqspi_csn( s_clk, { w_qspi_cs_n, w_qspi_cs_n },o_qspi_cs_n);
|
372 |
|
|
//
|
373 |
|
|
xioddr xqspi_d0( s_clk, (qspi_bmod != 2'b11),
|
374 |
3 |
dgisselq |
{ qspi_dat[0], qspi_dat[0] },
|
375 |
25 |
dgisselq |
{ i_qspi_pedge[0], i_qspi_nedge[0] }, io_qspi_dat[0]);
|
376 |
|
|
xioddr xqspi_d1( s_clk, (qspi_bmod==2'b10),
|
377 |
3 |
dgisselq |
{ qspi_dat[1], qspi_dat[1] },
|
378 |
25 |
dgisselq |
{ i_qspi_pedge[1], i_qspi_nedge[1] }, io_qspi_dat[1]);
|
379 |
|
|
xioddr xqspi_d2( s_clk, (qspi_bmod!=2'b11),
|
380 |
|
|
(qspi_bmod[1])?{ qspi_dat[2], qspi_dat[2] }:2'b11,
|
381 |
|
|
{ i_qspi_pedge[2], i_qspi_nedge[2] }, io_qspi_dat[2]);
|
382 |
|
|
xioddr xqspi_d3( s_clk, (qspi_bmod!=2'b11),
|
383 |
|
|
(qspi_bmod[1])?{ qspi_dat[3], qspi_dat[3] }:2'b11,
|
384 |
|
|
{ i_qspi_pedge[3], i_qspi_nedge[3] }, io_qspi_dat[3]);
|
385 |
30 |
dgisselq |
`endif
|
386 |
|
|
reg [3:0] r_qspi_dat;
|
387 |
|
|
always @(posedge s_clk)
|
388 |
|
|
r_qspi_dat <= i_qspi_pedge;
|
389 |
|
|
assign i_qspi_dat = r_qspi_dat;
|
390 |
3 |
dgisselq |
|
391 |
|
|
//
|
392 |
|
|
// Proposed QSPI mode select, to allow dual I/O mode
|
393 |
|
|
// 000 Normal SPI mode
|
394 |
|
|
// 001 Dual mode input
|
395 |
|
|
// 010 Dual mode, output
|
396 |
|
|
// 101 Quad I/O mode input
|
397 |
|
|
// 110 Quad I/O mode output
|
398 |
|
|
//
|
399 |
|
|
//
|
400 |
|
|
|
401 |
|
|
|
402 |
|
|
//
|
403 |
|
|
//
|
404 |
30 |
dgisselq |
// Generate a reference clock for the network
|
405 |
|
|
//
|
406 |
|
|
//
|
407 |
|
|
`ifdef VERILATOR
|
408 |
|
|
assign o_eth_ref_clk = i_eth_tx_clk;
|
409 |
|
|
`else
|
410 |
|
|
xoddr e_ref_clk( enet_clk, { 1'b1, 1'b0 }, o_eth_ref_clk );
|
411 |
|
|
`endif
|
412 |
|
|
|
413 |
|
|
//
|
414 |
|
|
//
|
415 |
3 |
dgisselq |
// Wires for setting up the SD Card Controller
|
416 |
|
|
//
|
417 |
|
|
//
|
418 |
|
|
assign io_sd_cmd = w_sd_cmd ? 1'bz:1'b0;
|
419 |
|
|
assign io_sd[0] = w_sd_data[0]? 1'bz:1'b0;
|
420 |
|
|
assign io_sd[1] = w_sd_data[1]? 1'bz:1'b0;
|
421 |
|
|
assign io_sd[2] = w_sd_data[2]? 1'bz:1'b0;
|
422 |
|
|
assign io_sd[3] = w_sd_data[3]? 1'bz:1'b0;
|
423 |
|
|
|
424 |
|
|
|
425 |
|
|
//
|
426 |
|
|
//
|
427 |
|
|
// Wire(s) for setting up the MDIO ethernet control structure
|
428 |
|
|
//
|
429 |
|
|
//
|
430 |
|
|
assign io_eth_mdio = (w_mdwe)?w_mdio : 1'bz;
|
431 |
|
|
|
432 |
25 |
dgisselq |
|
433 |
3 |
dgisselq |
//
|
434 |
|
|
//
|
435 |
25 |
dgisselq |
// Now, to set up our memory ...
|
436 |
3 |
dgisselq |
//
|
437 |
|
|
//
|
438 |
30 |
dgisselq |
migsdram #(.AXIDWIDTH(5)) rami(
|
439 |
25 |
dgisselq |
.i_clk(mem_clk_nobuf), .i_clk_200mhz(mem_clk_200mhz_nobuf),
|
440 |
|
|
.o_sys_clk(s_clk), .i_rst(pwr_reset), .o_sys_reset(s_reset),
|
441 |
|
|
.i_wb_cyc(ram_cyc), .i_wb_stb(ram_stb), .i_wb_we(ram_we),
|
442 |
|
|
.i_wb_addr(ram_addr), .i_wb_data(ram_wdata),
|
443 |
|
|
.i_wb_sel(4'hf),
|
444 |
|
|
.o_wb_ack(ram_ack), .o_wb_stall(ram_stall),
|
445 |
|
|
.o_wb_data(ram_rdata), .o_wb_err(ram_err),
|
446 |
|
|
.o_ddr_ck_p(ddr3_ck_p), .o_ddr_ck_n(ddr3_ck_n),
|
447 |
|
|
.o_ddr_reset_n(ddr3_reset_n), .o_ddr_cke(ddr3_cke),
|
448 |
|
|
.o_ddr_cs_n(ddr3_cs_n), .o_ddr_ras_n(ddr3_ras_n),
|
449 |
|
|
.o_ddr_cas_n(ddr3_cas_n), .o_ddr_we_n(ddr3_we_n),
|
450 |
|
|
.o_ddr_ba(ddr3_ba), .o_ddr_addr(ddr3_addr),
|
451 |
|
|
.o_ddr_odt(ddr3_odt), .o_ddr_dm(ddr3_dm),
|
452 |
|
|
.io_ddr_dqs_p(ddr3_dqs_p), .io_ddr_dqs_n(ddr3_dqs_n),
|
453 |
|
|
.io_ddr_data(ddr3_dq),
|
454 |
|
|
//
|
455 |
|
|
.o_ram_dbg(ram_dbg)
|
456 |
|
|
);
|
457 |
3 |
dgisselq |
|
458 |
|
|
endmodule
|
459 |
|
|
|