# Generate a 2/3 clock frequency in TB using System Verilog and Verilog

**URL:** <https://verificationacademy.com/forums/t/generate-a-2-3-clock-frequency-in-tb-using-system-verilog-and-verilog/39718>\
**Category:** SystemVerilog\
**Tags:** clockingblock, SystemVerilog\
**Created:** [October 20, 2021, 3:34am UTC](https://verificationacademy.com/forums/t/generate-a-2-3-clock-frequency-in-tb-using-system-verilog-and-verilog/39718 "2021-10-20T03:34:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sk7799](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@sk7799](https://verificationacademy.com/forums/u/sk7799)\
**Post date:** [October 20, 2021, 3:34am UTC](https://verificationacademy.com/forums/t/generate-a-2-3-clock-frequency-in-tb-using-system-verilog-and-verilog/39718/1 "2021-10-20T03:34:46Z")

</div>

Hi,

I came across the concept of clock generation and I am trying to understand if I can generate a clock for a let’s say a 2/3 clock divider i.e., 0.66 duty cycle using the system Verilog and Verilog. I would like to understand the difference. I am working on a pseudo-code but any other help to code would be greatly appreciated to help me understand the concept of how to generate the clock with any frequency other than the 50% duty cycle.

Thanks,  
Sruthi.

---

<div class="post-metadata">

**Author:** ![warnerrs](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/w/858c86/32.png) [@warnerrs](https://verificationacademy.com/forums/u/warnerrs)\
**Post date:** [October 20, 2021, 4:32am UTC](https://verificationacademy.com/forums/t/generate-a-2-3-clock-frequency-in-tb-using-system-verilog-and-verilog/39718/2 "2021-10-20T04:32:48Z")

</div>

_In reply to [sk7799](https://verificationacademy.com/forums/t/generate-a-2-3-clock-frequency-in-tb-using-system-verilog-and-verilog/39718):_

At it’s most basic.

A typical 50% duty implementation:

```verilog
initial begin
   clk = 0;
   forever #10 clk = ~clk;
end

```

Could be implemented:

```verilog
initial begin
   clk = 0;
   forever begin
       #5;
       clk = 1;
       #5;
       clk = 0;
   end
end

```

So a 66.6% duty, is simply:

```verilog
initial begin
   clk = 0;
   forever begin
      #3.333;
      clk = 1;
      #6.667;
      clk = 0;
   end
end

```

Then put this in an interface, embellish it with enable/disable, glitch-free frequency changes, jitter, etc.

---

<div class="post-metadata">

**Author:** ![sk7799](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@sk7799](https://verificationacademy.com/forums/u/sk7799)\
**Post date:** [October 20, 2021, 4:57am UTC](https://verificationacademy.com/forums/t/generate-a-2-3-clock-frequency-in-tb-using-system-verilog-and-verilog/39718/3 "2021-10-20T04:57:41Z")

</div>

_In reply to [warnerrs](https://verificationacademy.com/forums/t/generate-a-2-3-clock-frequency-in-tb-using-system-verilog-and-verilog/39718/2):_

Hi Warnerrs,

Thank you very much for the prompt response.

If possible can you please explain the code for the 66.6% duty cycle.

Also, for 2/3 frequency, it’s 0.66 right?

Please clarify.
