OpenCores
URL https://opencores.org/ocsvn/openverifla/openverifla/trunk

Subversion Repositories openverifla

[/] [openverifla/] [trunk/] [openverifla_2.4/] [vhdl/] [verifla/] [baud_of_verifla.vhd] - Blame information for rev 46

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 46 laurentiud
-- 20180816-1450
2
-- baud rate generator
3
-- author: Laurentiu Duca
4
-----------------------------------------------------
5
 
6
library IEEE;
7
use IEEE.STD_LOGIC_1164.ALL;
8
use IEEE.NUMERIC_STD.ALL;
9
--use ieee.std_logic_arith.all;  
10
use ieee.std_logic_unsigned.all;
11
use work.inc_of_verifla.all;
12
 
13
-----------------------------------------------------
14
 
15
entity baud_of_verifla is
16
port(   sys_clk, sys_rst_l:in std_logic;
17
                baud_clk_posedge:       out std_logic
18
);
19
end baud_of_verifla;
20
 
21
-----------------------------------------------------
22
 
23
architecture baud_of_verifla_arch of baud_of_verifla is
24
 
25
        -- This were moved to inc_of_verifla.vhd
26
        --constant CLOCK_FREQUENCY: integer := 50000000;
27
        --constant BPS: integer := 115200;
28
        -- 1s ... 50000000 T1
29
        -- 1bit ... 16 T2
30
        -- 1s .. 115200 bits
31
        -- =>
32
        -- 1s .. 115200 * 16 T2
33
        --
34
        -- T2 = 5000000 T1 / (115200 * 16) = T1 * 50000000 / (115200 * 16)
35
        --constant T2_div_T1_div_2: integer := (CLOCK_FREQUENCY / (BPS * 16 * 2));
36
        -- COUNTER_SIZE = log2(T2_T1_div_2) bits
37
        --constant BAUD_COUNTER_SIZE: integer := 15;
38
 
39
   signal counter: std_logic_vector((BAUD_COUNTER_SIZE-1) downto 0);
40
        signal baud_clk, baud_clk_posedge_reg: std_logic;
41
 
42
begin
43
 
44
        baud_clk_posedge <= baud_clk_posedge_reg;
45
 
46
   state_reg: process(sys_clk, sys_rst_l)
47
   begin
48
                if (sys_rst_l='0') then
49
                        baud_clk <= '0';
50
                        baud_clk_posedge_reg <= '0';
51
                        counter <= std_logic_vector(to_unsigned(0, BAUD_COUNTER_SIZE)); --x"00000000";
52
                elsif (rising_edge(sys_clk)) then
53
                        if (counter < std_logic_vector(to_unsigned(T2_div_T1_div_2, BAUD_COUNTER_SIZE))) then
54
                                counter <= counter + std_logic_vector(to_unsigned(1, BAUD_COUNTER_SIZE));
55
                                baud_clk <= baud_clk;
56
                                baud_clk_posedge_reg <= '0';
57
                        else
58
                                if (baud_clk = '0') then
59
                                        baud_clk_posedge_reg <= '1';
60
                                end if;
61
                                counter <= std_logic_vector(to_unsigned(0, BAUD_COUNTER_SIZE));
62
                                baud_clk <= not(baud_clk);
63
                        end if;
64
                end if;
65
   end process;
66
 
67
end baud_of_verifla_arch;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.