0

I am generating a PLL simulation model. I can find the input ref clock period by using $time and divide the period with pll divider to generate pll output clock. as shown below, but simulator doesn't show anything on waveform , no syntax error though. What is wrong with this approach ?

 time prev_t, periodd; reg clk = 0; always @(posedge CLK_PLL_IN) begin periodd = $time - prev_t; prev_t = $time; end always #(periodd/pll_div) clk = ~clk; 
1
  • 1
    Your code is not a complete stand-alone testbench. Please add the necessary code: module header, CLK_PLL_IN definition and how you make a signal (clock) with that etc. Commented Mar 16, 2020 at 16:53

1 Answer 1

2

The initial value of periodd is 0, so you get into a zero delay loop if the second always block begins before the first. I also suggest using realtime and $realtime instead of time and $time in case the factional part of periodd/pll_div is smaller than the timescale.

realtime prev_t, periodd=0; reg clk = 0; always @(posedge CLK_PLL_IN) begin periodd = $time - prev_t; prev_t = $time; end initial wait(periodd >0) forever #(periodd/pll_div) clk = ~clk; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.