source: trunk/MultiChannelCOM/baud_gen.v@ 109

Last change on this file since 109 was 2, checked in by demin, 15 years ago

first working version

File size: 672 bytes
Line 
1module baud_gen
2 #(
3 parameter INC=1208, // counter increment (115200*16*32768/F_clk)
4 DIV=1 // divider (baud rate = 115200/D)
5 )
6 (
7 input wire clk, reset,
8 output wire max_tick
9 );
10
11 //signal declaration
12 reg [15:0] acc_reg;
13 reg [7:0] div_reg;
14
15 wire div_reg_max = (div_reg == (DIV-1));
16
17 // body
18 always @(posedge clk, posedge reset)
19 begin
20 if (reset)
21 begin
22 acc_reg <= 0;
23 div_reg <= 0;
24 end
25 else
26 begin
27 acc_reg <= acc_reg[14:0] + INC;
28 if (acc_reg[15])
29 div_reg <= div_reg_max ? 0 : div_reg + 16'd1;
30 end
31 end
32
33 // output logic
34 assign max_tick = acc_reg[15] & div_reg_max;
35
36endmodule
Note: See TracBrowser for help on using the repository browser.