Line 1... |
Line 1... |
//
|
///////////////////////////////////////////////////////////////////////////
|
//
|
//
|
// Filename: llqspi.v
|
// Filename: llqspi.v
|
//
|
//
|
// Project: FPGA library development (Basys-3 development board)
|
// Project: Wishbone Controlled Quad SPI Flash Controller
|
//
|
//
|
// Purpose: Reads/writes a word (user selectable number of bytes) of data
|
// Purpose: Reads/writes a word (user selectable number of bytes) of data
|
// to/from a Quad SPI port. The port is understood to be
|
// to/from a Quad SPI port. The port is understood to be
|
// a normal SPI port unless the driver requests four bit mode.
|
// a normal SPI port unless the driver requests four bit mode.
|
// When not in use, unlike our previous SPI work, no bits will
|
// When not in use, unlike our previous SPI work, no bits will
|
// toggle.
|
// toggle.
|
//
|
//
|
// Creator: Dan Gisselquist
|
// Creator: Dan Gisselquist
|
// Gisselquist Tecnology, LLC
|
// Gisselquist Tecnology, LLC
|
//
|
//
|
// Copyright: 2015
|
///////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2015, Gisselquist Technology, LLC
|
|
//
|
|
// This program is free software (firmware): you can redistribute it and/or
|
|
// modify it under the terms of the GNU General Public License as published
|
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
|
// your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
// for more details.
|
//
|
//
|
|
// You should have received a copy of the GNU General Public License along
|
|
// with this program. (It's in the $(ROOT)/doc directory, run make with no
|
|
// target there if the PDF file isn't present.) If not, see
|
|
// <http://www.gnu.org/licenses/> for a copy.
|
//
|
//
|
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
|
// http://www.gnu.org/licenses/gpl.html
|
|
//
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////
|
`define QSPI_IDLE 0
|
`define QSPI_IDLE 0
|
`define QSPI_START 1
|
`define QSPI_START 1
|
`define QSPI_BITS 2
|
`define QSPI_BITS 2
|
`define QSPI_READY 3
|
`define QSPI_READY 3
|
`define QSPI_STOP 4
|
`define QSPI_STOP 4
|
Line 31... |
Line 52... |
module llqspi(i_clk,
|
module llqspi(i_clk,
|
// Module interface
|
// Module interface
|
i_wr, i_hold, i_word, i_len, i_spd, i_dir,
|
i_wr, i_hold, i_word, i_len, i_spd, i_dir,
|
o_word, o_valid, o_busy,
|
o_word, o_valid, o_busy,
|
// QSPI interface
|
// QSPI interface
|
o_sck, o_cs_n, o_mod, o_dat, i_dat,
|
o_sck, o_cs_n, o_mod, o_dat, i_dat);
|
// Wbscope interface
|
|
o_dbg);
|
|
input i_clk;
|
input i_clk;
|
// Chip interface
|
// Chip interface
|
// Can send info
|
// Can send info
|
// i_dir = 1, i_spd = 0, i_hold = 0, i_wr = 1,
|
// i_dir = 1, i_spd = 0, i_hold = 0, i_wr = 1,
|
// i_word = { 1'b0, 32'info to send },
|
// i_word = { 1'b0, 32'info to send },
|
Line 53... |
Line 72... |
output reg o_sck;
|
output reg o_sck;
|
output reg o_cs_n;
|
output reg o_cs_n;
|
output reg [1:0] o_mod;
|
output reg [1:0] o_mod;
|
output reg [3:0] o_dat;
|
output reg [3:0] o_dat;
|
input [3:0] i_dat;
|
input [3:0] i_dat;
|
output wire [22:0] o_dbg;
|
|
|
|
assign o_dbg = { state, spi_len, // 3+6+ 14
|
|
o_busy, o_valid, o_cs_n, o_sck, o_mod, o_dat, i_dat };
|
|
|
|
// Timing:
|
// Timing:
|
//
|
//
|
// Tick Clk BSY/WR CS_n BIT/MO STATE
|
// Tick Clk BSY/WR CS_n BIT/MO STATE
|
// 0 1 0/0 1 -
|
// 0 1 0/0 1 -
|