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

Subversion Repositories uart

[/] [uart/] [tags/] [jan_23_2000/] [clkUnit.vhd] - Diff between revs 9 and 10

Only display areas with differences | Details | Blame | View Log

Rev 9 Rev 10
--===========================================================================--
--===========================================================================--
--
--
--  S Y N T H E Z I A B L E    miniUART   C O R E
--  S Y N T H E Z I A B L E    miniUART   C O R E
--
--
--  www.OpenCores.Org - January 2000
--  www.OpenCores.Org - January 2000
--  This core adheres to the GNU public license  
--  This core adheres to the GNU public license  
 
 
-- Design units   : miniUART core for the OCRP-1
-- Design units   : miniUART core for the OCRP-1
--
--
-- File name      : clkUnit.vhd
-- File name      : clkUnit.vhd
--
--
-- Purpose        : Implements an miniUART device for communication purposes 
-- Purpose        : Implements an miniUART device for communication purposes 
--                  between the OR1K processor and the Host computer through
--                  between the OR1K processor and the Host computer through
--                  an RS-232 communication protocol.
--                  an RS-232 communication protocol.
--                  
--                  
-- Library        : uart_lib.vhd
-- Library        : uart_lib.vhd
--
--
-- Dependencies   : IEEE.Std_Logic_1164
-- Dependencies   : IEEE.Std_Logic_1164
--
--
--===========================================================================--
--===========================================================================--
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Revision list
-- Revision list
-- Version   Author                 Date                        Changes
-- Version   Author                 Date                        Changes
--
--
-- 0.1      Ovidiu Lupas       15 January 2000                  New model
-- 0.1      Ovidiu Lupas       15 January 2000                  New model
--        ovilup@mail.dnttm.ro
--        ovilup@mail.dnttm.ro
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Description    : Generates the Baud clock and enable signals for RX & TX
-- Description    : Generates the Baud clock and enable signals for RX & TX
--                  units. 
--                  units. 
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Entity for Baud rate generator Unit - 9600 baudrate                       --
-- Entity for Baud rate generator Unit - 9600 baudrate                       --
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
library ieee;
library ieee;
   use ieee.std_logic_1164.all;
   use ieee.std_logic_1164.all;
   use ieee.numeric_std.all;
   use ieee.numeric_std.all;
library work;
library work;
   use work.UART_Def.all;
   use work.UART_Def.all;
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Baud rate generator
-- Baud rate generator
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
entity ClkUnit is
entity ClkUnit is
  port (
  port (
     SysClk   : in  Std_Logic;  -- System Clock
     SysClk   : in  Std_Logic;  -- System Clock
     EnableRx : out Std_Logic;  -- Control signal
     EnableRx : out Std_Logic;  -- Control signal
     EnableTx : out Std_Logic;  -- Control signal
     EnableTx : out Std_Logic;  -- Control signal
     Reset    : in  Std_Logic); -- Reset input
     Reset    : in  Std_Logic); -- Reset input
end entity; --================== End of entity ==============================--
end entity; --================== End of entity ==============================--
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Architecture for Baud rate generator Unit
-- Architecture for Baud rate generator Unit
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
architecture Behaviour of ClkUnit is
architecture Behaviour of ClkUnit is
  -----------------------------------------------------------------------------
  -----------------------------------------------------------------------------
  -- Signals
  -- Signals
  -----------------------------------------------------------------------------
  -----------------------------------------------------------------------------
  signal ClkDiv26  : Std_Logic;
  signal ClkDiv26  : Std_Logic;
  signal tmpEnRX   : Std_Logic;
  signal tmpEnRX   : Std_Logic;
  signal tmpEnTX   : Std_Logic;
  signal tmpEnTX   : Std_Logic;
begin
begin
  -----------------------------------------------------------------------------
  -----------------------------------------------------------------------------
  -- Divides the system clock of 40 MHz by 26
  -- Divides the system clock of 40 MHz by 26
  -----------------------------------------------------------------------------
  -----------------------------------------------------------------------------
  DivClk26 : process(SysClk,Reset)
  DivClk26 : process(SysClk,Reset)
     constant CntOne : unsigned(4 downto 0) := "00001";
     constant CntOne : unsigned(4 downto 0) := "00001";
     variable Cnt26  : unsigned(4 downto 0);
     variable Cnt26  : unsigned(4 downto 0);
  begin
  begin
     if Rising_Edge(SysClk) then
     if Rising_Edge(SysClk) then
        if Reset = '0' then
        if Reset = '0' then
           Cnt26 := "00000";
           Cnt26 := "00000";
           ClkDiv26 <= '0';
           ClkDiv26 <= '0';
        else
        else
           Cnt26 := Cnt26 + CntOne;
           Cnt26 := Cnt26 + CntOne;
           case Cnt26 is
           case Cnt26 is
              when "11010" =>
              when "11010" =>
                  ClkDiv26 <= '1';
                  ClkDiv26 <= '1';
                  Cnt26 := "00000";
                  Cnt26 := "00000";
              when others =>
              when others =>
                  ClkDiv26 <= '0';
                  ClkDiv26 <= '0';
           end case;
           end case;
        end if;
        end if;
     end if;
     end if;
  end process;
  end process;
  -----------------------------------------------------------------------------
  -----------------------------------------------------------------------------
  -- Provides the EnableRX signal, at ~ 155 KHz
  -- Provides the EnableRX signal, at ~ 155 KHz
  -----------------------------------------------------------------------------
  -----------------------------------------------------------------------------
  DivClk10 : process(SysClk,Reset,Clkdiv26)
  DivClk10 : process(SysClk,Reset,Clkdiv26)
     constant CntOne : unsigned(3 downto 0) := "0001";
     constant CntOne : unsigned(3 downto 0) := "0001";
     variable Cnt10  : unsigned(3 downto 0);
     variable Cnt10  : unsigned(3 downto 0);
  begin
  begin
     if Rising_Edge(SysClk) then
     if Rising_Edge(SysClk) then
        if Reset = '0' then
        if Reset = '0' then
           Cnt10 := "0000";
           Cnt10 := "0000";
           tmpEnRX <= '0';
           tmpEnRX <= '0';
        elsif ClkDiv26 = '1' then
        elsif ClkDiv26 = '1' then
           Cnt10 := Cnt10 + CntOne;
           Cnt10 := Cnt10 + CntOne;
        end if;
        end if;
        case Cnt10 is
        case Cnt10 is
             when "1010" =>
             when "1010" =>
                tmpEnRX <= '1';
                tmpEnRX <= '1';
                Cnt10 := "0000";
                Cnt10 := "0000";
             when others =>
             when others =>
                tmpEnRX <= '0';
                tmpEnRX <= '0';
        end case;
        end case;
     end if;
     end if;
  end process;
  end process;
  -----------------------------------------------------------------------------
  -----------------------------------------------------------------------------
  -- Provides the EnableTX signal, at 9.6 KHz
  -- Provides the EnableTX signal, at 9.6 KHz
  -----------------------------------------------------------------------------
  -----------------------------------------------------------------------------
  DivClk16 : process(SysClk,Reset,tmpEnRX)
  DivClk16 : process(SysClk,Reset,tmpEnRX)
     constant CntOne : unsigned(4 downto 0) := "00001";
     constant CntOne : unsigned(4 downto 0) := "00001";
     variable Cnt16  : unsigned(4 downto 0);
     variable Cnt16  : unsigned(4 downto 0);
  begin
  begin
     if Rising_Edge(SysClk) then
     if Rising_Edge(SysClk) then
        if Reset = '0' then
        if Reset = '0' then
           Cnt16 := "00000";
           Cnt16 := "00000";
           tmpEnTX <= '0';
           tmpEnTX <= '0';
        elsif tmpEnRX = '1' then
        elsif tmpEnRX = '1' then
           Cnt16 := Cnt16 + CntOne;
           Cnt16 := Cnt16 + CntOne;
        end if;
        end if;
        case Cnt16 is
        case Cnt16 is
           when "01111" =>
           when "01111" =>
                tmpEnTX <= '1';
                tmpEnTX <= '1';
                Cnt16 := Cnt16 + CntOne;
                Cnt16 := Cnt16 + CntOne;
           when "10010" =>
           when "10010" =>
                Cnt16 := "00000";
                Cnt16 := "00000";
           when others =>
           when others =>
                tmpEnTX <= '0';
                tmpEnTX <= '0';
        end case;
        end case;
     end if;
     end if;
  end process;
  end process;
 
 
  EnableRX <= tmpEnRX;
  EnableRX <= tmpEnRX;
  EnableTX <= tmpEnTX;
  EnableTX <= tmpEnTX;
 
 

powered by: WebSVN 2.1.0

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