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.

create_uart_bus.py
 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()
Create UART Bus
~  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.

set_uart_baud.py
 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)
Set UART Bus BAUD
~  lager bus uart --baud 115200 --dut 1

Parity

This sets the assumed parity(e.g. none, even, odd) of the UART bus being decoded.

set_uart_parity.py
 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()
Set UART Bus Parity
~  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.

set_uart_polarity.py
 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()
Set UART Bus Polarity
~  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).

set_uart_endianness.py
 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()
Set UART Bus Endianness
~  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.

set_uart_stop_bits.py
 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)
Set UART Bus Stop Bits
~  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.

set_uart_data_bits.py
 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)
Set UART Bus Data Bits
~  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.

set_uart_packet_end.py
 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()
Set UART Bus Packet Ending
~  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.

set_uart_threshold.py
 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)
Set UART Bus Threshold
~  lager bus uart --level-tx 1.5 --level-rx 1.5 --dut 1