Skip to content

[top,sw/dv] Clk pwr rst smoke tests#460

Open
csabakiss-semify wants to merge 4 commits into
lowRISC:mainfrom
csabakiss-semify:clk_pwr_rst_smoke_test
Open

[top,sw/dv] Clk pwr rst smoke tests#460
csabakiss-semify wants to merge 4 commits into
lowRISC:mainfrom
csabakiss-semify:clk_pwr_rst_smoke_test

Conversation

@csabakiss-semify
Copy link
Copy Markdown
Collaborator

  1. Added power manager related hal files
  2. Extended reset manager hal
  3. Extended clock manager hal
  4. Added smoke tests for the managers

I can see the conflicts, even if I just finished the rebase. However, I am opening this PR to start the review process. I will fix the further conflicts just before the merge.

@csabakiss-semify csabakiss-semify force-pushed the clk_pwr_rst_smoke_test branch 2 times, most recently from 2dbcd22 to 7adf270 Compare April 23, 2026 09:35
@martin-velay martin-velay changed the title Clk pwr rst smoke tests [top,sw/dv] Clk pwr rst smoke tests Apr 23, 2026
Copy link
Copy Markdown
Collaborator

@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.

Some initial comments from my end.

Comment thread sw/device/tests/rstmgr/smoketest.c
DEV_WRITE(rstmgr + RSTMGR_RESET_REQ_REG, RSTMGR_RESET_REQ_TRUE);
}

bool rstmgr_software_reset_info_get(rstmgr_t rstmgr)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we can now remove this function. I think it was only used in the software_reset test.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good point. The test now reads and clears the reset reason directly, so this function is not needed anymore. I will remove it from the HAL source and header.

Comment thread sw/device/lib/hal/clkmgr.c Outdated
Comment on lines +11 to +25
static uint32_t clkmgr_read(clkmgr_t clkmgr, uintptr_t reg)
{
return DEV_READ(clkmgr + reg);
}

static void clkmgr_write(clkmgr_t clkmgr, uintptr_t reg, uint32_t value)
{
DEV_WRITE(clkmgr + reg, value);
}

static uint32_t clkmgr_bit(size_t clock)
{
return 1u << clock;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These don't look like clock manager specific functions. Do they already exist elsewhere in the repo?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I did not find another helper for this, only the DEV_READ and DEV_WRITE macros. I added these local helpers to avoid repeating the same code in this file. I can also remove them and use DEV_READ/DEV_WRITE directly if you prefer.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Probably best to use DEV_READ and DEV_WRITE.

bool toggled = !initial;

clkmgr_gateable_clock_set_enabled(clkmgr, CLKMGR_GATEABLE_CLOCK_IO_PERI, toggled);
if (clkmgr_gateable_clock_get_enabled(clkmgr, CLKMGR_GATEABLE_CLOCK_IO_PERI) != toggled) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there any way that we can confirm that the peripherals are actually stopped? I'm not sure whether reading a register will cause a bus error or just hang the design.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't think this software smoke test can safely check that. If we read from a peripheral after stopping its clock, it may hang the design. This test only checks that the clkmgr registers can be written and read back correctly. I think checking that the clock really stops should be done in DV, where we can observe the clock signals directly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ok, this is fine. Thanks for confirming.

Comment thread sw/device/lib/hal/mocha.c Outdated
Comment thread sw/device/lib/hal/pwrmgr.c Outdated
Comment on lines +9 to +22
static uint32_t pwrmgr_read(pwrmgr_t pwrmgr, uintptr_t reg)
{
return DEV_READ(pwrmgr + reg);
}

static void pwrmgr_write(pwrmgr_t pwrmgr, uintptr_t reg, uint32_t value)
{
DEV_WRITE(pwrmgr + reg, value);
}

uint32_t pwrmgr_control_get(pwrmgr_t pwrmgr)
{
return pwrmgr_read(pwrmgr, PWRMGR_CONTROL_REG);
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Replicated from clock manager.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I copied the same style from clkmgr. I can keep both files like this, or I can remove these helpers and use DEV_READ/DEV_WRITE directly in both files.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes please use DEV_READ and DEV_WRITE.

Copy link
Copy Markdown
Contributor

@ziuziakowska ziuziakowska left a comment

Choose a reason for hiding this comment

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

Software side looks good. Just a small nit

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.

The convention for tests seems to be smoketest instead of smoke_test.

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.

(likewise for the clkmgr test).

@csabakiss-semify csabakiss-semify force-pushed the clk_pwr_rst_smoke_test branch 5 times, most recently from 5f1c44d to 9b76a67 Compare May 6, 2026 07:54
Comment thread hw/top_chip/dv/tb/tb.sv Outdated
Comment thread sw/device/tests/CMakeLists.txt
Comment thread sw/device/tests/CMakeLists.txt
Comment thread hw/top_chip/dv/top_chip_sim_cfg.hjson Outdated
@csabakiss-semify csabakiss-semify force-pushed the clk_pwr_rst_smoke_test branch 3 times, most recently from 3ef6837 to c8ae72c Compare May 8, 2026 07:32
Comment thread sw/device/lib/hal/clkmgr.c Outdated
#include <stddef.h>
#include <stdint.h>

static uint32_t clkmgr_read(clkmgr_t clkmgr, uintptr_t reg)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The autogenerated clkmgr header is on main, would you mind writting these new hal functions using the new abstraction?
Here is a example.

Signed-off-by: Csaba Kiss <csaba.kiss@semify-eda.com>
Signed-off-by: Csaba Kiss <csaba.kiss@semify-eda.com>
Signed-off-by: Csaba Kiss <csaba.kiss@semify-eda.com>
…ests to top level smoke regression and top level sim config

Signed-off-by: Csaba Kiss <csaba.kiss@semify-eda.com>
@martin-velay
Copy link
Copy Markdown
Contributor

I have checked out the branch and ran the UVM based top-level regression:
dvsim hw/top_chip/dv/mocha_sim_cfgs.hjson --select-cfgs top_mocha_sim -i smoke

Test Results

Stage Name Tests Max Job Runtime Simulated Time Passing Total Pass Rate
rv_timer_irq 105.000s 3092.983us 1 1 100.00 %
spi_host_smoke 70.000s 1515.417us 1 1 100.00 %
spi_host_smoke_cheri 97.000s 1808.465us 1 1 100.00 %
spi_device_smoke_cheri 102.000s 2354.524us 0 1 0.00 %
rom_ctrl_smoke 0.846s 0.000us 0 1 0.00 %
test_framework_exception_test_cheri 106.000s 2370.587us 1 1 100.00 %
gpio_smoke_cheri 96.000s 1891.201us 1 1 100.00 %
rom_ctrl_smoke_cheri 0.805s 0.000us 0 1 0.00 %
rv_timer_smoke_cheri 91.000s 2089.047us 1 1 100.00 %
rstmgr_smoke 102.000s 2856.330us 1 1 100.00 %
pwrmgr_smoke_cheri 99.000s 1865.492us 1 1 100.00 %
mailbox_smoke_cheri 85.000s 1863.523us 1 1 100.00 %
gpio_smoke 96.000s 1578.978us 1 1 100.00 %
rv_timer_irq_cheri 105.000s 3467.145us 1 1 100.00 %
axi_sram_smoke 88.000s 1520.691us 1 1 100.00 %
rv_plic_smoke 95.000s 1666.383us 1 1 100.00 %
rstmgr_smoke_cheri 111.000s 3409.617us 1 1 100.00 %
spi_device_smoke 101.000s 2003.784us 0 1 0.00 %
uart_smoke 92.000s 2041.267us 1 1 100.00 %
axi_sram_smoke_cheri 93.000s 1808.661us 1 1 100.00 %
clkmgr_smoke 90.000s 1559.275us 1 1 100.00 %
rv_timer_smoke 98.000s 1766.778us 1 1 100.00 %
mailbox_smoke 82.000s 1561.158us 1 1 100.00 %
pwrmgr_smoke 77.000s 1561.964us 1 1 100.00 %
uart_smoke_cheri 99.000s 2351.453us 1 1 100.00 %
clkmgr_smoke_cheri 102.000s 1873.857us 1 1 100.00 %
test_framework_exception_test 94.000s 1995.936us 1 1 100.00 %
rv_plic_smoke_cheri 83.000s 2004.322us 1 1 100.00 %
TOTAL 24 28 85.71 %
TOTAL 24 28 85.71 %

Copy link
Copy Markdown
Contributor

@martin-velay martin-velay left a comment

Choose a reason for hiding this comment

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

According to the regression mentioned above, results LGTM. Thanks Csaba

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.

5 participants