2 use ieee.std_logic_1164.all;
3 use ieee.std_logic_arith.all;
4 use ieee.std_logic_unsigned.all;
6 --------------------------------------------------------------------------------
7 -- Baud generator is an adjustable clock frequency divider. Division factor
8 -- is determined by the value present on the input vector named 'scale' and is
10 -- f_OUT = f_IN / (2 * (1 + 'scale'))
12 -- The divided clock signal has a duty cycle of 50%.
14 -- The reset input signal is asynchronous. When held active, the output is 0.
15 -- When released, the output starts a new period and goes high with the next
16 -- rising edge of the input clock signal.
18 -- _ _ _ _ _ _ _ _ _ _ _ _
19 -- CLK _| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_
21 -- RESET ____________| |__________________________
23 -- CLK_BAUD _| |___| |____________| |___| |___| |___
25 --------------------------------------------------------------------------------
29 SCALE_WIDTH : integer := 16
34 scale : in std_logic_vector (SCALE_WIDTH-1 downto 0);
35 clk_baud : out std_logic
39 --------------------------------------------------------------------------------
41 architecture behavioral of baud_gen is
43 signal counter : std_logic_vector (SCALE_WIDTH-1 downto 0);
44 signal clk_baud_s : std_logic;
46 --------------------------------------------------------------------------------
53 counter <= (others => '0');
56 elsif (rising_edge(clk)) then
59 clk_baud_s <= not clk_baud_s;
62 counter <= counter - 1;
68 --------------------------------------------------------------------------------
70 clk_baud <= clk_baud_s;