Forum Discussion

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

wait statement error

hello,

here i'm getting error in using of wait statement. how to use wait statement for executing an event after a particular time like after every 83 ns high and low respectively?

3 Replies

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

    please post your code.

    wait statements with specific delays are not appropriate for synthesis, only simulation. For synthesis you need to use counters to wait for the specified time.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    First you should use the numeric_std library, to have access to the signed and unsigned types.

    Then declare count and z as unsigned(1 downto 0) and unsigned(6 downto 0) respectively, and you can directly use arithmetic operators on them:

    count<=count+1;
    IF ((Z = 15) or (Z = 30) or (Z = 45) or (Z = 60)) then
      clkout<= not clkout;
    END IF; 
    IF(Z = 83) THEN
      Z <="0000000";
    ELSE
      Z <=Z+1;
    END IF; 
    
    I don't understand the values you use though... do you want to divide the clock frequency by 3 (meaning 666.666kHz) or by 3000 to get 666 Hz? IF dividing by 3 you won't be able to produce a square signal with 50% duty cycle. But you can generate a clock enable signal quite easily.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    thank you for your advice, yes i want to divide the clk frequency by 3 to get 666kHz which is equal to 166ns....