-
Notifications
You must be signed in to change notification settings - Fork 5
Add br_cdc_stable_data_autoupdate module #999
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
| // Bedrock-RTL Stable Data CDC | ||
| // | ||
| // This is a thin wrapper around br_cdc_reg for synchronizing an infrequently | ||
| // changing multi-bit value. The register updates with the value of src_data | ||
| // when src_valid is asserted and holds the value on dst_data until the next time | ||
| // src_valid is asserted. | ||
| // | ||
|
|
||
| `include "br_asserts_internal.svh" | ||
| `include "br_registers.svh" | ||
| `include "br_unused.svh" | ||
|
|
||
| module br_cdc_stable_data #( | ||
| parameter int Width = 1, // Must be at least 1 | ||
| // The initial value of the destination-side register. | ||
| // dst_data will hold this value until the first time src_valid=1 | ||
| parameter logic [Width-1:0] InitValue = '0, | ||
| // If 1 (the default), register push_rst on push_clk and pop_rst on pop_clk | ||
| // before sending to the CDC synchronizers. This adds one cycle to the cut-through | ||
| // latency and one cycle to the backpressure latency. | ||
| // Do not set this to 0 unless push_rst and pop_rst are driven directly by | ||
| // registers. | ||
| parameter bit RegisterResetActive = 1, | ||
| // Number of synchronization stages to use. Must be at least 1. | ||
| // WARNING: Setting this parameter correctly is critical to | ||
| // ensuring a low probability of metastability. | ||
| // The recommended value is 3 for most technology nodes. | ||
| // Do not decrease below that unless you have a good reason. | ||
| parameter int NumSyncStages = 3 | ||
| ) ( | ||
| input logic src_clk, | ||
| input logic src_rst, | ||
| input logic src_valid, | ||
| input logic [Width-1:0] src_data, | ||
|
|
||
| input logic dst_clk, | ||
| input logic dst_rst, | ||
| output logic dst_updated, | ||
| output logic [Width-1:0] dst_data | ||
| ); | ||
| // Integration Checks | ||
| // Only used for assertion | ||
| logic src_ready; | ||
|
|
||
| // Rely on submodules for static parameter checks | ||
|
|
||
| `BR_ASSERT_CR_INTG(no_reg_overflow_A, src_valid |-> src_ready, src_clk, src_rst) | ||
|
|
||
| // Implementation | ||
| logic dst_updated_next; | ||
| logic [Width-1:0] dst_data_next; | ||
|
|
||
| br_cdc_reg #( | ||
| .Width(Width), | ||
| .RegisterResetActive(RegisterResetActive), | ||
| .NumSyncStages(NumSyncStages), | ||
| // There shouldn't be push backpressure | ||
| .EnableCoverPushBackpressure(0) | ||
| ) br_cdc_reg_inst ( | ||
| .push_clk (src_clk), // ri lint_check_waive SAME_CLOCK_NAME | ||
| .push_rst (src_rst), | ||
| .push_valid(src_valid), | ||
| .push_ready(src_ready), | ||
| .push_data (src_data), | ||
|
|
||
| .pop_clk(dst_clk), // ri lint_check_waive SAME_CLOCK_NAME | ||
| .pop_rst(dst_rst), | ||
| .pop_ready(1'b1), | ||
| .pop_valid(dst_updated_next), | ||
| .pop_data(dst_data_next) | ||
| ); | ||
|
|
||
| `BR_REGX(dst_updated, dst_updated_next, dst_clk, dst_rst) | ||
| `BR_REGLIX(dst_data, dst_data_next, dst_updated_next, InitValue, dst_clk, dst_rst) | ||
| `BR_UNUSED(src_ready) | ||
|
|
||
| // Implementation checks | ||
| // TODO(zhemao): Add some here | ||
|
|
||
| endmodule |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
| // Bedrock-RTL Stable Data CDC with Automatic Update | ||
| // | ||
| // This is a thin wrapper around br_cdc_stable_data that generates the src_valid signal | ||
| // automatically based on whether the src_data signal has been changed. | ||
| // | ||
|
|
||
| `include "br_asserts_internal.svh" | ||
| `include "br_registers.svh" | ||
|
|
||
| module br_cdc_stable_data_autoupdate #( | ||
| parameter int Width = 1, | ||
| parameter logic [Width-1:0] InitValue = '0, | ||
| parameter bit RegisterResetActive = 1, | ||
| parameter int NumSyncStages = 3 | ||
| ) ( | ||
| input logic src_clk, | ||
| input logic src_rst, | ||
| input logic [Width-1:0] src_data, | ||
|
|
||
| input logic dst_clk, | ||
| input logic dst_rst, | ||
| output logic dst_updated, | ||
| output logic [Width-1:0] dst_data | ||
| ); | ||
| // Integration Checks | ||
| // Rely on checks in br_cdc_stable_data submodule | ||
|
|
||
| // Implementation | ||
| logic src_valid; | ||
| logic [Width-1:0] src_data_reg; | ||
|
|
||
| `BR_REGLIX(src_data_reg, src_data, src_valid, InitValue, src_clk, src_rst) | ||
|
|
||
| assign src_valid = src_data != src_data_reg; | ||
|
|
||
| br_cdc_stable_data #( | ||
| .Width(Width), | ||
| .InitValue(InitValue), | ||
| .RegisterResetActive(RegisterResetActive), | ||
| .NumSyncStages(NumSyncStages) | ||
| ) br_cdc_stable_data_inst ( | ||
| .src_clk, | ||
| .src_rst, | ||
| .src_valid, | ||
| .src_data, | ||
| .dst_clk, | ||
| .dst_rst, | ||
| .dst_updated, | ||
| .dst_data | ||
| ); | ||
|
|
||
| // Implementation checks | ||
| // Rely on checks in br_cdc_stable_data submodule | ||
|
|
||
| endmodule : br_cdc_stable_data_autoupdate | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic can drop updates whenever
src_datachanges whilebr_cdc_stable_datais backpressured:src_data_regis updated on anysrc_valid, butsrc_validitself is justsrc_data != src_data_reg, so a change that occurs whensrc_readyis low is consumed into the shadow register and then deasserted before a transfer happens. In that case the destination never receives the new value (and with assertions enabled,no_reg_overflow_Acan also fire), so two source updates within one CDC transfer interval can leavedst_datapermanently stale.Useful? React with 👍 / 👎.