icicle/clk_div.sv
Graham Edgecombe 22bce1bdeb Fix compatibility with iverilog
This commit:

 * changes the type of all output variables to logic
 * splits variable declaration and assignment
 * declares variables before modules that use the variables
2017-12-09 21:03:45 +00:00

18 lines
273 B
Systemverilog

`ifndef CLK_DIV
`define CLK_DIV
module clk_div #(
parameter LOG_DIVISOR = 1
) (
input clk_in,
output logic clk_out
);
logic [LOG_DIVISOR-1:0] q;
always_ff @(posedge clk_in)
q <= q + 1;
assign clk_out = q[LOG_DIVISOR-1];
endmodule
`endif