Skip to content

[otbn,dv] Add WFI testpoint and tests - #30918

Open
etterli wants to merge 4 commits into
lowRISC:masterfrom
etterli:otbn-wfi-testing
Open

[otbn,dv] Add WFI testpoint and tests#30918
etterli wants to merge 4 commits into
lowRISC:masterfrom
etterli:otbn-wfi-testing

Conversation

@etterli

@etterli etterli commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This PR is based on #30917 and can only be merged afterwards (thus a draft PR). Only the last 4 commits are relevant.

This PR adds a testpoint for the WFI feature (or here) as well as the required tests.

Please note that I have limited DV experience. Feel free to discard the current vseqs. These serve as starting points.

@etterli
etterli requested a review from a team as a code owner August 4, 2026 14:13
@etterli
etterli requested review from rswarbrick and removed request for a team August 4, 2026 14:13
@etterli
etterli marked this pull request as draft August 4, 2026 14:14
Comment thread hw/ip/otbn/dv/directed/wfi/wfi_smoke.s Outdated
Comment on lines +13 to +14
* After resuming, load the word at DMEM address 0. This tests that the ISS observes the same new
* value as the RTL (if the host wrote to DMEM).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd probably switch the order to "RTL ... the same as the ISS", which sounds a bit more like the ISS is defined to be correct :-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This test is now obsolete as I switched the smoke test to use the already existing top level test.

Comment on lines +56 to +57
`DV_CHECK_FATAL(uvm_hdl_read(status_path, rtl_status),
$sformatf("Failed to read STATUS from `%0s'", status_path))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not a big fan of this! Can't we wait by repeatedly reading the STATUS register with no backdoors?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True, this is ugly. I've replaced it with a simpler STATUS register polling.

Comment on lines +63 to +66
// Stay paused for a random number of cycles.
resume_delay = $urandom_range(max_resume_delay, min_resume_delay);
`uvm_info(`gfn, $sformatf("Paused, waiting %0d cycles before RESUME", resume_delay), UVM_LOW)
cfg.clk_rst_vif.wait_clks(resume_delay);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why add an extra wait? If there's a good reason, it will need describing carefully here and also in the testpoint. If not, I suggest dropping the unnecessary code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hm, I added this just to not always read on the same cycle. But its meaningless. The only really good edge case would be to read in the very first pause cycle. But this code does not do this anyway. I removed it.


// Wait until the program has ended.
`DV_WAIT(cfg.model_agent_cfg.vif.status == otbn_pkg::StatusIdle)
`uvm_info(`gfn, "OTBN finished after RESUME", UVM_LOW)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't we need the OTBN application to finish the handshake? I would suggest it does something like copying the value that we wrote and putting it at address 0x4. Then the virtual sequence can load that word and check it's the value that we wrote in the first place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That is a good point. This smoke test here was my very first test. But in the meantime I wrote a top level test which is more evolved. I have now changed the smoke vseq to use this test. The test can be found at sw/otbn/wfi/wfi_test.s.

@etterli etterli left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @rswarbrick for the good inputs. The smoke tests now uses the top level test which checks more stuff.

Comment thread hw/ip/otbn/dv/directed/wfi/wfi_smoke.s Outdated
Comment on lines +13 to +14
* After resuming, load the word at DMEM address 0. This tests that the ISS observes the same new
* value as the RTL (if the host wrote to DMEM).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This test is now obsolete as I switched the smoke test to use the already existing top level test.

Comment on lines +56 to +57
`DV_CHECK_FATAL(uvm_hdl_read(status_path, rtl_status),
$sformatf("Failed to read STATUS from `%0s'", status_path))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True, this is ugly. I've replaced it with a simpler STATUS register polling.


// Wait until the program has ended.
`DV_WAIT(cfg.model_agent_cfg.vif.status == otbn_pkg::StatusIdle)
`uvm_info(`gfn, "OTBN finished after RESUME", UVM_LOW)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That is a good point. This smoke test here was my very first test. But in the meantime I wrote a top level test which is more evolved. I have now changed the smoke vseq to use this test. The test can be found at sw/otbn/wfi/wfi_test.s.

Comment on lines +63 to +66
// Stay paused for a random number of cycles.
resume_delay = $urandom_range(max_resume_delay, min_resume_delay);
`uvm_info(`gfn, $sformatf("Paused, waiting %0d cycles before RESUME", resume_delay), UVM_LOW)
cfg.clk_rst_vif.wait_clks(resume_delay);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hm, I added this just to not always read on the same cycle. But its meaningless. The only really good edge case would be to read in the very first pause cycle. But this code does not do this anyway. I removed it.

@etterli

etterli commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Moved the WFI test programs to the sw/otbn/wfi folder. Now all test software is at the same location.

Adds new testpoints to test the WaitForInterrupt feature.

Signed-off-by: Pascal Etterli <pascal.etterli@lowrisc.org>
This adds a simple sequence which runs an OTBN program with a WFI instruction. It then lets OTBN
resume and checks that it did resume properly.

Signed-off-by: Pascal Etterli <pascal.etterli@lowrisc.org>
This adds a directed test to check that an escalation is properly handled whilst OTBN is paused by a
WFI instruction.

Signed-off-by: Pascal Etterli <pascal.etterli@lowrisc.org>
Signed-off-by: Pascal Etterli <pascal.etterli@lowrisc.org>
@etterli

etterli commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on merged #30917. This is now ready.

@etterli
etterli marked this pull request as ready for review August 10, 2026 12:21
@etterli
etterli requested a review from rswarbrick August 10, 2026 12: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