Quantcast
Channel: Question and Answer » uart
Viewing all articles
Browse latest Browse all 57

trying to understand a baud rate generator (module m counter)

$
0
0

I would like to understand a baud rate generator (module m counter).

module mod_m_counter
   #(
    parameter N=4, // number of bits in counter
              M=10 // mod-M
   )
   (
    input wire clk, reset,
    output wire max_tick,
    output wire [N-1:0] q
   );

   //signal declaration
   reg [N-1:0] r_reg;
   wire [N-1:0] r_next;

   // body
   // register
   always @(posedge clk, posedge reset)
      if (reset)
         r_reg <= 0;
      else
         r_reg <= r_next;

   // next-state logic
   assign r_next = (r_reg==(M-1)) ? 0 : r_reg + 1;
   // output logic
   assign q = r_reg;
   assign max_tick = (r_reg==(M-1)) ? 1'b1 : 1'b0;

endmodule

I know that using N=4 and M=10 (having a 50Mhz clock), I’m generating a baud rate of 19200 and I would like to understand this so that I can set another baud rates.

Thanks in advance for your help.
God bless


Viewing all articles
Browse latest Browse all 57

Trending Articles