Communication Protocols
Communication Protocols
Devices
Communication • Sensors
• A-to-D converters
Protocols • D-to-A
• Memory
Notes and/or Reference • Microcontrollers
• Etc…
• Serial (UART) (still common in random devices, reliable and Parallel Link: Serial Link:
easy to implement)
SPI
Master MISO Slave
Device Device 1
SCK MCP3008 is a 8-channel 10 bit ADC from
CE0/CS0 Microchip Semi that communicates over
SPI
• Can share MOSI/MISO Bus so the wire
requirement scales as 3 + # where # is Slave CMOD-A7-35T
MCP3008
CE1/CS1
• Addition of multiple slaves requires Here I am talking to a MCP3008 10 bit ADC
• Hardware/firmware for SPI is pretty MOSI Sends its data MSB first
easy to implement: X X 1 1 0 0 1 X X X X X X X X X X X X X
SPI* Master
Device
MISO
SCK
Slave
Device
4.7kΩ
• inout is an “input-output”…needs some special inout sda;
logic sda_val;
handling...you can both write to them (only using assign sda = sda_val? 1’bz: 1’b0; SDA
combinational logic) and read from them...the Wanna write to SDA? SDA in
usual way to work with them is the following: sda_val <= 0; //or 1 if desired
driving it LO
• Data is sent MSB first Data from SDA sampled @ posedge of SCL
State-Machine
Implementation of i2C START1
Master
ACKNACK1A
STOP IDLE IDLE
ADDRESS1 READWRITE1
ACKNACK1C
NACK
7x
• Redundant states (repeated
READ/WRITE, ADDRESS, ACK/NACK, NACK ACK
READ3
etc…) ADDRESS2
ADDRESS3
8x
REGISTER1
ACK4
• ARM manual describes ~20 state READ4 7x
FSM for full I2C…this is just a toy 8x
implementation of specific I2C START2
operation
ADDRESS4
READ2 ACKNACK3A REGISTER2
GND GND
SCL SCL
MA
ST E
Nexys4 Acknowledge=0 ReStart MPU9250
R AC
Write=0 Read=1 Acknowledge=0
K
Device Address (0x68) Device Address (0x68) Data Read In
Start Device Register (0x3B)
1 0 1 1 0 1 0 0 0 0 0 0 0 1 1 1 0 1 1 0 1 0 0 1 1 0 1 0 0 0 1 0 0 1 1 0 1 1 1 0 0 1 0 1 1 0 1 0 0 0 0 0 0 0 1 1 1 0 1 1 0 1 0 0 1 1 0 1 0 0 0 1 0 0 1 1 0 1 1 1 0 0
SDA
SDA
01010101010101010101010101010101010101110101010101010101010101010101010101010 … 01010101010101010101010101010101010101110101010101010101010101010101010101010 …
SCL
SCL
GND
SCL
SDA MPU9250
Nexys4
SDA = Yellow
1 0 1 1 0 1 0 0 0 0 0 0 0 1 1 1 0 1 1 0 1 0 0 1 1 0 1 0 0 0 1 0 0 1 1 0 1 1 1 0 0 SCL = Purple
SDA
SCL
01010101010101010101010101010101010101110101010101010101010101010101010101010 …
Nexys4 (Master Device) Dialog MPU9250 (Slave Device) Dialog
Triggered on leaving IDLE state
SCL:
Horizontal: Vertical:
16’hFD88 = 16’b1111_1101_1000_1000 (2’s complement) 16’h4088 = 16’b0100_0000_1000_1000 (2’s complement) Once Slave goes HiZ again, Master
Flip bits to get magnitude: 16’b0000_0010_0111_0111 Leave bits to get magnitude: 16’b0100_0000_1000_1000 picks back up on SCL
=-315 =+16520
Full-scale (default +/- 2g) Full-scale (default +/- 2g) • Allows Slave a way to buy time/slow down things (if it requires
-315/(2**15)*2g = -0.02g J makes sense -16520/(2**15)*2 = +1.01g J makes sense! multiple clock cycles to process incoming data and/or generate
output)
democratic Master Releases Bus (STOP) • Intended for Digitized Stereo Data
By pulling SDA HI while SCL is HI
Master Claims Bus (START)
Idle State By pulling SDA LOW while SCL is HI • Three Wires:
SDA and SCL sit HI
• SDA: Serial Data (The actual music)
SDA: HI • WS: Word Select (Left/Right Channel)
• SCL: Serial Clock (For Synchronization)
LO
• Push-Pull Driving (like SPI…no need for pull-up resistors)
• Devices can be design to yield based on who claims a bus first…but • Data sent MSB first
you have to be careful…what if two devices claim a bus at the same
time…potential problems? Can get bus contention so need to be • Clock-rate dictated by sample rate (44.1kHz @16 bits per
careful channel /w 2 channels = ~1.4 MHz for example
10/22/19 6.111 Fall 2019 39 10/22/19 6.111 Fall 2019 40
i2S Implementation
• You’ve built a UART/serial module already…it was
pretty short/easy
• Vivado has IP cores for i2C Master and i2S Masters
• SPI is much more open to interpretation and loose
on its specs so no default core that I can find:
• I put some generic skeleton code on github/site with a
FIFO buffer that can get folks started if they need it.
AXI
Communication AXI
AXI
Talking Between Modules on the same Chip (Systems on a
Chip)
Payload
Payload
Supplemental
Supplemental
Stuff
Stuff
CORE CORE
Payload
Write Response
Payload
CORE
CORE
Generalized Transaction
Payload
CORE
10/22/19 6.111 Fall 2019 61 10/22/19 6.111 Fall 2019 62
And you Can Use AXI to Interface And you Can Use AXI to Interface
with Tons of things! with Tons of things!
Connecting a FIR (from a Xilinx IP) to the FFT module Creating a AXI-controlled joe6 module that I can then call from Python
Thi
s
s p e is th e
s u r c s h e e th in g
Others than AXI? Sources
p ri s t
ing /man right h
ly g u a l
o o d i s e re … t
!! he