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

Subversion Repositories System09

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

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

powered by: WebSVN 2.1.0

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