eladla
Member level 4
Hi!
I`m trying to create a counter that will count nine rising edges of the input clock and do nothing and then on the 10th rising edge output a pulse until the input clock goes back low and then begin counting again, i.e. I want to pass every 10th clock pulse and the input pulse length is variable. I got something going, but I used a while loop and it seems not to be synthesizer friendly. Syplify keeps asking me to raise the loop limit, but since it`s a while, I can`t know the loop limit ahead of time. I`m guessing there is a better way to do this, I`m just new to Verilog.
Please help!
Thank you.
---------- Post added at 06:06 ---------- Previous post was at 05:39 ----------
Well... I have made some progress, but still having synthesis issues.
Now Synplify tells me I can`t use posedge and negedge of pulse_in in the same always block. I don`t get why this is a hardware limitation, but ok...
Any other way to do this?
I`m trying to create a counter that will count nine rising edges of the input clock and do nothing and then on the 10th rising edge output a pulse until the input clock goes back low and then begin counting again, i.e. I want to pass every 10th clock pulse and the input pulse length is variable. I got something going, but I used a while loop and it seems not to be synthesizer friendly. Syplify keeps asking me to raise the loop limit, but since it`s a while, I can`t know the loop limit ahead of time. I`m guessing there is a better way to do this, I`m just new to Verilog.
Please help!
Thank you.
Code:
`timescale 1 ns / 100 ps
module pulse_generator (pulse_in, pulse_out);
input pulse_in;
output pulse_out;
reg [8:0] Counter;
reg pulse_out;
always @ (posedge pulse_in)
begin
Counter <= Counter + 9'h1;
if(Counter == 9'b111111111)
begin
// synthesis loop_limit 8000
while (pulse_in == 1'b1) begin
pulse_out <= pulse_in;
end
Counter <= 9'b000000000;
end
end
endmodule
---------- Post added at 06:06 ---------- Previous post was at 05:39 ----------
Well... I have made some progress, but still having synthesis issues.
Code:
module pulse_generator (pulse_in, pulse_out);
input pulse_in;
output pulse_out;
wire pulse_in;
reg [3:0] Counter;
reg pulse_out;
initial
begin
Counter = 4'd0;
pulse_out = 0;
end
always @ (posedge pulse_in)
begin
Counter = Counter + 1;
if(Counter == 4'd9)
begin
pulse_out = pulse_in;
@(negedge pulse_in)
pulse_out = 1'b0;
Counter = 4'd0;
end
end
endmodule
Now Synplify tells me I can`t use posedge and negedge of pulse_in in the same always block. I don`t get why this is a hardware limitation, but ok...
Any other way to do this?