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

Subversion Repositories z80control

[/] [z80control/] [trunk/] [DE1/] [rtl/] [VHDL/] [uart/] [clkUnit.vhd] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 tylerapohl
--===========================================================================--
2
--
3
--  S Y N T H E Z I A B L E    miniUART   C O R E
4
--
5
--  www.OpenCores.Org - January 2000
6
--  This core adheres to the GNU public license  
7
 
8
-- Design units   : miniUART core for the OCRP-1
9
--
10
-- File name      : clkUnit.vhd
11
--
12
-- Purpose        : Implements an miniUART device for communication purposes 
13
--                  between the OR1K processor and the Host computer through
14
--                  an RS-232 communication protocol.
15
--                  
16
-- Library        : uart_lib.vhd
17
--
18
-- Dependencies   : IEEE.Std_Logic_1164
19
--
20
--===========================================================================--
21
-------------------------------------------------------------------------------
22
-- Revision list
23
-- Version   Author              Date                Changes
24
--
25
-- 1.0     Ovidiu Lupas      15 January 2000         New model
26
-- 1.1     Ovidiu Lupas      28 May 2000     EnableRx/EnableTx ratio corrected
27
--      olupas@opencores.org
28
-------------------------------------------------------------------------------
29
-- Description    : Generates the Baud clock and enable signals for RX & TX
30
--                  units. 
31
-------------------------------------------------------------------------------
32
-- Entity for Baud rate generator Unit - 9600 baudrate                       --
33
-------------------------------------------------------------------------------
34
library ieee;
35
   use ieee.std_logic_1164.all;
36
   use ieee.numeric_std.all;
37
library work;
38
   use work.UART_Def.all;
39
-------------------------------------------------------------------------------
40
-- Baud rate generator
41
-------------------------------------------------------------------------------
42
entity ClkUnit is
43
  port (
44
     SysClk   : in  Std_Logic;  -- System Clock
45
     EnableRx : out Std_Logic;  -- Control signal
46
     EnableTx : out Std_Logic;  -- Control signal
47
     Reset    : in  Std_Logic); -- Reset input
48
end entity; --================== End of entity ==============================--
49
-------------------------------------------------------------------------------
50
-- Architecture for Baud rate generator Unit
51
-------------------------------------------------------------------------------
52
architecture Behaviour of ClkUnit is
53
  -----------------------------------------------------------------------------
54
  -- Signals
55
  -----------------------------------------------------------------------------
56
  signal ClkDiv26  : Std_Logic;
57
  signal tmpEnRX   : Std_Logic;
58
  signal tmpEnTX   : Std_Logic;
59
begin
60
  -----------------------------------------------------------------------------
61
  -- Divides the system clock of 50 MHz by 32
62
  -----------------------------------------------------------------------------
63
  DivClk26 : process(SysClk,Reset)
64
     constant CntOne : unsigned(4 downto 0) := "00001";
65
     variable Cnt26  : unsigned(5 downto 0);
66
  begin
67
     if Rising_Edge(SysClk) then
68
        if Reset = '0' then
69
           Cnt26 := "000000";
70
           ClkDiv26 <= '0';
71
        else
72
           Cnt26 := Cnt26 + CntOne;
73
           case Cnt26 is
74
              when "100000" =>
75
                  ClkDiv26 <= '1';
76
                  Cnt26 := "000000";
77
              when others =>
78
                  ClkDiv26 <= '0';
79
           end case;
80
        end if;
81
     end if;
82
  end process;
83
  -----------------------------------------------------------------------------
84
  -- Provides the EnableRX signal, at ~ 155 KHz
85
  -----------------------------------------------------------------------------
86
  DivClk10 : process(SysClk,Reset,Clkdiv26)
87
     constant CntOne : unsigned(3 downto 0) := "0001";
88
     variable Cnt10  : unsigned(3 downto 0);
89
  begin
90
     if Rising_Edge(SysClk) then
91
        if Reset = '0' then
92
           Cnt10 := "0000";
93
           tmpEnRX <= '0';
94
        elsif ClkDiv26 = '1' then
95
           Cnt10 := Cnt10 + CntOne;
96
        end if;
97
        case Cnt10 is
98
             when "1010" =>
99
                tmpEnRX <= '1';
100
                Cnt10 := "0000";
101
             when others =>
102
                tmpEnRX <= '0';
103
        end case;
104
     end if;
105
  end process;
106
  -----------------------------------------------------------------------------
107
  -- Provides the EnableTX signal, at 9.6 KHz
108
  -----------------------------------------------------------------------------
109
  DivClk16 : process(SysClk,Reset,tmpEnRX)
110
     constant CntOne : unsigned(4 downto 0) := "00001";
111
     variable Cnt16  : unsigned(4 downto 0);
112
  begin
113
     if Rising_Edge(SysClk) then
114
        if Reset = '0' then
115
           Cnt16 := "00000";
116
           tmpEnTX <= '0';
117
        elsif tmpEnRX = '1' then
118
           Cnt16 := Cnt16 + CntOne;
119
        end if;
120
        case Cnt16 is
121
           when "01111" =>
122
                tmpEnTX <= '1';
123
                Cnt16 := Cnt16 + CntOne;
124
           when "10001" =>
125
                Cnt16 := "00000";
126
                tmpEnTX <= '0';
127
           when others =>
128
                tmpEnTX <= '0';
129
        end case;
130
     end if;
131
  end process;
132
 
133
  EnableRX <= tmpEnRX;
134
  EnableTX <= tmpEnTX;
135
end Behaviour; --==================== End of architecture ===================--

powered by: WebSVN 2.1.0

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