Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
17 years ago

synchronize pll

On CycloneII, is it possible to re-synchronize or start a pll on an async event such as a pulse?

I have a 50Mhz pll clocked state machine that is triggered from a single external async pulse. I also have a Flash A/D that is running on a separate, continous 10mhz pll clock. What I would like to do is synchronize the two plls such that the A/D clock is aligned to my external pulse so its sampling times are predictably synched to my state machine logic.

The A/D is designed to operate from a continuous clock only and has an internal 4clk conversion delay. The very first result may be bad but I can live with that. I thought of using counters to generate a 10Mhz clock directly from the 50Mhz state machine logic but it would be better if I could use a pll so as to have some control over phase.

14 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I wrote up some verilog for this (12ff,3gates) and the functional simulation looks perfect, but the timing simulation does not show correct values for one of my shift registers. I see in the altddio doc that there are special ddr register cells, and special sim libs also. I'd prefer to stick with my own code, but without knowing how to specify those special options I guess I will have to use the megafunction.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The Quartus Handbook clarifies that DDIO can't be inferred from HDL code:

    --- Quote Start ---

    You must instantiate megafunctions to target certain device and high-speed features such as LVDS drivers, PLLs, transceivers, and double-data rate input/output (DDIO) circuitry.

    --- Quote End ---

    Other solutions that combine posedge and negedge clocked registers are possible, but you have to take care not to generate glitches. One option is to use a asynchronous clear from a register clocked at the opposite edge. See: http://www.edaboard.com/viewtopic.php?t=303735
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    This short code works pretty well. Functional sim looks perfect but timing sim does not init properly. On CII grade8, a 50mhz:10mhz conversion has 50% duty. I don't see glitches, but it does not always start aligned to the 1st rising edge like I want. Could be improved.

    --- Quote Start ---

    module ddrdiv5_clk

    (

    clk50,

    nReset,

    cnt_en,

    clk10_out

    );

    input clk50;

    input nReset;

    input cnt_en;

    output clk10_out;

    reg[4:0] ddsrh;

    reg[4:0] ddsrl;

    reg first;

    assign clk10_out = ddsrh[0] & (ddsrl[0] | ~ddsrh[4] | ~ddsrl[4]);

    always @(posedge clk50 or negedge nReset)

    begin

    if(!nReset)

    begin

    ddsrh[4:0] <= 5'b01110;

    first <= 1'b0;

    end

    else

    begin

    if(cnt_en)

    begin

    ddsrh[4:0] <= {ddsrh[0],ddsrh[4:1]};

    first <= 1'b1;

    end

    else

    begin

    ddsrh[4:0] <= ddsrh[4:0];

    end

    end

    end

    always @(negedge clk50)

    begin

    if(!first)

    begin

    ddsrl[4:0] <= 5'b00110;

    end

    else

    begin

    if(cnt_en)

    begin

    ddsrl[4:0] <= {ddsrl[0],ddsrl[4:1]};

    end

    else

    begin

    ddsrl[4:0] <= ddsrl[4:0];

    end

    end

    end

    endmodule

    --- Quote End ---