From e683fa28c88eaee89bda6568601d1c4da2dc2559 Mon Sep 17 00:00:00 2001 From: Madeline Busig Date: Wed, 19 Nov 2025 15:50:34 -0800 Subject: [PATCH] Add power of two divider --- pwm_block/src/conf_div.v | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pwm_block/src/conf_div.v diff --git a/pwm_block/src/conf_div.v b/pwm_block/src/conf_div.v new file mode 100644 index 0000000..19990a3 --- /dev/null +++ b/pwm_block/src/conf_div.v @@ -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 +