I am trying to divide 48MHz into 9600Hz using the following fractional divider.
Why am I getting baud_out period of 104170ns (simulation) instead of 104167ns (calculation) ? How to calculate this 3ns difference ?
Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// credit: Adapted from [url]https://zipcpu.com/blog/2017/06/02/generating-timing.html[/url]module baud_generator(clk, baud_out);// we are obtaining baud_out = 9600bps = clk/5000 where clk = 48MHzinput clk;output baud_out;reg ck_stb;reg[31:0] counter =0;always@(posedge clk){ck_stb, counter}<= counter +858993;// (2^32)/5000 ~= 858993 , actual baudrate = 9599.9949bps// baud_out has a period of (1/9599.9949bps) or 104167nsassign baud_out = ck_stb;endmodule