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

Add a set of CDC Linting rules #200

Open
chili-chips-ba opened this issue Jul 23, 2024 · 4 comments
Open

Add a set of CDC Linting rules #200

chili-chips-ba opened this issue Jul 23, 2024 · 4 comments

Comments

@chili-chips-ba
Copy link

For starters, we could check the scenarios that mainstream commercial tools address:

There is also this open-source project that can be taken for reference:

Verilator CDC Request
Yosys CDC Request
Slang CDC Request

@chili-chips-ba chili-chips-ba changed the title Add a set of CDC Lining rules Add a set of CDC Linting rules Jul 23, 2024
@ajeethakv
Copy link
Contributor

Thanks for the interest. I browsed through some of the links you've provided. I don't see a crisp set of rules that can be lint-checked. CDC verification is ofcourse a wider problem involving multitude of techniques and looks like that cdc_snitch is a good start. What exactly do you have in mind for source code level Verilog/SV (or even VHDL) lint checks w.r.t CDC?

@ajeethakv
Copy link
Contributor

Here are some basic conceptual rules. I am looking for more concrete ones to implement via PySlint.

CDC Lint Rules

1. Clock Domain Identification:

  • Rule: Ensure all clock domains are explicitly identified.
  • Description: Clearly label and document all clock domains used in the design. Use consistent naming conventions for signals and modules to indicate their clock domains (e.g., clk_a, clk_b).

2. Synchronous Resets:

  • Rule: Use synchronous resets for all registers.
  • Description: Ensure that all resets are synchronous to the respective clock domains they control. Asynchronous resets should be avoided unless absolutely necessary, and should be de-asserted synchronously.

3. Single-Bit Signal Synchronization:

  • Rule: Synchronize single-bit signals crossing clock domains using multi-stage flip-flop synchronizers.
  • Description: Use at least two flip-flops in series to synchronize single-bit signals crossing clock domains to avoid metastability.

4. Multi-Bit Signal Handling:

  • Rule: Use CDC-safe structures for multi-bit signal transfers.
  • Description: Employ methods like FIFOs, dual-port RAMs, or handshaking protocols to safely transfer multi-bit data across clock domains.

5. FIFO Usage:

  • Rule: Use asynchronous FIFOs for data transfer between different clock domains.
  • Description: Asynchronous FIFOs should be implemented with proper full and empty flag synchronization to manage data safely between clock domains.

6. Handshake Protocols:

  • Rule: Implement handshake protocols for control signal transfers.
  • Description: Use handshaking mechanisms (e.g., request-acknowledge) for transferring control signals across clock domains to ensure data integrity.

7. Avoid Combinational Logic Between Clock Domains:

  • Rule: Do not use combinational logic to connect signals between different clock domains.
  • Description: Ensure that signals crossing clock domains are registered and do not pass through combinational logic to prevent glitches and metastability.

8. Metastability Handling:

  • Rule: Design for metastability tolerance.
  • Description: Ensure that the design can tolerate metastability by allowing sufficient settling time and using proper synchronizers.

@chili-chips-ba
Copy link
Author

@ajeethakv any progress on this track?

We're hot to trying it on our Wireguard-FPGA project...

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

No branches or pull requests

2 participants