Line 51... |
Line 51... |
//
|
//
|
//
|
//
|
module toplevel(i_clk_8mhz,
|
module toplevel(i_clk_8mhz,
|
o_qspi_cs_n, o_qspi_sck, io_qspi_dat,
|
o_qspi_cs_n, o_qspi_sck, io_qspi_dat,
|
i_btn, o_led, o_pwm, o_pwm_shutdown_n, o_pwm_gain,
|
i_btn, o_led, o_pwm, o_pwm_shutdown_n, o_pwm_gain,
|
i_uart, o_uart, o_uart_cts, i_uart_rts,
|
i_uart, o_uart, o_uart_rts_n, i_uart_cts_n,
|
i_kp_row, o_kp_col,
|
i_kp_row, o_kp_col,
|
i_gpio, o_gpio,
|
i_gpio, o_gpio,
|
io_scl, io_sda);
|
io_scl, io_sda);
|
input i_clk_8mhz;
|
input i_clk_8mhz;
|
//
|
//
|
Line 71... |
Line 71... |
//
|
//
|
// and our serial port
|
// and our serial port
|
input i_uart;
|
input i_uart;
|
output wire o_uart;
|
output wire o_uart;
|
// and it's associated control wires
|
// and it's associated control wires
|
output wire o_uart_cts;
|
output wire o_uart_rts_n;
|
input i_uart_rts;
|
input i_uart_cts_n;
|
// Our keypad
|
// Our keypad
|
input [3:0] i_kp_row;
|
input [3:0] i_kp_row;
|
output wire [3:0] o_kp_col;
|
output wire [3:0] o_kp_col;
|
// and our GPIO
|
// and our GPIO
|
input [15:2] i_gpio;
|
input [15:2] i_gpio;
|
Line 112... |
Line 112... |
.CLKFB(ck_zero_0),
|
.CLKFB(ck_zero_0),
|
.CLKFX(clk_s),
|
.CLKFX(clk_s),
|
.PSEN(1'b0),
|
.PSEN(1'b0),
|
.RST(1'b0));
|
.RST(1'b0));
|
|
|
//
|
// Baud rate is set by clock rate / baud rate desired. Thus,
|
// The UART serial interface
|
// 80 MHz / 9600 Baud = 8333, or about 0x208d. We choose a slow
|
//
|
// speed such as 9600 Baud to help the CPU keep up with the serial
|
// Perhaps this should be part of our simulation model as well.
|
// port rate.
|
// For historical reasons, internal to Gisselquist Technology,
|
localparam [30:0] UART_SETUP = 31'h4000208d;
|
// this has remained separate from the simulation, allowing the
|
|
// simulation to bypass whether or not these two functions work.
|
|
//
|
|
wire rx_stb, tx_stb;
|
|
wire [7:0] rx_data, tx_data;
|
|
wire tx_busy;
|
|
wire [29:0] uart_setup;
|
|
|
|
wire reset_s;
|
|
assign reset_s = 1'b0;
|
|
|
|
wire rx_break, rx_parity_err, rx_frame_err, rx_ck_uart, tx_break;
|
|
assign tx_break = 1'b0;
|
|
rxuart rcvuart(clk_s, 1'b0, uart_setup,
|
|
i_uart, rx_stb, rx_data,
|
|
rx_break, rx_parity_err, rx_frame_err, rx_ck_uart);
|
|
txuart tcvuart(clk_s, reset_s, uart_setup, tx_break, tx_stb, tx_data,
|
|
o_uart, tx_busy);
|
|
|
|
|
|
//
|
//
|
// BUSMASTER
|
// BUSMASTER
|
//
|
//
|
// Busmaster is so named because it contains the wishbone
|
// Busmaster is so named because it contains the wishbone
|
Line 150... |
Line 131... |
//
|
//
|
wire [3:0] qspi_dat;
|
wire [3:0] qspi_dat;
|
wire [1:0] qspi_bmod;
|
wire [1:0] qspi_bmod;
|
wire [15:0] w_gpio;
|
wire [15:0] w_gpio;
|
|
|
busmaster masterbus(clk_s, 1'b0,
|
wire w_uart_rts_n;
|
// External ... bus control (if enabled)
|
busmaster #(.UART_SETUP(UART_SETUP))
|
rx_stb, rx_data, tx_stb, tx_data, tx_busy, w_uart_cts,
|
masterbus(clk_s, 1'b0,
|
|
// Serial port wires
|
|
i_uart, o_uart_rts_n, o_uart, i_uart_cts_n,
|
// SPI/SD-card flash
|
// SPI/SD-card flash
|
o_qspi_cs_n, o_qspi_sck, qspi_dat, io_qspi_dat, qspi_bmod,
|
o_qspi_cs_n, o_qspi_sck, qspi_dat, io_qspi_dat, qspi_bmod,
|
// Board lights and switches
|
// Board lights and switches
|
i_btn, o_led, o_pwm, { o_pwm_shutdown_n, o_pwm_gain },
|
i_btn, o_led, o_pwm, { o_pwm_shutdown_n, o_pwm_gain },
|
// Keypad connections
|
// Keypad connections
|
i_kp_row, o_kp_col,
|
i_kp_row, o_kp_col,
|
// UART control
|
|
uart_setup,
|
|
// GPIO lines
|
// GPIO lines
|
{ i_gpio, io_scl, io_sda }, w_gpio
|
{ i_gpio, io_scl, io_sda }, w_gpio
|
);
|
);
|
assign o_uart_cts = (w_uart_cts)&&(i_uart_rts);
|
|
|
|
//
|
//
|
// Quad SPI support
|
// Quad SPI support
|
//
|
//
|
// Supporting a Quad SPI port requires knowing which direction the
|
// Supporting a Quad SPI port requires knowing which direction the
|