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

Subversion Repositories instruction_list_pipelined_processor_with_peripherals

[/] [instruction_list_pipelined_processor_with_peripherals/] [trunk/] [hdl/] [uartBrg.vhd] - Blame information for rev 10

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 maheshpalv
--////////////////////////////////////////////////////////////////////////////////////////////////
2
--////                                                                                                                  ////
3
--////                                                                                                                  ////
4
--////          This file is part of the project                                                                                        ////
5
--////  "instruction_list_pipelined_processor_with_peripherals"                                                         ////
6
--////                                                                                                                  ////
7
--////  http://opencores.org/project,instruction_list_pipelined_processor_with_peripherals      ////
8
--////                                                                                                                  ////
9
--////                                                                                                                  ////
10
--////                           Author:                                                                                ////
11
--////                          - Mahesh Sukhdeo Palve                                                                                                  ////
12
--////                                                                                                                                                                          ////
13
--////////////////////////////////////////////////////////////////////////////////////////////////
14
--////////////////////////////////////////////////////////////////////////////////////////////////
15
--////                                                                                                                                                                          ////
16
--////                                                                                                                                                          ////
17
--////                                                                                                                  ////
18
--////                                  This source file may be used and distributed without                    ////
19
--////                                  restriction provided that this copyright statement is not               ////
20
--////                                  removed from the file and that any derivative work contains             ////
21
--////                                  the original copyright notice and the associated disclaimer.            ////
22
--////                                                                                                                  ////
23
--////                                  This source file is free software; you can redistribute it              ////
24
--////                                  and/or modify it under the terms of the GNU Lesser General              ////
25
--////                                  Public License as published by the Free Software Foundation;            ////
26
--////                                  either version 2.1 of the License, or (at your option) any              ////
27
--////                                  later version.                                                          ////
28
--////                                                                                                                  ////
29
--////                                  This source is distributed in the hope that it will be                  ////
30
--////                                  useful, but WITHOUT ANY WARRANTY; without even the implied              ////
31
--////                                  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR                 ////
32
--////                                  PURPOSE.  See the GNU Lesser General Public License for more            ////
33
--////                                  details.                                                                ////
34
--////                                                                                                                  ////
35
--////                                  You should have received a copy of the GNU Lesser General               ////
36
--////                                  Public License along with this source; if not, download it              ////
37
--////                                  from http://www.opencores.org/lgpl.shtml                                ////
38
--////                                                                                                                  ////
39
--////////////////////////////////////////////////////////////////////////////////////////////////
40
 
41 3 maheshpalv
library IEEE;
42
use IEEE.STD_LOGIC_1164.ALL;
43
use IEEE.math_real.all;
44
use ieee.std_logic_unsigned.all;
45
 
46
entity uartBrg is
47
  generic (
48
    DIVISOR: natural := 32000000/(16*9600) -- DIVISOR = 100,000,000 / (16 x BAUD_RATE)
49
    -- 2400 -> 2604
50
    -- 9600 -> 651
51
    -- 115200 -> 54
52
    -- 1562500 -> 4
53
    -- 2083333 -> 3
54
  );
55
  port (
56
    clk: in std_logic;                         -- clock
57
    reset: in std_logic;                      -- reset
58
         outp : out std_logic
59
  );
60
end uartBrg;
61
 
62
architecture Behavioral of uartBrg is
63
 
64
  constant COUNTER_BITS : natural := integer(ceil(log2(real(DIVISOR))));
65
  signal sample: std_logic; -- 1 clk spike at 16x baud rate
66
  signal sample_counter: std_logic_vector(COUNTER_BITS-1 downto 0) := (others=> '0'); -- should fit values in 0..DIVISOR-1
67
 
68
begin
69
 
70
  -- sample signal at 16x baud rate, 1 CLK spikes
71
  sample_process: process (clk,reset) is
72
  begin
73
    if reset = '1' then
74
      sample_counter <= (others => '0');
75
      sample <= '0';
76
    elsif rising_edge(clk) then
77
      if sample_counter = DIVISOR-1 then
78
        sample <= '1';
79
        sample_counter <= (others => '0');
80
      else
81
        sample <= '0';
82
        sample_counter <= sample_counter + 1;
83
      end if;
84
    end if;
85
  end process;
86
 
87
  outp <= sample;
88
 
89
end Behavioral;

powered by: WebSVN 2.1.0

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