0
votes

I have a clock which is always active, I have another clock call it "sample" , which is generated from the first clock . I want to generate a delay of "sample" signal by fixed number of cycles of the first clock signal in verilog

2

2 Answers

3
votes

Use a shift register:

parameter DELAY = number_of_clock_cycles_you_want_to_delay_by;

reg [DELAY-1:0] shift_reg;

always @(posedge clk)
    begin
          shift_reg <= { shift_reg[DELAY-2:0], signal_you_want_to_delay};
    end

assign delayed_signal = shift_reg[DELAY-1];
0
votes

I think you need to add a count down counter, otherwise, it keeps shifting to the left without ending.