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

Subversion Repositories miniuart2

[/] [miniuart2/] [trunk/] [rtl/] [vhdl/] [utils.vhd] - Blame information for rev 29

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

Line No. Rev Author Line
1 2 philippe
-------------------------------------------------------------------------------
2
-- Title      : UART
3
-- Project    : UART
4
-------------------------------------------------------------------------------
5
-- File        : utils.vhd
6
-- Author      : Philippe CARTON 
7 15 philippe
--               (philippe.carton2@libertysurf.fr)
8
-- Organization:
9 2 philippe
-- Created     : 15/12/2001
10 16 philippe
-- Last update : 8/1/2003
11 2 philippe
-- Platform    : Foundation 3.1i
12 16 philippe
-- Simulators  : ModelSim 5.5b
13
-- Synthesizers: Xilinx Synthesis
14 2 philippe
-- Targets     : Xilinx Spartan
15
-- Dependency  : IEEE std_logic_1164
16
-------------------------------------------------------------------------------
17
-- Description: VHDL utility file
18
-------------------------------------------------------------------------------
19
-- Copyright (c) notice
20
--    This core adheres to the GNU public license 
21
--
22
-------------------------------------------------------------------------------
23
-- Revisions       :
24
-- Revision Number :
25
-- Version         :
26
-- Date    :
27
-- Modifier        : name <email>
28
-- Description     :
29
--
30
------------------------------------------------------------------------------
31
 
32
 
33
-------------------------------------------------------------------------------
34
-- Revision list
35
-- Version   Author                 Date                        Changes
36
--
37
-- 1.0      Philippe CARTON  19 December 2001                   New model
38 15 philippe
--          philippe.carton2@libertysurf.fr
39 2 philippe
-------------------------------------------------------------------------------
40
 
41
-------------------------------------------------------------------------------- 
42
-- Synchroniser: 
43
--    Synchronize an input signal (C1) with an input clock (C).
44
--    The result is the O signal which is synchronous of C, and persist for
45
--    one C clock period.
46
-------------------------------------------------------------------------------- 
47
library IEEE,STD;
48 16 philippe
use IEEE.std_logic_1164.all;
49 2 philippe
 
50
entity synchroniser is
51
   port (
52 16 philippe
      C1 : in std_logic;-- Asynchronous signal
53
      C :  in std_logic;-- Clock
54
      O :  out std_logic);-- Synchronised signal
55
end synchroniser;
56 2 philippe
 
57
architecture Behaviour of synchroniser is
58 16 philippe
   signal C1A : std_logic;
59
   signal C1S : std_logic;
60
   signal R : std_logic;
61 2 philippe
begin
62
   RiseC1A : process(C1,R)
63
   begin
64
      if Rising_Edge(C1) then
65
         C1A <= '1';
66
      end if;
67
      if (R = '1') then
68
         C1A <= '0';
69 16 philippe
      end if;
70 2 philippe
   end process;
71
 
72
   SyncP : process(C,R)
73
   begin
74 16 philippe
      if Rising_Edge(C) then
75 2 philippe
         if (C1A = '1') then
76
            C1S <= '1';
77
         else C1S <= '0';
78
         end if;
79
         if (C1S = '1') then
80
            R <= '1';
81
         else R <= '0';
82
         end if;
83
      end if;
84
      if (R = '1') then
85
         C1S <= '0';
86 16 philippe
      end if;
87 2 philippe
   end process;
88
   O <= C1S;
89
end Behaviour;
90
 
91
-------------------------------------------------------------------------------
92
-- Counter
93
--    This counter is a parametrizable clock divider.
94
--    The count value is the generic parameter Count.
95
--    It is CE enabled. (it will count only if CE is high).
96
--    When it overflow, it will emit a pulse on O. 
97
--    It can be reseted to 0. 
98
-------------------------------------------------------------------------------
99
library IEEE,STD;
100 16 philippe
use IEEE.std_logic_1164.all;
101 2 philippe
 
102
entity Counter is
103
  generic(Count: INTEGER range 0 to 65535); -- Count revolution
104
  port (
105 16 philippe
     Clk      : in  std_logic;  -- Clock
106
     Reset    : in  std_logic;  -- Reset input
107
     CE       : in  std_logic;  -- Chip Enable
108
     O        : out std_logic); -- Output
109
end Counter;
110 2 philippe
 
111
architecture Behaviour of Counter is
112
begin
113
  counter : process(Clk,Reset)
114
     variable Cnt : INTEGER range 0 to Count-1;
115
  begin
116
     if Reset = '1' then
117
        Cnt := Count - 1;
118 16 philippe
        O <= '0';
119 2 philippe
     elsif Rising_Edge(Clk) then
120
        if CE = '1' then
121
           if Cnt = 0 then
122
              O <= '1';
123
              Cnt := Count - 1;
124
           else
125
              O <= '0';
126
              Cnt := Cnt - 1;
127
           end if;
128
        else O <= '0';
129
        end if;
130
     end if;
131
  end process;
132
end Behaviour;

powered by: WebSVN 2.1.0

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