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, prim_reg_cdc_arb] Conditional coverage simplification #26028

Conversation

antmarzam
Copy link
Contributor

@antmarzam antmarzam commented Jan 27, 2025

end else if (dst_req_i && !dst_req_q && busy) begin is equivalent to
end else if (dst_req_i && busy) begin.

In order to guarantee the above happens an assertion has been added checking:
dst_req_i |-> !dst_req_q

The reasoning for the simplification is:

In prim_reg_cdc, we expect to see a request that comes from the SW
as a signal on the src domain (either src_we_i or src_re_i).
This gets synchronised to the destination clock by
u_src_to_dst_req.
This then appears to the arbiter as dst_req_i.
If there is another request in flight (probably an update from HW),
the SW request get stored in the dst_req_q register.
The stored request gets cleared on the first posedge of the dst
clock after the previous request is complete, because it causes
dst_lat_d to be high.
To see dst_req_i && dst_req_q, we would need prim_reg_cdc to
send another request before that happened.
When the first SW request appears in prim_reg_cdc, we set busy
until we see src_ack.
This goes high when the SW request has been synchronised to the
dst clock by u_dst_update_sync.
As such, we can't see another request from prim_reg_cdc before
src_req_q has been cleared. Clearing src_req_q takes exactly one
clock crossing time and allowing prim_reg_cdc to send the second
request takes the same time.

This is part of the efforts to close code coverage for AON timer and taken as
feedback from Rupert in PR:
#25705 (comment)

hw/ip/prim/rtl/prim_reg_cdc_arb.sv Outdated Show resolved Hide resolved
hw/ip/prim/rtl/prim_reg_cdc_arb.sv Outdated Show resolved Hide resolved
@antmarzam antmarzam force-pushed the prim_reg_cdc_arb_rtl_cond_ccov_simplification branch from 118230f to 83de710 Compare January 27, 2025 17:41
Copy link
Contributor

@rswarbrick rswarbrick left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks.

@rswarbrick
Copy link
Contributor

CHANGE AUTHORIZED: hw/ip/prim/rtl/prim_reg_cdc_arb.sv

The behaviour shouldn't change (as "derived" reasonably carefully and described in the commit message). The assertion will explode in DV if we've got something wrong.

@rswarbrick rswarbrick requested a review from alees24 January 28, 2025 16:26
@alees24
Copy link
Contributor

alees24 commented Jan 28, 2025

CHANGE AUTHORIZED: hw/ip/prim/rtl/prim_reg_cdc_arb.sv

@alees24
Copy link
Contributor

alees24 commented Jan 28, 2025

@antmarzam Could you fix the first two lines of the commit message, please, just to clarify?

`end else if (dst_req_i && !dst_req_q && busy) begin` is equivalent to
`end else if (dst_req_i && busy) begin`.

In order to guarantee the above happens an assertion has been added checking:
`dst_req_i |-> !dst_req_q`

The reasoning for the simplification is:

In prim_reg_cdc, we expect to see a request that comes from the SW
as a signal on the src domain (either src_we_i or src_re_i).
This gets synchronised to the destination clock by
u_src_to_dst_req.
This then appears to the arbiter as dst_req_i.
If there is another request in flight (probably an update from HW),
the SW request get stored in the dst_req_q register.
The stored request gets cleared on the first posedge of the dst
clock after the previous request is complete, because it causes
dst_lat_d to be high.
To see dst_req_i && dst_req_q, we would need prim_reg_cdc to
send another request before that happened.
When the first SW request appears in prim_reg_cdc, we set busy
until we see src_ack.
This goes high when the SW request has been synchronised to the
dst clock by u_dst_update_sync.
As such, we can't see another request from prim_reg_cdc before
src_req_q has been cleared. Clearing src_req_q takes exactly one
clock crossing time and allowing prim_reg_cdc to send the second
request takes the same time.

This is part of the efforts to close code coverage for AON timer and taken as
feedback from Rupert in PR:
lowRISC#25705 (comment)

Signed-off-by: Antonio Martinez Zambrana <[email protected]>
@antmarzam antmarzam force-pushed the prim_reg_cdc_arb_rtl_cond_ccov_simplification branch from 83de710 to 43754a0 Compare January 28, 2025 17:07
@antmarzam
Copy link
Contributor Author

@alees24 Just pushed the changes amending the commit

@rswarbrick rswarbrick merged commit dd44869 into lowRISC:master Jan 29, 2025
37 of 38 checks passed
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.

3 participants