Skip to content

Comments

Add CBOR transactors for UART, I2C, JTAG, SPI and SWD#3

Open
imateosd wants to merge 37 commits intonipo:masterfrom
imateosd:cbor_transactors
Open

Add CBOR transactors for UART, I2C, JTAG, SPI and SWD#3
imateosd wants to merge 37 commits intonipo:masterfrom
imateosd:cbor_transactors

Conversation

@imateosd
Copy link

I2C, SPI, JTAG, SWD, UART transactors

This merge request adds new transactor implementations for I2C, SPI, JTAG, SWD and UART. It introduces new command and response formats for the transactors based in CBOR-encoded payloads. The descriptions of the encoded command and responses are in the cbor_transactor packages of each protocol library.
The transactors have AXI-Stream command/response interfaces instead of BNOC interfaces.

EZ-USB-FX2 interface

It also adds an AXI-Stream interface for Cypress' EZ-USB-FX2 controller in Slave FIFO mode with synchronous R/W. Three variants:

Simulation/testing helpers

The following packages have been introduced or expanded:

  • nsl_amba/axi4_stream: added check_status boolean output overloads to all *_check_* functions. They are meant to be used together with the changes in nsl_simulation/logging and nsl_simulation/tests_reports.
  • nsl_simulation/logging: added colored log output with severity levels, added test step result aggregation with pass/fail counters.
  • nsl_simulation/test_reports: added generator for structured test reports for machine-parseable test results independently of backend.
  • nsl_simulation/shell: VHPIDIRECT-based background process execution for command execution during simulation.

Supporting library changes

  • nsl_amba/stream_sized: added support for sized frames (2-byte header containts the size of the frame) for AXI-Stream, equivalent to BNOC's implementation.
  • nsl_amba/control_status: added AXI-Stream-mapped control/status register set, similar to the one already available for BNOC.
  • nsl_data/cbor: added fixed-width overloads for encoding functions. Also added bstr and tstr header generation functions. Renamed "undefinite" to "indefinite" throughout.
  • nsl_data/bytestream: added "+" operator for byte_string concatenation.
  • nsl_uart/serdes: added uart_tx_no_generics and uart_rx_no_generics, which take UART configuration (baud divisor, bit count, parity, stop bits) as signal inputs instead of generics to allow runtime reconfiguration. Used by the UART transactor.

Minor bug fix

  • nsl_spi/io_extender: fixed data_i changes being lost when they occur during the processing of the previous value.

Automatic testing infrastructure using pytest

  • Added tests/conftest.py that discovers VHDL testbenches, runs GHDL simulations via make run, parses structured report.txt results and exposes each VHDL test case as a pytest item with JUnit XML output.
  • Added Dockerfile for the GHDL simulation environment and Jenkinsfile for CI.
  • Added testbenches for all five CBOR transactors, AXI-Stream sized modules, UART serdes, EZ-USB-FX2 controllers, logging, and test reports.

…er functions and change 'undefinite' to 'indefinite'
…the processing of the previous one and chain back to back updates
… inputs and not generics to allow for runtime configuration
@imateosd imateosd marked this pull request as ready for review February 12, 2026 15:55
Copy link
Owner

@nipo nipo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this is an interesting set of changes.
The second half of the commits that are changes and fixes on files introduced in the same PR should be reordered and squashed into relevant changes.

-- Serializes a number, depending on sign of the value parameter, it
-- spills a positive or negative item
function cbor_number(value: integer) return byte_string;
function cbor_number(value: unsigned) return byte_string;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A signed would be better here.

-- with the minimum count of bytes. Passed value is the actual value
-- (negative).
function cbor_negative(value: integer) return byte_string;
function cbor_negative(value: unsigned) return byte_string;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A signed would be better here.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe splitting the undefinite -> indefinite changes from the rest would help review.

function to_string(level : log_level_t) return string;

function ansi_escape(command : character;
arg0 : integer := - 1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid space after unary -

function "and"(l, r : byte_string) return byte_string;
function "or"(l, r : byte_string) return byte_string;
function "xor"(l, r : byte_string) return byte_string;
function "+"(l, r : byte_string) return byte_string;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concatination operator for VHDL is &, and it is implicitly defined for arrays like byte_string. Do we really need + to be basically an alias?


component uart_tx_no_generics is
generic(
bit_count_c : natural range 7 to 8
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be made a runtime config as well.

end case;
end function;

-- Lookup table function to convert divisor to baud rate
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than having a divisor, you may as well have an accumulator where:

  • on each cycle, add baud rate,
  • if accumulated value is more than system clock, a bit time passed, substract system clock

This is a functionality could be added in nsl_event.tick library by taking inspiration in nsl_signal_generator.frequency.frequency_generator.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit could be split, reordered and squashed with relevant library changes

Default.wcfg
isim1.wdb
*.gtkw
**/nsl_simulation/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ignoring this pattern?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be reordered and squashed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants