2018-08-13 22:17:36 +00:00
|
|
|
|
2018-10-01 16:30:47 +00:00
|
|
|
/*
|
2018-12-15 16:10:32 +00:00
|
|
|
A clock divider in Verilog, using the cascading
|
|
|
|
flip-flop method.
|
2018-10-01 16:30:47 +00:00
|
|
|
*/
|
|
|
|
|
2017-11-15 00:12:52 +00:00
|
|
|
module clock_divider(
|
|
|
|
input clk,
|
2018-02-07 00:07:40 +00:00
|
|
|
input reset,
|
2017-11-15 00:12:52 +00:00
|
|
|
output reg clk_div2,
|
|
|
|
output reg clk_div4,
|
|
|
|
output reg clk_div8,
|
2018-12-15 16:10:32 +00:00
|
|
|
output reg clk_div16
|
2017-11-15 00:12:52 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// simple ripple clock divider
|
|
|
|
|
|
|
|
always @(posedge clk)
|
|
|
|
clk_div2 <= ~clk_div2;
|
|
|
|
|
|
|
|
always @(posedge clk_div2)
|
|
|
|
clk_div4 <= ~clk_div4;
|
|
|
|
|
|
|
|
always @(posedge clk_div4)
|
|
|
|
clk_div8 <= ~clk_div8;
|
|
|
|
|
|
|
|
always @(posedge clk_div8)
|
|
|
|
clk_div16 <= ~clk_div16;
|
|
|
|
|
|
|
|
endmodule
|