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

[SeqToSV] Add clock_gate lowering #5457

Merged
merged 1 commit into from
Jun 26, 2023
Merged

[SeqToSV] Add clock_gate lowering #5457

merged 1 commit into from
Jun 26, 2023

Conversation

mortbopet
Copy link
Contributor

@mortbopet mortbopet commented Jun 22, 2023

... for those times when you don't want to externalize a clock gate. My immediate use for this is to not have to worry about placing clock gate modules into output/search folders when running integration tests for ops that use clock gates. Obviously, the clock gate externalization pass can be run prior to SV lowering to skip this. Secondly, i prefer that all ops have some way of reaching emission without having to worry about external collateral.

The implementation exports as the following sv:

module cg1(
  input  clk,
         enable,
  output gclk
);

  reg cg_en_latch;
  always @(edge clk or edge enable) begin
    if (~clk)
      cg_en_latch <= enable;
  end
  assign gclk = clk & cg_en_latch;
endmodule

module cg2(
  input  clk,
         enable,
         test_enable,
  output gclk
);

  wire _GEN = enable | test_enable;
  reg  cg_en_latch;
  always @(edge clk or edge _GEN) begin
    if (~clk)
      cg_en_latch <= _GEN;
  end
  assign gclk = clk & cg_en_latch;
endmodule

... for those times when you don't want to externalize a clock gate. My immediate use for this is to not have to worry about placing clock gate modules into output/search folders when running integration tests for ops that use clock gates.
Obviously, the clock gate externalization pass can be run prior to SV lowering to skip this.

The implementation exports as the following `sv`:

```sv
module cg1(
  input  clk,
         enable,
  output gclk
);

  reg cg_en_latch;
  always @(edge clk or edge enable) begin
    if (~clk)
      cg_en_latch <= enable;
  end
  assign gclk = clk & cg_en_latch;
endmodule

module cg2(
  input  clk,
         enable,
         test_enable,
  output gclk
);

  wire _GEN = enable | test_enable;
  reg  cg_en_latch;
  always @(edge clk or edge _GEN) begin
    if (~clk)
      cg_en_latch <= _GEN;
  end
  assign gclk = clk & cg_en_latch;
endmodule
```
Copy link
Contributor

@fabianschuiki fabianschuiki 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 for adding this. 💯

@mortbopet mortbopet merged commit 46562d3 into main Jun 26, 2023
@darthscsi darthscsi deleted the dev/mpetersen/seq_cg_sv branch June 4, 2024 14:48
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.

2 participants