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

Subversion Repositories System09

[/] [System09/] [trunk/] [rtl/] [VHDL/] [ACIA_Clock.vhd] - Blame information for rev 101

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 99 davidgb
--===========================================================================--
2
--                                                                           --
3
--  ACIA_Clock.vhd - Synthesizable Baud Rate Clock Divider                   --
4
--                                                                           --
5
--===========================================================================--
6 19 dilbert57
--
7 99 davidgb
--  File name      : ACIA_Clock.vhd
8 19 dilbert57
--
9 99 davidgb
--  Purpose        : Implements a baud rate clock divider for a 6850 compatible
10
--                   Asynchronous Communications Interface Adapter 
11
--                  
12
--  Dependencies   : ieee.std_logic_1164
13
--                   ieee.std_logic_arith
14
--                   ieee.std_logic_unsigned
15
--                   ieee.numeric_std
16
--                   unisim.vcomponents
17
--                   work.bit_funcs
18
--
19
--  Author         : John E. Kent
20
--
21
--  Email          : dilbert57@opencores.org      
22
--
23
--  Web            : http://opencores.org/project,system09
24
--
25
--  ACIA_Clock.vhd is baud rate clock divider for a 6850 compatible ACIA core.
26
-- 
27
--  Copyright (C) 2003 - 2010 John Kent
28
--
29
--  This program is free software: you can redistribute it and/or modify
30
--  it under the terms of the GNU General Public License as published by
31
--  the Free Software Foundation, either version 3 of the License, or
32
--  (at your option) any later version.
33
--
34
--  This program is distributed in the hope that it will be useful,
35
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
36
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37
--  GNU General Public License for more details.
38
--
39
--  You should have received a copy of the GNU General Public License
40
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
41
--
42
--===========================================================================--
43
--                                                                           --
44
--                              Revision  History                            --
45
--                                                                           --
46
--===========================================================================--
47
--
48
-- Revision Name          Date             Description
49
-- 0.1      John Kent     unknown          Initial version
50
-- 1.0      John Kent     30th May 2010    Added GPL header 
51
--      
52
 
53 19 dilbert57
library ieee;
54 99 davidgb
   use ieee.std_logic_1164.all;
55
   use ieee.std_logic_arith.all;
56
   use ieee.std_logic_unsigned.all;
57 19 dilbert57
   use ieee.numeric_std.all;
58
library unisim;
59
        use unisim.vcomponents.all;
60
library work;
61
   use work.bit_funcs.all;
62
 
63 99 davidgb
entity acia_clock is
64 19 dilbert57
  generic (
65 99 davidgb
     SYS_CLK_FREQ  : integer;
66
          ACIA_CLK_FREQ : integer
67 19 dilbert57
  );
68
  port(
69
    clk      : in  Std_Logic;  -- System Clock input
70 99 davidgb
         acia_clk : out Std_Logic   -- ACIA Clock output
71 19 dilbert57
  );
72 99 davidgb
end acia_clock;
73 19 dilbert57
 
74
-------------------------------------------------------------------------------
75
-- Architecture for ACIA_Clock
76
-------------------------------------------------------------------------------
77
architecture rtl of ACIA_Clock is
78
 
79 99 davidgb
constant FULL_CYCLE : integer :=  (SYS_CLK_FREQ / ACIA_CLK_FREQ);
80 19 dilbert57
constant HALF_CYCLE : integer :=  (FULL_CYCLE / 2);
81 99 davidgb
signal   acia_count : Std_Logic_Vector(log2(FULL_CYCLE) downto 0) := (Others => '0');
82 19 dilbert57
 
83
begin
84
--
85
-- Baud Rate Clock Divider
86
--
87
-- 25MHz / 27  = 926,000 KHz = 57,870Bd * 16
88
-- 50MHz / 54  = 926,000 KHz = 57,870Bd * 16
89
--
90 99 davidgb
my_acia_clock: process( clk  )
91 19 dilbert57
begin
92
    if(clk'event and clk = '0') then
93 99 davidgb
                if( acia_count = (FULL_CYCLE - 1) )     then
94
                        acia_clk   <= '0';
95
                   acia_count <= (others => '0'); --"000000";
96 19 dilbert57
                else
97 99 davidgb
                   if( acia_count = (HALF_CYCLE - 1) )  then
98
                                acia_clk <='1';
99 19 dilbert57
                        end if;
100 99 davidgb
                   acia_count <= acia_count + 1;
101 19 dilbert57
                end if;
102
    end if;
103
end process;
104
 
105
end rtl;

powered by: WebSVN 2.1.0

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