Skip to content

Top-level UART redux#47

Merged
elliotb-lowrisc merged 9 commits intolowRISC:mainfrom
elliotb-lowrisc:uart_redux
Feb 27, 2025
Merged

Top-level UART redux#47
elliotb-lowrisc merged 9 commits intolowRISC:mainfrom
elliotb-lowrisc:uart_redux

Conversation

@elliotb-lowrisc
Copy link
Contributor

Rework top-level UART tests to use ported OpenTitan test programs and introduce more randomisation.

See individual commits for details.

Copy link
Contributor

@marnovandermaas marnovandermaas left a comment

Choose a reason for hiding this comment

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

Nice work Elliot! When I run this code, I get an error that openpty is an undefined symbol. Is this because I'm missing a package?

// The first byte must be FF so we can differentiate this blob from ASCII sent
// by the ROM when it starts. FF is not UTF-8 / ASCII.
static const uint8_t kUartTxData[UART_DATASET_SIZE] = {
static volatile const uint8_t kUartTxData[UART_DATASET_SIZE] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this need to be volatile? It's constant right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is supposed to be overwritten by the DV, so is not so constant.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly, though in the case of the OT UART there are separate test programs for use in SiVal. I wonder if they could be merged with the DV ones, but have not yet looked into it. This may be one such thing that would need to change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, the change looks reasonable to me. This comment shouldn't block the merging of this PR.

This is a workaround for CHERIoT using interrupt-disabling backward
sentries to return from `irq_global_ctrl()`, thus removing the ability
to enable interrupts for more than a few cycles at a time.
Inlining the function removes the jump-and-link and associated
interrupt-disabling backward sentry, allowing the enabling
of interrupts to persist in the context of the caller and any
inheriting functions.

See CHERIoT-Platform/llvm-project#120
Correct the base address of the UART1 block and comment-out some
unused and clashing address `#define`s.
Mapping of interrupt ID to peripheral.
Hardcoded for now as we have don't have auto generation set-up.
A few changes were required to get `uart_tx_rx_test` to work:

- Gate clkmgr code with `#if` to avoid errors due to lacking clkmgr DIF.
- Rework interrupt handler to check the UART block for interrupt
  specifics due to PLIC having less detailed interrupts.
- Tweak console configuration due to lack of fast/backdoor logging.
No point in having these top-level monitors enabled by default.
They cannot do any meaningful checking without being provided with
configuration information telling what clock period, parity, etc.
to expect from the DUT.

It would be nice if one day the agents could figure out most of this
for themselves from the raw output.
No point in wasting runtime clocking the UART DPI model connected to
UART0 when it has been disconnected in favour of a UART UVM agent.
- Fix `kUartIdxDv` capitalisation error.
- Allow `uart_idx` to randomise.
- Prepare for future baud rate randomisation.
Switch from the initial hacky top-level UART test programs to the ones
ported from OpenTitan for increased randomisation.
Also introduce a new test that randomises baud rate and a new `uart`
regression test group.
@elliotb-lowrisc
Copy link
Contributor Author

Removed extern of irq_global_ctrl().

@elliotb-lowrisc
Copy link
Contributor Author

Nice work Elliot! When I run this code, I get an error that openpty is an undefined symbol. Is this because I'm missing a package?

Not sure what the problem is for you there. The only mention of openpty I can find in the code is in the UART DPI model (uartdpi.c), which I haven't touched. Perhaps there is a dependency missing somewhere.

@marnovandermaas
Copy link
Contributor

Hmmm, interesting. You're right. I saw this issue on Ubuntu 20.04. I tried fixing it by running https://opentitan.org/book/doc/getting_started/index.html#step-2-install-dependencies-using-the-package-manager but that didn't help.
Running inside the OpenTitan Nix container did however fix this issue. I've opened an issue to track setting up the Nix environment: #50

Copy link
Contributor

@marnovandermaas marnovandermaas left a comment

Choose a reason for hiding this comment

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

Ok, this runs successfully for me with the following command:
hw/vendor/lowrisc_ip/util/dvsim/dvsim.py hw/top_chip/dv/top_chip_sim_cfg.hjson -i uart --max-parallel 32

I've changed the default reseed to 10 in an additional commit, so I'll leave it up to you to press the merge button if you're happy with that.

@elliotb-lowrisc
Copy link
Contributor Author

I think 10 is a bit high for the global default for me. I'll remove your commit and merge my changes.

@elliotb-lowrisc elliotb-lowrisc merged commit 833d6d4 into lowRISC:main Feb 27, 2025
2 checks passed
@elliotb-lowrisc elliotb-lowrisc deleted the uart_redux branch February 27, 2025 10:22
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