Line 108... |
Line 108... |
input i_aux_rx, i_aux_rts;
|
input i_aux_rx, i_aux_rts;
|
output wire o_aux_tx, o_aux_cts;
|
output wire o_aux_tx, o_aux_cts;
|
|
|
`define FULLCLOCK
|
`define FULLCLOCK
|
// Build our master clock
|
// Build our master clock
|
wire i_clk, clk_for_ddr, mem_serial_clk, mem_serial_clk_inv,
|
wire s_clk_pll, s_clk, clk_for_ddr, mem_serial_clk, mem_serial_clk_inv,
|
enet_clk, clk_halfspeed, clk_feedback, clk_locked, clk_unused;
|
enet_clk, clk_halfspeed, clk_feedback, clk_locked, clk_unused;
|
PLLE2_BASE #(
|
PLLE2_BASE #(
|
.BANDWIDTH("OPTIMIZED"), // OPTIMIZED, HIGH, LOW
|
.BANDWIDTH("OPTIMIZED"), // OPTIMIZED, HIGH, LOW
|
.CLKFBOUT_PHASE(0.0), // Phase off. in deg of CLKFB,(-360-360)
|
.CLKFBOUT_PHASE(0.0), // Phase offset in degrees of CLKFB, (-360-360)
|
.CLKIN1_PERIOD(10.0), // Input clock period in ns resolution
|
.CLKIN1_PERIOD(10.0), // Input clock period in ns resolution
|
`ifdef FULLCLOCK
|
// CLKOUT0_DIVIDE - CLKOUT5_DIVIDE: divide amount for each CLKOUT(1-128)
|
// CLKOUT0_DIVIDE - CLKOUT5_DIVIDE:
|
|
// divide amount for each CLKOUT(1-128)
|
|
.CLKFBOUT_MULT(8), // Multiply value for all CLKOUT (2-64)
|
|
.CLKOUT0_DIVIDE(4), // 200 MHz
|
|
.CLKOUT1_DIVIDE(1), // 800 MHz clock for DDR memory
|
|
.CLKOUT2_DIVIDE(1), // 800 MHz clock to run DDR I/O
|
|
.CLKOUT3_DIVIDE(1), // 800MHz clk inv to run DDR I/O
|
|
.CLKOUT4_DIVIDE(8), // 100 MHz
|
|
.CLKOUT5_DIVIDE(32), // 25 MHz
|
|
`else
|
|
// 100*64/40 = 160 -- the fastest speed where the UART will
|
|
// still work at 4MBaud. Others will still support 115200
|
|
// Baud
|
|
// 100*64/36 = 177.78
|
|
// 100*64/34 = 188.24
|
|
// 100*64/33 = 193.94
|
|
.CLKFBOUT_MULT(8), // Multiply value for all CLKOUT (2-64)
|
.CLKFBOUT_MULT(8), // Multiply value for all CLKOUT (2-64)
|
.CLKOUT0_DIVIDE(5), // 160 MHz
|
.CLKOUT0_DIVIDE(5), // 160 MHz
|
.CLKOUT1_DIVIDE(5), // 160 MHz //Clock too slow for DDR mem
|
.CLKOUT1_DIVIDE(10), // 80 MHz (Unused)
|
.CLKOUT2_DIVIDE(5), // 160 MHz // Clock too slow for DDR
|
.CLKOUT2_DIVIDE(16), // 50 MHz (Unused)
|
.CLKOUT3_DIVIDE(5), // 160 MHz // Clock too slow for DDR
|
.CLKOUT3_DIVIDE(32), // 25 MHz (Unused/Ethernet clock)
|
.CLKOUT4_DIVIDE(20), // 40 MHz
|
.CLKOUT4_DIVIDE(16), // 50 MHz (Unused clock?)
|
.CLKOUT5_DIVIDE(5),
|
.CLKOUT5_DIVIDE(24),
|
`endif
|
|
// CLKOUT0_DUTY_CYCLE -- Duty cycle for each CLKOUT
|
// CLKOUT0_DUTY_CYCLE -- Duty cycle for each CLKOUT
|
.CLKOUT0_DUTY_CYCLE(0.5),
|
.CLKOUT0_DUTY_CYCLE(0.5),
|
.CLKOUT1_DUTY_CYCLE(0.5),
|
.CLKOUT1_DUTY_CYCLE(0.5),
|
.CLKOUT2_DUTY_CYCLE(0.5),
|
.CLKOUT2_DUTY_CYCLE(0.5),
|
.CLKOUT3_DUTY_CYCLE(0.5),
|
.CLKOUT3_DUTY_CYCLE(0.5),
|
.CLKOUT4_DUTY_CYCLE(0.5),
|
.CLKOUT4_DUTY_CYCLE(0.5),
|
.CLKOUT5_DUTY_CYCLE(0.5),
|
.CLKOUT5_DUTY_CYCLE(0.5),
|
// CLKOUT0_PHASE -- phase offset for each CLKOUT
|
// CLKOUT0_PHASE -- phase offset for each CLKOUT
|
.CLKOUT0_PHASE(0.0),
|
.CLKOUT0_PHASE(0.0),
|
.CLKOUT1_PHASE(270.0),
|
.CLKOUT1_PHASE(0.0),
|
.CLKOUT2_PHASE(0.0),
|
.CLKOUT2_PHASE(0.0),
|
.CLKOUT3_PHASE(180.0),
|
.CLKOUT3_PHASE(0.0),
|
.CLKOUT4_PHASE(0.0),
|
.CLKOUT4_PHASE(0.0),
|
.CLKOUT5_PHASE(0.0),
|
.CLKOUT5_PHASE(0.0),
|
.DIVCLK_DIVIDE(1), // Master division value , (1-56)
|
.DIVCLK_DIVIDE(1), // Master division value , (1-56)
|
.REF_JITTER1(0.0), // Ref. input jitter in UI (0.000-0.999)
|
.REF_JITTER1(0.0), // Ref. input jitter in UI (0.000-0.999)
|
.STARTUP_WAIT("TRUE") // Delay DONE until PLL Locks, ("TRUE"/"FALSE")
|
.STARTUP_WAIT("TRUE") // Delay DONE until PLL Locks, ("TRUE"/"FALSE")
|
) genclock(
|
) genclock(
|
// Clock outputs: 1-bit (each) output
|
// Clock outputs: 1-bit (each) output
|
.CLKOUT0(i_clk),
|
.CLKOUT0(s_clk_pll),
|
.CLKOUT1(clk_for_ddr),
|
.CLKOUT1(mem_clk),
|
.CLKOUT2(mem_serial_clk),
|
.CLKOUT2(clk2_unused),
|
.CLKOUT3(mem_serial_clk_inv),
|
.CLKOUT3(enet_clk),
|
.CLKOUT4(clk_unused),
|
.CLKOUT4(clk4_unused),
|
.CLKOUT5(enet_clk),
|
.CLKOUT5(clk5_unused),
|
.CLKFBOUT(clk_feedback), // 1-bit output, feedback clock
|
.CLKFBOUT(clk_feedback), // 1-bit output, feedback clock
|
.LOCKED(clk_locked),
|
.LOCKED(clk_locked),
|
.CLKIN1(i_clk_100mhz),
|
.CLKIN1(i_clk_100mhz),
|
.PWRDWN(1'b0),
|
.PWRDWN(1'b0),
|
.RST(1'b0),
|
.RST(1'b0),
|
.CLKFBIN(clk_feedback) // 1-bit input, feedback clock
|
.CLKFBIN(clk_feedback_bufd) // 1-bit input, feedback clock
|
);
|
);
|
|
|
|
// Help reduce skew ...
|
|
BUFG sys_clk_buffer( .I(s_clk_pll), .O(s_clk));
|
|
BUFG feedback_buffer(.I(clk_feedback),.O(clk_feedback_bufd));
|
|
|
// UART interface
|
// UART interface
|
wire [29:0] bus_uart_setup;
|
wire [29:0] bus_uart_setup;
|
`ifdef FULLCLOCK
|
assign bus_uart_setup = 30'h10000028; // 4MBaud, 7 bits
|
assign bus_uart_setup = 30'h10000032; // 4MBaud, 7 bits
|
|
`else
|
|
assign bus_uart_setup = 30'h10000028;//4MBaud,7 bits,@160MHzClk
|
|
//assign bus_uart_setup = 30'h10000019;//4MBaud,7 bits,@100MHzClk
|
|
`endif
|
|
|
|
wire [7:0] rx_data, tx_data;
|
wire [7:0] rx_data, tx_data;
|
wire rx_break, rx_parity_err, rx_frame_err, rx_stb;
|
wire rx_break, rx_parity_err, rx_frame_err, rx_stb;
|
wire tx_stb, tx_busy;
|
wire tx_stb, tx_busy;
|
|
|
Line 200... |
Line 182... |
reg pwr_reset, pre_reset;
|
reg pwr_reset, pre_reset;
|
//
|
//
|
// Logic description starts with the PRE-reset, so as to make certain
|
// Logic description starts with the PRE-reset, so as to make certain
|
// we include the reset button
|
// we include the reset button
|
initial pre_reset = 1'b0;
|
initial pre_reset = 1'b0;
|
always @(posedge i_clk)
|
always @(posedge s_clk)
|
pre_reset <= ~i_reset_btn;
|
pre_reset <= ~i_reset_btn;
|
//
|
//
|
// and then continues with the actual reset, now that we've
|
// and then continues with the actual reset, now that we've
|
// synchronized our reset button wire.
|
// synchronized our reset button wire.
|
initial pwr_reset = 1'b1;
|
initial pwr_reset = 1'b1;
|
always @(posedge i_clk)
|
always @(posedge s_clk)
|
pwr_reset <= pre_reset;
|
pwr_reset <= pre_reset;
|
|
|
wire w_ck_uart, w_uart_tx;
|
wire w_ck_uart, w_uart_tx;
|
rxuart rcv(i_clk, pwr_reset, bus_uart_setup, i_uart_rx,
|
rxuart rcv(s_clk, pwr_reset, bus_uart_setup, i_uart_rx,
|
rx_stb, rx_data, rx_break,
|
rx_stb, rx_data, rx_break,
|
rx_parity_err, rx_frame_err, w_ck_uart);
|
rx_parity_err, rx_frame_err, w_ck_uart);
|
txuart txv(i_clk, pwr_reset, bus_uart_setup, 1'b0,
|
txuart txv(s_clk, pwr_reset, bus_uart_setup, 1'b0,
|
tx_stb, tx_data, o_uart_tx, tx_busy);
|
tx_stb, tx_data, o_uart_tx, tx_busy);
|
|
|
|
|
|
|
|
|
Line 400... |
Line 382... |
wire [1:0] qspi_bmod;
|
wire [1:0] qspi_bmod;
|
wire [3:0] qspi_dat;
|
wire [3:0] qspi_dat;
|
wire [3:0] i_qspi_dat;
|
wire [3:0] i_qspi_dat;
|
|
|
//
|
//
|
|
wire [2:0] w_ddr_dqs;
|
|
wire [31:0] wo_ddr_data, wi_ddr_data;
|
|
//
|
wire w_mdio, w_mdwe;
|
wire w_mdio, w_mdwe;
|
//
|
//
|
wire w_sd_cmd;
|
wire w_sd_cmd;
|
wire [3:0] w_sd_data;
|
wire [3:0] w_sd_data;
|
fastmaster wbbus(i_clk, pwr_reset,
|
fastmaster wbbus(s_clk, pwr_reset,
|
// External USB-UART bus control
|
// External USB-UART bus control
|
rx_stb, rx_data, tx_stb, tx_data, tx_busy,
|
rx_stb, rx_data, tx_stb, tx_data, tx_busy,
|
// Board lights and switches
|
// Board lights and switches
|
i_sw, i_btn, o_led,
|
i_sw, i_btn, o_led,
|
o_clr_led0, o_clr_led1, o_clr_led2, o_clr_led3,
|
o_clr_led0, o_clr_led1, o_clr_led2, o_clr_led3,
|
Line 448... |
Line 433... |
//
|
//
|
// ?? Dual mode in (not yet)
|
// ?? Dual mode in (not yet)
|
// ?? Dual mode out (not yet)
|
// ?? Dual mode out (not yet)
|
//
|
//
|
//
|
//
|
// `define QSPI_OUT_VERSION_ONE
|
|
`ifdef QSPI_OUT_VERSION_ONE
|
|
assign io_qspi_dat = (~qspi_bmod[1])?({2'b11,1'bz,qspi_dat[0]})
|
|
:((qspi_bmod[0])?(4'bzzzz):(qspi_dat[3:0]));
|
|
assign i_qspi_dat = io_qspi_dat;
|
|
assign o_qspi_sck = w_qspi_sck;
|
|
`else
|
|
wire [3:0] i_qspi_pedge, i_qspi_nedge;
|
wire [3:0] i_qspi_pedge, i_qspi_nedge;
|
|
|
xoddr xqspi_sck( i_clk, { w_qspi_sck, w_qspi_sck }, o_qspi_sck);
|
xoddr xqspi_sck( i_clk, { w_qspi_sck, w_qspi_sck }, o_qspi_sck);
|
xoddr xqspi_csn( i_clk, { w_qspi_cs_n, w_qspi_cs_n },o_qspi_cs_n);
|
xoddr xqspi_csn( i_clk, { w_qspi_cs_n, w_qspi_cs_n },o_qspi_cs_n);
|
//
|
//
|
xioddr xqspi_d0( i_clk, (qspi_bmod != 2'b11),
|
xioddr xqspi_d0( s_clk, (qspi_bmod != 2'b11),
|
{ qspi_dat[0], qspi_dat[0] },
|
{ qspi_dat[0], qspi_dat[0] },
|
{ i_qspi_pedge[0], i_qspi_nedge[0] }, io_qspi_dat[0]);
|
{ i_qspi_pedge[0], i_qspi_nedge[0] }, io_qspi_dat[0]);
|
xioddr xqspi_d1( i_clk, (qspi_bmod==2'b10),
|
xioddr xqspi_d1( s_clk, (qspi_bmod==2'b10),
|
{ qspi_dat[1], qspi_dat[1] },
|
{ qspi_dat[1], qspi_dat[1] },
|
{ i_qspi_pedge[1], i_qspi_nedge[1] }, io_qspi_dat[1]);
|
{ i_qspi_pedge[1], i_qspi_nedge[1] }, io_qspi_dat[1]);
|
xioddr xqspi_d2( i_clk, (qspi_bmod!=2'b11),
|
xioddr xqspi_d2( s_clk, (qspi_bmod!=2'b11),
|
(qspi_bmod[1])?{ qspi_dat[2], qspi_dat[2] }:2'b11,
|
(qspi_bmod[1])?{ qspi_dat[2], qspi_dat[2] }:2'b11,
|
{ i_qspi_pedge[2], i_qspi_nedge[2] }, io_qspi_dat[2]);
|
{ i_qspi_pedge[2], i_qspi_nedge[2] }, io_qspi_dat[2]);
|
xioddr xqspi_d3( i_clk, (qspi_bmod!=2'b11),
|
xioddr xqspi_d3( s_clk, (qspi_bmod!=2'b11),
|
(qspi_bmod[1])?{ qspi_dat[3], qspi_dat[3] }:2'b11,
|
(qspi_bmod[1])?{ qspi_dat[3], qspi_dat[3] }:2'b11,
|
{ i_qspi_pedge[3], i_qspi_nedge[3] }, io_qspi_dat[3]);
|
{ i_qspi_pedge[3], i_qspi_nedge[3] }, io_qspi_dat[3]);
|
|
|
assign i_qspi_dat = i_qspi_pedge;
|
assign i_qspi_dat = i_qspi_pedge;
|
`endif
|
//
|
|
// Proposed QSPI mode select, to allow dual I/O mode
|
|
// 000 Normal SPI mode
|
|
// 001 Dual mode input
|
|
// 010 Dual mode, output
|
|
// 101 Quad I/O mode input
|
|
// 110 Quad I/O mode output
|
|
//
|
|
//
|
|
|
|
|
//
|
//
|
//
|
//
|
// Wires for setting up the SD Card Controller
|
// Wires for setting up the SD Card Controller
|
//
|
//
|