简体   繁体   中英

How to give a delay of 1 clock cycle in a combinational block verilog

I have a combinational code that I have, In that code I would like to turn off a signal after 1 clock cycle, ie initially it is 1, and after one clock cycle it should be 0. Is there any way I can do it and if possible it should be able to synthesize on an FPGA. The code is as follows:

always@(ao or bo or co or dod or eo or fo or go or ho)
    begin
    temp_out = {ho,go,fo,eo,dod,co,bo,ao};
    out_flag = 1;
    //after one clock cycle it should go to 0 ;
    //help is required over here
    out_flag = 0;
    end

You cannot do it in a pure combinational synthesizable manner. You need a flop (which is synthesizable) and a reset to set the signal to a know value, say to 0. So, you can delay 1 clock cycle after reset as the following:

always @(posedge clk) begin 
    if (reset)
        out_flag <= 0;
    else 
        out_flag <= 1;
end

you need to figure out exact timing and use correct number of flops for you particular situation. You might want to have an asynchronous reset versus synchronous as in the above example.

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