Add power of two divider

This commit is contained in:
Madeline Busig 2025-11-19 15:50:34 -08:00
parent ae5dcf1a4d
commit e683fa28c8

25
pwm_block/src/conf_div.v Normal file
View 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