UART Bus
The UART bus interface allows you to decode traffic sent over UART transmit and receive. In order to decode the traffic, a number of parameters need to be set based on your knowledge how the UART bus should be operating.
Creating a UART Bus
To create a UART bus, a TX (transmit) net and RX (receive) net need to be instantiated.
from lager import Net, NetType, UART
tx = Net.get('UART.TX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
rx = Net.get('UART.RX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
uart = UART(tx=tx,rx=rx)
uart.enable()
~ lager bus uart --source-tx UART.TX --source-rx UART.RX --dut 1
BAUD
This sets the assumed BAUD rate of the UART bus being decoded.
from lager import Net, NetType, UART
tx = Net.get('UART.TX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
rx = Net.get('UART.RX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
uart = UART(tx=tx,rx=rx)
uart.set_baud(115200)
~ lager bus uart --baud 115200 --dut 1
Parity
This sets the assumed parity (e.g. none, even, odd) of the UART bus being decoded.
from lager import Net, NetType, UART
tx = Net.get('UART.TX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
rx = Net.get('UART.RX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
uart = UART(tx=tx,rx=rx)
uart.set_parity_none()
~ lager bus uart --parity none --dut 1
Polarity
This sets the assumed polarity of the UART Bus signals. Typically the polarity is negative (i.e. idle high), however some systems have the polarity inverted.
from lager import Net, NetType, UART
tx = Net.get('UART.TX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
rx = Net.get('UART.RX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
uart = UART(tx=tx,rx=rx)
uart.set_polarity_negative()
~ lager bus uart --polarity neg --dut 1
Endianness
This sets the assumed endiannes of the UART Bus signals. Typically this will be MSB (most significant bit).
from lager import Net, NetType, UART
tx = Net.get('UART.TX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
rx = Net.get('UART.RX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
uart = UART(tx=tx,rx=rx)
uart.set_endianness_msb()
~ lager bus uart --endianness msb --dut 1
Stop Bits
This sets the assumed number of stop bits (1, 1.5, 2) in the UART Bus data packet.
from lager import Net, NetType, UART
tx = Net.get('UART.TX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
rx = Net.get('UART.RX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
uart = UART(tx=tx,rx=rx)
uart.set_stop_bits(1)
~ lager bus uart --stop-bits 1 --dut 1
Data Bits
This sets the assumed number of data bits(5 to 9) in each UART byte being sent or received.
from lager import Net, NetType, UART
tx = Net.get('UART.TX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
rx = Net.get('UART.RX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
uart = UART(tx=tx,rx=rx)
uart.set_data_bits(8)
~ lager bus uart --data-bits 8 --dut 1
Packet Ending
This is an optional setting that allows you to let the decoder know if there is an end byte such as null, line-feed, etc.
from lager import Net, NetType, UART
tx = Net.get('UART.TX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
rx = Net.get('UART.RX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
uart = UART(tx=tx,rx=rx)
uart.set_packet_ending_lf()
~ lager bus uart --packet-ending lf --dut 1
Signal Threshold
This sets the assumed voltage threshold a rising or falling UART signal should pass through.
from lager import Net, NetType, UART
tx = Net.get('UART.TX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
rx = Net.get('UART.RX',
type=NetType.Logic,
setup_function=setup_nets,
teardown_function=teardown_nets)
uart = UART(tx=tx,rx=rx)
uart.set_signal_threshold(tx=1.5, rx=1.5)
~ lager bus uart --level-tx 1.5 --level-rx 1.5 --dut 1