1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-26 10:49:17 +00:00
8bitworkshop/presets/verilog/clock_divider.v

31 lines
503 B
Coq
Raw Normal View History

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
*/
module clock_divider(
input clk,
2018-02-07 00:07:40 +00:00
input reset,
output reg clk_div2,
output reg clk_div4,
output reg clk_div8,
2018-12-15 16:10:32 +00:00
output reg clk_div16
);
// simple ripple clock divider
always @(posedge clk)
clk_div2 <= reset ? 0 : ~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