SPI MASTER CORE SPECIFICATION
INTRODUCTION:
SPI (Serial Peripheral Interface) Master core.
Synchronous serial interfaces are widely used to provide economical board-level
interfaces between different devices such as microcontrollers, DACs, ADCs and
other. Although there is no single standard for a synchronous serial bus, there
are industry-wide accepted guidelines based on two most popular
implementations:
·
SPI (a
trademark of Motorola Semiconductor)
·
Microwire/Plus
(a trademark of National Semiconductor)
Many IC manufacturers produce components that are
compatible with SPI and Microwire/Plus.
The SPI Master core is compatible with both
above-mentioned protocols as master with some additional functionality.
At the hosts side, the core acts like a WISHBONE
compliant slave device.
Features:
·
Full duplex
synchronous serial data transfer
·
Variable length
of transfer word up to 128 bits
·
MSB or LSB first
data transfer
·
Rx and Tx on
both rising or falling edge of serial clock independently
·
8 slave select
lines
·
Fully static
synchronous design with one clock domain
·
Technology
independent Verilog
·
Fully
synthesizable
WISHBONE
interface signals
Port
|
Width
|
Direction
|
Description
|
|
1
|
Input
|
Master
clock
|
wb_rst_i
|
1
|
Input
|
Synchronous
reset, active high
|
wb_adr_i
|
5
|
Input
|
Lower
address bits
|
wb_dat_i
|
32
|
Input
|
Data
towards the core
|
wb_dat_o
|
32
|
Output
|
Data
from the core
|
wb_sel_i
|
4
|
Input
|
Byte
select signals
|
wb_we_i
|
1
|
Input
|
Write
enable input
|
wb_stb_i
|
1
|
Input
|
Strobe
signal/Core select input
|
wb_cyc_i
|
1
|
Input
|
Valid
bus cycle input
|
wb_ack_o
|
1
|
Output
|
Bus cycle acknowledge output
|
wb_err_o
|
1
|
Output
|
Bus cycle error output
|
wb_int_o
|
1
|
Output
|
Interrupt signal output
|
Table 1: Wishbone interface signals
All output WISHBONE signals are registered and
driven on the rising edge of wb_clk_i. All input WISHBONE signals are latched
on the rising edge of wb_clk_i.
SPI
external connections
Port
|
Width
|
Direction
|
Description
|
|
8
|
Output
|
Slave
select output signals
|
sclk_pad_o
|
1
|
Output
|
Serial
clock output
|
mosi_pad_o
|
1
|
Output
|
Master
out slave in data signal output
|
miso_pad_i
|
1
|
Input
|
Master in slave out data signal input
|
Table 2: SPI external
connections
Core
Registers list
Name
|
Address
|
Width
|
Access
|
Description
|
Rx0
|
0x00
|
32
|
R
|
Data
receive register 0
|
Rx1
|
0x04
|
32
|
R
|
Data
receive register 1
|
Rx2
|
0x08
|
32
|
R
|
Data
receive register 2
|
Rx3
|
0x0c
|
32
|
R
|
Data
receive register 3
|
|
0x00
|
32
|
R/W
|
Data
transmit register 0
|
|
0x04
|
32
|
R/W
|
Data
transmit register 1
|
|
0x08
|
32
|
R/W
|
Data
transmit register 2
|
|
0x0c
|
32
|
R/W
|
Data
transmit register 3
|
CTRL
|
0x10
|
32
|
R/W
|
Control
and status register
|
DIVIDER
|
0x14
|
32
|
R/W
|
Clock
divider register
|
SS
|
0x18
|
32
|
R/W
|
Slave select register
|
Table 3: List of core registers
All registers are 32-bit wide and accessible only with 32 bits (all
wb_sel_i signals must be active).
Control
and status register [CTRL]
Bit
#
|
31:14
|
13
|
12
|
11
|
10
|
9
|
8
|
7
|
6:0
|
Access
|
R
|
R/W
|
R/W
|
R/W
|
R/W
|
R/W
|
R/W
|
R
|
R/W
|
Name
|
Reserved
|
ASS
|
IE
|
LSB
|
Tx_NEG
|
Rx_NEG
|
GO_BSY
|
Reserved
|
CHAR_LEN
|
Table 6: Control and Status register
Reset
Value: 0x00000000
ASS
If this bit is set, ss_pad_o signals are generated
automatically. This means that slave select signal, which is selected in SS
register is asserted by the SPI controller, when transfer is started by setting CTRL[GO_BSY] and
is de-asserted after transfer is finished. If this bit is cleared, slave select
signals are asserted and de-aserted by writing and clearing bits in SS
register.
IE
If this bit is set, the interrupt output is set
active after a transfer is finished. The Interrupt signal is deasserted after a
Read or Write to any register.
LSB
If this bit is set, the LSB is sent first on the
line (bit TxL[0]), and the first bit received from the line will be put in the
LSB position in the Rx register (bit RxL[0]). If this bit is cleared, the MSB
is transmitted/received first (which bit in TxX/RxX register that is depends on
the CHAR_LEN field in the CTRL register).
Tx_NEG
If this bit is set, the mosi_pad_o signal is changed
on the falling edge of a sclk_pad_o clock signal, or otherwise the mosi_pad_o
signal is changed on the rising edge of sclk_pad_o.
Rx_NEG
If this bit is set, the miso_pad_i signal is latched
on the falling edge of a sclk_pad_o clock signal, or otherwise the miso_pad_i
signal is latched on the rising edge of sclk_pad_o.
GO_BSY
Writing 1 to this bit starts the transfer. This bit
remains set during the transfer and is automatically cleared after the transfer
finished. Writing 0 to this bit has no effect.
Divider
register [DIVIDER]
Bit
#
|
31:16
|
15:0
|
Access
|
R
|
R/W
|
Name
|
Reserved
|
DIVIDER
|
Table 7: Divider register
Reset
Value: 0x0000ffff
DIVIDER
The value in this field is the frequency divider of
the system clock wb_clk_i to generate the serial clock on the output
sclk_pad_o. The desired frequency is obtained according to the following
equation:
fclk = fwb_clk_i / (DIVIDER + 1 )*2
Slave select register [SS]
Bit
#
|
31:8
|
7:0
|
Access
|
R
|
R/W
|
Name
|
Reserved
|
SS
|
Table 8: Slave Select register
Reset
Value: 0x00000000
SS
If CTRL[ASS] bit is cleared, writing 1 to any bit
location of this field sets the proper ss_pad_o line to an active state and
writing 0 sets the line back to inactive state. If CTRL[ASS] bit is set,
writing 1 to any bit location of this field will select appropriate ss_pad_o
line to be automatically driven to active state for the duration of the
transfer, and will be driven to inactive state for the rest of the time.