generated from maddiebusig/vivado-template-hog
Add power of two divider
This commit is contained in:
parent
ae5dcf1a4d
commit
e683fa28c8
25
pwm_block/src/conf_div.v
Normal file
25
pwm_block/src/conf_div.v
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
//power-of-2 clock divider
|
||||||
|
//output clock frequency can be chosen through the input 'sel'
|
||||||
|
//output clock freqeuncy is clk_in/(2^(sel+1))
|
||||||
|
module conf_div (
|
||||||
|
input clk_in,
|
||||||
|
input rst,
|
||||||
|
input [3:0] sel,
|
||||||
|
output reg clk_out
|
||||||
|
|
||||||
|
);
|
||||||
|
wire cl_sel;
|
||||||
|
reg [15:0] count;
|
||||||
|
|
||||||
|
assign cl_sel = count[sel];
|
||||||
|
|
||||||
|
always @(posedge clk_in)
|
||||||
|
if(rst)
|
||||||
|
count<=0;
|
||||||
|
else
|
||||||
|
count<=count+1;
|
||||||
|
|
||||||
|
always @(posedge clk_in)
|
||||||
|
clk_out <= cl_sel;
|
||||||
|
endmodule
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user