简体   繁体   中英

Verilog clock generator error?

I write simple code using ISE 14.7 to generate clock signal, but the output in iSim is always 1, until I change = with <= then the clock works, could you tell me why?

module nonblocking( clk );
 output reg clk;

 initial 
   #10 clk =0;

 always @ (clk)
#10 clk = ~ clk; // change to <= to work

endmodule

This code honestly doesn't make any sense.

Your current code states that based on clk , the value of clk should be ~clk . When you use <= you are at least specifying a nonblocking assignment, which makes slightly more sense, but still doesn't.

If you want a clock generator for simulation, use the following within an initial block (giving a 10ns period):

forever begin
    #5 clk <= ~clk;
end

If you want a clock generator for FPGA synthesis, either connect a physical oscillator to your device's clock input pin, or use a built-in oscillator (if available on your device). You can always use a DCM/PLL/CMT/MMCM/whatever your FPGA calls it to adjust the clock frequency.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM