Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rtl,clkmgr] Fix missing jitter regwen #26259

Merged
merged 2 commits into from
Feb 14, 2025

Conversation

matutem
Copy link
Contributor

@matutem matutem commented Feb 12, 2025

This has two commits:

  • Fix the clkmgr hjson file to connect jitter_regwen to jitter_enable
  • Enhance unit an top level tests for this feature
    • Add dif support for this as required
    • Fix clkmgr_frequency block level test to disable an assertion that is intentionally violated

Fixes #26258

@matutem matutem requested review from a team as code owners February 12, 2025 01:05
@matutem matutem requested review from rswarbrick, moidx and vogelpi and removed request for a team February 12, 2025 01:05
Comment on lines +14 to +15
mubi4_t prev_value;
mubi4_t new_value;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I'd change the names to something like value0, value to avoid it looking like prev_value was the value that the register had before this task.

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 was the value before this task is called to change it to new_value.

/**
* Checks if the jitter enable register is locked.
*
* Jitter enable register is locked by CLKMGR_JITTER_REGWEN.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should probably be "The jitter enable ..." ? (Similarly for "The external clock ..." below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks :)

@moidx
Copy link
Contributor

moidx commented Feb 12, 2025

CHANGE AUTHORIZED: hw/top_earlgrey/ip_autogen/clkmgr/data/clkmgr.hjson
CHANGE AUTHORIZED: hw/top_earlgrey/ip_autogen/clkmgr/rtl/clkmgr_reg_top.sv

Copy link
Contributor

@moidx moidx left a comment

Choose a reason for hiding this comment

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

Thanks @matutem. LGTM.

Copy link
Contributor

@vogelpi vogelpi left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @matutem !

@@ -187,8 +187,10 @@
jitter_o clkmgr output to toggle. Verify this output is connected to AST's
clk_src_sys_jen_i input using formal.

If jitter_regwen is enabled check that jitter_enable can be toggled.
If jitter_regwen is disabled check that jitter_enable cannot be changed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: the test always disables the jitter_regwen and then checks that jitter_enable cannot be changed. I think this is great. The test can run independent whether the jitter_enable is locked already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test depends on the current state of jitter_regwen: if it is unlocked it checks that jitter_enable can be flipped, and if locked it checks it cannot. This is per line 50 in clkmgr_jitter_test.c.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is correct. What I meant is: after the if on line 50, the code enters the function which first disables the regwen and then tries changing the value. This part is executed independent whether the jitter_regwen is enabled or disabled when the test starts.

So one could change the test description to something like:

If jitter_regwen is enabled check that jitter_enable can be toggled, and disable jitter_regwen afterwards.
If jitter_regwen is disabled check that jitter_enable cannot be changed.

But it's not that important. The great thing is that this is now properly tested :-)

// This checks there are no errors.
CHECK_STATUS_OK(clkmgr_testutils_check_measurement_counts(&clkmgr));
CHECK_STATUS_OK(clkmgr_testutils_disable_clock_counts(&clkmgr));
if (kDeviceType == kDeviceSimDV || kDeviceType == kDeviceSilicon) {
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC, you added a print statement in earlgrey_1.0.0 to notify the user that we don't check this on FPGA. This would probably be useful here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks

@matutem
Copy link
Contributor Author

matutem commented Feb 14, 2025

CHANGE AUTHORIZED: hw/top_earlgrey/ip_autogen/clkmgr/data/clkmgr.hjson
CHANGE AUTHORIZED: hw/top_earlgrey/ip_autogen/clkmgr/rtl/clkmgr_reg_top.sv

Enhance testing at block and top level.
Enhance clkmgr dif for this feature.

Fixes lowRISC#26258

Signed-off-by: Guillermo Maturana <[email protected]>
@matutem matutem force-pushed the fix_missing_jitter_regwen branch from 36e6a95 to 9ebaa40 Compare February 14, 2025 16:01
@matutem matutem merged commit 83fd4eb into lowRISC:master Feb 14, 2025
42 checks passed
@matutem matutem deleted the fix_missing_jitter_regwen branch February 14, 2025 21:49
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.

[rtl,clkmgr] Fix missing regwen in jitter_enable
4 participants