1 ------------------------------------------------------------------------------- 3 --! @brief SPI Slave module 4 ------------------------------------------------------------------------------- 9 --! Using IEEE standard logic components 10 USE ieee.std_logic_1164.
ALL;
12 --! @brief SPI Slave module 14 --! This SPI slave works with SPI signals using the following format: 15 --! - CPOL = 0: sclk low when idle. 16 --! - CPHA = 1: data written on first edge and read on second. 18 --! This SPI slave provides a simple SPI shift register for reading/writing 19 --! data. At the start of a transfer when the CS goes low the 'dat_rd_reg_in' 20 --! is latched for transmitting. 22 --! At the end of transfer when the CS goes high the module loads the received 23 --! data into 'dat_wr_reg_out' then drives the 'dat_wr_done_out' signal for 24 --! one clock indicating new data has been written to the SPI block. 27 size : RANGE 1 TO 'high --! Size of the SPI data 42 --! Architecture rtl of spi_slave entity 45 --! Flag indicating a transfer is in progress. 48 --! SPI shift register 51 --! Signal indicating rise of sclk 54 --! Signal indicating fall fo sclk 59 --! Edge detector for SCLK signal 69 --! @brief SPI shift process 74 -- Asynchronous reset of state 76 shift <= (OTHERS => '0');
80 ELSIF (rising_edge(clk_in)) THEN 81 -- Default dat_wr_done_out to 0 (set only on end transfer) 98 -- First edge - write data 101 -- Second edge - capture data 107 END PROCESS pr_shift;
109 END ARCHITECTURE rtl;
out rise_outstd_logic
Rising edge output.
in spi_mosi_instd_logic
SPI MOSI.
std_logic_vector( size- 1 DOWNTO 0) shift
SPI shift register.
in rst_instd_logic
Asynchronous reset.
in sig_instd_logic
Input signal.
out spi_miso_outstd_logic
SPI MISO.
in clk_instd_logic
Clock.
_library_ ieeeieee
Using IEEE library.
std_logic sclk_rise
Signal indicating rise of sclk.
in spi_sclk_instd_logic
SPI Clock.
in dat_rd_reg_instd_logic_vector( size- 1 DOWNTO 0)
Data Read Register value.
in clk_instd_logic
Clock.
std_logic sclk_fall
Signal indicating fall fo sclk.
sizenatural range 1 TO natural'high
Size of the SPI data.
out dat_wr_done_outstd_logic
Data Write Done flag.
in rst_instd_logic
Asynchronous reset.
std_logic in_xfer
Flag indicating a transfer is in progress.
out fall_outstd_logic
Falling edge output.
in spi_cs_instd_logic
SPI Chip-select.
out dat_wr_reg_outstd_logic_vector( size- 1 DOWNTO 0)
Data Write Register value.