tipra
Newbie

I need to write verilog code wherein I need a signal which goes high for one clock pulse after every tenth clock pulse. I tried something this way,
This code works fine and is able to produce the required signal 'sig1' which goes high for one cycle after every tenth clock cycle.
Is there any better and generalized way to generate 'sig1' with the required characterstics?
Note: I intend to use this signal 'sig1' in a larger design which needs to be synthesised.
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 module top #( WIDTH=8 ) ( input clk, output reg [WIDTH-1:0] sig1, ); reg [WIDTH-1:0] count; always@(posedge clk) begin count <= count + 1; if (count == 'd10 || count == 'd20 || count == 'd30 || count == 'd40 ) begin sig1<= 1; else begin sig1<= 0; end endmodule
This code works fine and is able to produce the required signal 'sig1' which goes high for one cycle after every tenth clock cycle.
Is there any better and generalized way to generate 'sig1' with the required characterstics?
Note: I intend to use this signal 'sig1' in a larger design which needs to be synthesised.
Last edited by a moderator: