URL
https://opencores.org/ocsvn/spi_master_slave/spi_master_slave/trunk
Subversion Repositories spi_master_slave
Compare Revisions
- This comparison shows the changes necessary to convert path
/spi_master_slave/trunk/syn
- from Rev 5 to Rev 6
- ↔ Reverse comparison
Rev 5 → Rev 6
/spi_master.vhd
60,8 → 60,8
-- PARALLEL READ INTERFACE |
-- ======================= |
-- An internal buffer is used to copy the internal shift register data to drive the 'do_o' port. When a complete word is received, |
-- the core shift register is transferred to the buffer, at the rising edge of the spi clock, 'spi_2x_clk_i'. |
-- The signal 'do_valid_o' is set one 'spi_2x_clk_i' clock after, to directly drive a synchronous memory or fifo write enable. |
-- the core shift register is transferred to the buffer, at the rising edge of the spi clock, 'spi_clk'. |
-- The signal 'do_valid_o' is set one 'spi_clk' clock after, to directly drive a synchronous memory or fifo write enable. |
-- 'do_valid_o' is synchronous to the parallel interface clock, and changes only on rising edges of 'pclk_i'. |
-- When the interface is idle, data at the 'do_o' port holds the last word received. |
-- |
68,11 → 68,11
-- PARALLEL READ SEQUENCE |
-- ====================== |
-- ______ ______ ______ ______ |
-- spi_2x_clk_i bit1 \______/ bitN \______/bitN-1\______/bitN-2\__... -- spi 2x base clock |
-- spi_clk bit1 \______/ bitN \______/bitN-1\______/bitN-2\__... -- spi 2x base clock |
-- _ __ __ __ __ __ __ __ __ |
-- pclk_i \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \_... -- parallel interface clock (may be async to sclk_i) |
-- _____________ _____________________________________... -- 1) rx data is transferred to 'do_buffer_reg' |
-- do_o ___old_data__X__________new_data___________________... -- after last rx bit, at rising 'spi_2x_clk_i'. |
-- do_o ___old_data__X__________new_data___________________... -- after last rx bit, at rising 'spi_clk'. |
-- ____________ |
-- do_valid_o ____________________________/ \_________... -- 2) 'do_valid_o' strobed for 2 'pclk_i' cycles |
-- -- on the 3rd 'pclk_i' rising edge. |
88,26 → 88,26
------------------------------ COPYRIGHT NOTICE ----------------------------------------------------------------------- |
-- |
-- This file is part of the SPI MASTER/SLAVE INTERFACE project http://opencores.org/project,spi_master_slave |
-- |
-- |
-- Author(s): Jonny Doin, jdoin@opencores.org |
-- |
-- |
-- Copyright (C) 2011 Authors and OPENCORES.ORG |
-- -------------------------------------------- |
-- |
-- This source file may be used and distributed without restriction provided that this copyright statement is not |
-- -------------------------------------------- |
-- |
-- This source file may be used and distributed without restriction provided that this copyright statement is not |
-- removed from the file and that any derivative work contains the original copyright notice and the associated |
-- disclaimer. |
-- |
-- disclaimer. |
-- |
-- This source file is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser |
-- General Public License as published by the Free Software Foundation; either version 2.1 of the License, or |
-- (at your option) any later version. |
-- |
-- This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
-- details. |
-- |
-- (at your option) any later version. |
-- |
-- This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
-- details. |
-- |
-- You should have received a copy of the GNU Lesser General Public License along with this source; if not, download |
-- it from http://www.opencores.org/lgpl.shtml |
-- it from http://www.opencores.org/lgpl.shtml |
-- |
------------------------------ REVISION HISTORY ----------------------------------------------------------------------- |
-- |
132,7 → 132,7
-- frequency sequential circuits, to preserve clocking resources and avoid path delay glitches. |
-- 2011/07/10 v1.00.0098 [JD] implemented SCK clock divider circuit to generate spi clock directly from system clock. |
-- 2011/07/10 v1.10.0075 [JD] verified spi_master_slave in silicon at 50MHz, 25MHz, 16.666MHz, 12.5MHz, 10MHz, 8.333MHz, |
-- 7.1428MHz, 6.25MHz, 1MHz and 500kHz. The core proved very robust at all tested frequencies. |
-- 7.1428MHz, 6.25MHz, 1MHz and 500kHz. The core proved very robust at all tested frequencies. |
-- |
----------------------------------------------------------------------------------------------------------------------- |
-- TODO |
143,7 → 143,7
library ieee; |
use ieee.std_logic_1164.all; |
use ieee.numeric_std.all; |
use ieee.std_logic_unsigned.all; |
use ieee.std_logic_unsigned.all; |
|
--================================================================================================================ |
-- There are several output ports that are used to simulate and verify the core operation. |
169,10 → 169,10
spi_mosi_o : out std_logic; -- spi bus mosi output |
spi_miso_i : in std_logic := 'X'; -- spi bus spi_miso_i input |
di_req_o : out std_logic; -- preload lookahead data request line |
di_i : in std_logic_vector (N-1 downto 0) := (others => 'X'); -- parallel data in (clocked on rising spi_2x_clk_i after last bit) |
di_i : in std_logic_vector (N-1 downto 0) := (others => 'X'); -- parallel data in (clocked on rising spi_clk after last bit) |
wren_i : in std_logic := 'X'; -- user data write enable, starts transmission when interface is idle |
do_valid_o : out std_logic; -- do_o data valid signal, valid during one spi_2x_clk_i rising edge. |
do_o : out std_logic_vector (N-1 downto 0); -- parallel output (clocked on rising spi_2x_clk_i after last bit) |
do_valid_o : out std_logic; -- do_o data valid signal, valid during one spi_clk rising edge. |
do_o : out std_logic_vector (N-1 downto 0); -- parallel output (clocked on rising spi_clk after last bit) |
--- debug ports: can be removed for the application circuit --- |
do_transfer_o : out std_logic; -- debug: internal transfer driver |
wren_o : out std_logic; -- debug: internal state of the wren_i pulse stretcher |
189,10 → 189,10
|
--================================================================================================================ |
-- this architecture is a pipelined register-transfer description. |
-- all signals are clocked at the rising edge of the system clock 'spi_2x_clk_i'. |
-- all signals are clocked at the rising edge of the system clock 'sclk_i'. |
--================================================================================================================ |
architecture rtl of spi_master is |
-- core clocks, generated from 'spi_2x_clk_i': initialized to differential values |
-- core clocks, generated from 'sclk_i': initialized to differential values |
signal core_clk : std_logic := '0'; -- continuous core clock, positive logic |
signal core_n_clk : std_logic := '1'; -- continuous core clock, negative logic |
signal core_ce : std_logic := '0'; -- core clock enable, positive logic |
262,20 → 262,20
-- GENERICS CONSTRAINTS CHECKING |
--============================================================================================= |
-- minimum word width is 8 bits |
assert N >= 8 |
report "Generic parameter 'N' (shift register size) needs to be 8 bits minimum" |
assert N >= 8 |
report "Generic parameter 'N' (shift register size) needs to be 8 bits minimum" |
severity FAILURE; |
-- minimum prefetch lookahead check |
assert PREFETCH >= 2 |
report "Generic parameter 'PREFETCH' (lookahead count) needs to be 1 minimum" |
assert PREFETCH >= 2 |
report "Generic parameter 'PREFETCH' (lookahead count) needs to be 1 minimum" |
severity FAILURE; |
-- maximum prefetch lookahead check |
assert PREFETCH <= N-5 |
report "Generic parameter 'PREFETCH' (lookahead count) out of range, needs to be N-5 maximum" |
assert PREFETCH <= N-5 |
report "Generic parameter 'PREFETCH' (lookahead count) out of range, needs to be N-5 maximum" |
severity FAILURE; |
-- SPI_2X_CLK_DIV clock divider value must not be zero |
assert SPI_2X_CLK_DIV > 0 |
report "Generic parameter 'SPI_2X_CLK_DIV' must not be zero" |
assert SPI_2X_CLK_DIV > 0 |
report "Generic parameter 'SPI_2X_CLK_DIV' must not be zero" |
severity FAILURE; |
|
--============================================================================================= |
295,7 → 295,7
-- Each phase is selected so that all the registers can be clocked with a rising edge on all SPI |
-- modes, by a single high-speed global clock, preserving clock resources. |
----------------------------------------------------------------------------------------------- |
-- generate the core clock enables from the serial high-speed input clock |
-- generate the 2x spi base clock enable from the serial high-speed input clock |
spi_2x_ce_gen_proc: process (sclk_i) is |
variable clk_cnt : integer range SPI_2X_CLK_DIV-1 downto 0 := 0; |
begin |
310,7 → 310,7
end if; |
end process spi_2x_ce_gen_proc; |
----------------------------------------------------------------------------------------------- |
-- generate the core antiphase clocks and clock enables. |
-- generate the core antiphase clocks and clock enables from the 2x base CE. |
core_clock_gen_proc : process (sclk_i) is |
begin |
if sclk_i'event and sclk_i = '1' then |
353,7 → 353,7
samp_ce <= core_n_ce; |
end generate; |
----------------------------------------------------------------------------------------------- |
-- FSM clock generation: generate 'fsm_ce' from core_ce or core_n_ce depending on CPHA |
-- FSM clock enable generation: generate 'fsm_ce' from core_ce or core_n_ce depending on CPHA |
fsm_ce_cpha_0_proc : |
if CPHA = '0' generate |
begin |
/readme.txt
1,6 → 1,9
SPI_MASTER_ATLYS |
================ |
|
This is a ISE 13.1 project to test the spi_master.vhd model in silicon. |
|
The target board is a Digilent Atlys board (Spartan-6 @ 100MHz), and the circuit was tested at different SPI clock frequencies. |
The target board is a Digilent Atlys FPGA board (Spartan-6 @ 100MHz), and the circuit was tested at different SPI clock frequencies. |
|
See the scope screenshots in the spi_master_scope_photos.zip file for each SPI frequency tested. |
|
7,6 → 10,7
This circuit also includes a very robust debouncing circuit to use with multiple inputs. The model, "grp_debouncer.vhd" is also published under a LGPL license. |
|
The files are: |
------------- |
|
spi_master.vhd vhdl model for the spi_master interface |
grp_debouncer.vhd vhdl model for the switch debouncer |
28,3 → 32,4
|
Jonny Doin |
jdoin@opencores.org |
|